Skip to main content

Echo Service - ChukMCP Server Test Project

Project description

ChukMCP Echo Service

An async-native demonstration MCP (Model Context Protocol) service built using the ChukMCP Server framework. This service showcases various MCP capabilities including text processing, data manipulation, and testing features with full async/await support.

Features

  • Async-Native Architecture: All tools and resources implemented with async/await
  • Text Processing: Echo, uppercase, reverse text operations
  • Data Manipulation: JSON echoing with metadata, list processing, number operations
  • Testing Utilities: Delayed responses for async testing, error simulation
  • Resource Management: Configuration, status, examples, and documentation resources
  • Non-blocking I/O: Handles concurrent requests efficiently

Installation

Using pip

pip install chuk-mcp-echo

Using uv

uv pip install chuk-mcp-echo

Using uvx (for running directly)

uvx chuk-mcp-echo

Development Installation

git clone https://github.com/yourusername/chuk-mcp-echo.git
cd chuk-mcp-echo
make dev-install

Quick Start

Running the Service

The echo service can run in two modes: HTTP mode (default) and stdio mode (for MCP clients).

HTTP Mode (Default)

# Using the installed command
chuk-mcp-echo

# Or explicitly specify HTTP mode
chuk-mcp-echo http

# With custom host and port
chuk-mcp-echo http --host 0.0.0.0 --port 9000

# Or using make
make run

# Or using uvx
uvx chuk-mcp-echo

The service will start on http://localhost:8000 with the MCP endpoint at http://localhost:8000/mcp.

Stdio Mode (For MCP Clients)

# Run in stdio mode for MCP clients
chuk-mcp-echo stdio

# With debug logging (sent to stderr)
chuk-mcp-echo stdio --debug

# Using uvx
uvx chuk-mcp-echo stdio

MCP Client Configuration

To use this service with an MCP client (like Claude Desktop or mcp-cli), add the following to your MCP client configuration:

{
  "mcpServers": {
    "echo": {
      "command": "uvx",
      "args": ["chuk-mcp-echo", "stdio"]
    }
  }
}

Or if you have it installed locally:

{
  "mcpServers": {
    "echo": {
      "command": "chuk-mcp-echo",
      "args": ["stdio"]
    }
  }
}

Or if you want to run it from source:

{
  "mcpServers": {
    "echo": {
      "command": "python",
      "args": ["-m", "chuk_mcp_echo.main", "stdio"],
      "env": {
        "PYTHONPATH": "/path/to/chuk-mcp-echo/src"
      }
    }
  }
}

Testing with MCP Inspector

  1. Open MCP Inspector
  2. Set Transport Type to "Streamable HTTP"
  3. Enter URL: http://localhost:8000/mcp
  4. Connect and explore available tools and resources

Available Tools

Text Processing

  • echo_text(message, prefix="", suffix="") - Echo text with optional formatting
  • echo_uppercase(text) - Convert text to uppercase
  • echo_reverse(text) - Reverse the text

Data Processing

  • echo_json(data) - Echo JSON data with metadata
  • echo_list(items, sort=False, reverse=False) - Process and echo lists
  • echo_number(number, multiply=1.0, add=0.0) - Perform number operations

Testing & Utility

  • echo_delay(message, delay_seconds=1.0) - Test async delayed responses
  • echo_error(should_error=False, error_message="Test error") - Test error handling
  • get_service_info() - Get service information

Available Resources

  • echo://config - Service configuration and features (JSON)
  • echo://status - Current service status and health (JSON)
  • echo://examples - Comprehensive usage examples (JSON)
  • echo://docs - Complete service documentation (Markdown)

Development

Project Structure

chuk-mcp-echo/
\x00\x00 src/
   \x00\x00 chuk_mcp_echo/
       \x00\x00 __init__.py
       \x00\x00 main.py          # Entry point
       \x00\x00 server.py        # Server configuration
       \x00\x00 tools.py         # Async tool implementations
       \x00\x00 resources.py     # Async resource handlers
\x00\x00 tests/
   \x00\x00 test_echo_service.py
   \x00\x00 test_simple.py
\x00\x00 examples/
   \x00\x00 api_test_script.py
\x00\x00 debug/
   \x00\x00 debug_failing_tests.py
   \x00\x00 debug_imports.py
\x00\x00 Makefile
\x00\x00 pyproject.toml
\x00\x00 README.md

Running Tests

# Run all tests
make test

# Run with coverage
make test-cov

# Run specific test
uv run pytest tests/test_echo_service.py::test_echo_text

Code Quality

# Run all checks (lint, typecheck, tests)
make check

# Format code
make format

# Run linter
make lint

# Type checking
make typecheck

Building and Publishing

# Build the package
make build

# Publish to PyPI
make publish

# Publish to Test PyPI
make publish-test

Usage Examples

Using with Python Client

import asyncio
from chuk_mcp_client import ChukMCPClient

async def main():
    client = ChukMCPClient("http://localhost:8000/mcp")
    
    # Echo text
    result = await client.call_tool("echo_text", {
        "message": "Hello, World!",
        "prefix": ">>> ",
        "suffix": " <<<"
    })
    print(result)  # >>> Hello, World! <<<
    
    # Process a list
    result = await client.call_tool("echo_list", {
        "items": [3, 1, 4, 1, 5],
        "sort": True
    })
    print(result["processed"])  # [1, 1, 3, 4, 5]
    
    # Test async behavior with delay
    result = await client.call_tool("echo_delay", {
        "message": "Delayed message",
        "delay_seconds": 2.0
    })
    print(result["actual_delay"])  # ~2.0

asyncio.run(main())

Concurrent Execution Example

async def test_concurrent_requests():
    # Multiple requests execute concurrently
    tasks = [
        client.call_tool("echo_delay", {"message": f"Message {i}", "delay_seconds": 2.0})
        for i in range(3)
    ]
    
    # All complete in ~2 seconds (concurrent) not 6 seconds (sequential)
    results = await asyncio.gather(*tasks)
    return results

Requirements

  • Python 3.11+
  • ChukMCP Server >= 0.2.3
  • Pydantic >= 2.11.7
  • Uvicorn >= 0.35.0

License

MIT License - See LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues, questions, or suggestions, please open an issue on the GitHub repository.

Acknowledgments

Built with the ChukMCP Server framework for creating async-native MCP services.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chuk_mcp_echo-0.1.3.tar.gz (57.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chuk_mcp_echo-0.1.3-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file chuk_mcp_echo-0.1.3.tar.gz.

File metadata

  • Download URL: chuk_mcp_echo-0.1.3.tar.gz
  • Upload date:
  • Size: 57.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for chuk_mcp_echo-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2432ea348d9b678c5e91a783dca5df91ee476c5b84a0ec688f089638cd674c61
MD5 d1fef6b5238c1d24b835b205acb24f0e
BLAKE2b-256 3d21230c1c4dbd2f17e194efd91e916815bbf17815febf8289ca3728f1befff9

See more details on using hashes here.

File details

Details for the file chuk_mcp_echo-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: chuk_mcp_echo-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for chuk_mcp_echo-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 eb16d1235848dc90e0f95c868b77eb328a48bc1d9e8bc58ee835a394e158353c
MD5 b9ff9b9a60996b6e61a49aca8e6a276e
BLAKE2b-256 a9c611cd38a9efc6053f97c90ab4b3d546d528f82f9b487de088b35c38ace811

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page