This repository contains an implementation of a Message Control Protocol system using Python. The project provides both client and server components for handling message-based communications.
mcp.py- Client implementation with websocket connection handlingapp.py- Server implementation using FastMCP framework
- WebSocket-based communication
- Tool registration and management
- Dynamic resource routing
- Example implementations:
- Addition tool
- Dynamic greeting resource
pip install smithery
pip install mcpThe server component (app.py) demonstrates how to:
- Create an MCP server
- Register tools and resources
- Handle dynamic routing
Example server code:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Demo")
@mcp.tool()
def add(a: int, b: int) -> int:
return a + bThe client component (mcp.py) shows how to:
- Connect to the MCP server
- List available tools
- Make tool calls
Example client code:
async with websocket_client(url) as streams:
async with mcp.ClientSession(*streams) as session:
tools_result = await session.list_tools()Make sure to set up your environment with:
- Smithery API key
- GitHub Personal Access Token (if using GitHub integration)
Feel free to submit issues and pull requests to improve the implementation.
This project is open source and available under the MIT License.