This project demonstrates a working pattern for SSE-based MCP (Model Context Protocol) servers and clients. It consists of three main components:
- server.py: An SSE-based MCP server that provides simple tools
- client.py: A standalone client that connects to the server and uses its tools with Claude
- mcp-sse.py: A client using praisonaiagents that connects to the server and uses its tools with OpenAI
The server implements two simple tools:
- get_greeting: Returns a personalized greeting for a given name
- get_weather: Returns simulated weather data for a given city
Make sure you have the required packages installed:
pip install praisonaiagents mcp httpx starlette uvicorn anthropic python-dotenvFirst, start the MCP SSE server:
python server.pyBy default, the server runs on 0.0.0.0:8080, but you can customize the host and port:
python server.py --host 127.0.0.1 --port 8081The standalone client uses Claude to interact with the MCP server tools:
# Set your Anthropic API key
export ANTHROPIC_API_KEY=your_api_key_here
# Run the client
python client.py http://0.0.0.0:8080/sseYou'll see a prompt where you can type queries for Claude to process using the MCP tools.
The praisonaiagents client uses OpenAI to interact with the MCP server tools:
# Set your OpenAI API key
export OPENAI_API_KEY=your_api_key_here
# Run the client
python mcp-sse.pyThis will automatically send a query about the weather in Paris to the agent.
- The server exposes MCP tools via an SSE endpoint
- Clients connect to this endpoint and discover available tools
- When a user makes a query, the client:
- For client.py: Uses Claude to determine which tool to call
- For mcp-sse.py: Uses OpenAI to determine which tool to call
- The client executes the tool call against the server
- The result is returned to the user
This pattern allows for decoupled processes where the MCP server can run independently of clients, making it suitable for cloud-native applications.
- To add more tools to the server, define new functions with the
@mcp.tool()decorator inserver.py - To change the client's behavior, update the instructions and query in
mcp-sse.py