mcp-sse
by: sidharthrajaram
A working pattern for SSE-based MCP clients and servers
📌Overview
Purpose: To demonstrate a scalable, decoupled architecture for building SSE-based MCP servers and clients that can operate independently.
Overview: This project provides a server and client implementation utilizing Server-Sent Events (SSE) within the Model Context Protocol (MCP). Designed to work seamlessly in cloud-native environments, it allows for dynamic interaction between clients and a server, enabling flexible querying capabilities for various tools, such as weather forecasts.
Key Features:
-
Decoupled Processes: The MCP server and clients can operate independently, allowing for connections and disconnections at will, enhancing flexibility and cloud-native compatibility.
-
SSE Client and Server: Offers a simple implementation for both server (
weather.py
) and client (client.py
) using the National Weather Service APIs for the client to retrieve weather data based on user queries.
SSE-based Server and Client for MCP
This demonstrates a working pattern for SSE-based MCP servers and standalone MCP clients. Based on an original discussion here.
Usage
Make sure to supply ANTHROPIC_API_KEY
in .env
or as an environment variable.
uv run weather.py
uv run client.py http://0.0.0.0:8080/sse
The client initializes and connects to the server. You can then type queries or 'quit' to exit. For example:
Query: what's the weather like in Spokane?
Why?
This architecture allows the MCP server to be a running process that agents (clients) can connect to, use, and disconnect from, fitting "cloud-native" use cases better than the STDIO-based pattern where the client spawns the server as a subprocess.
Installation via Smithery
To install the SSE-based Server and Client for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @sidharthrajaram/mcp-sse --client claude
Server
weather.py
is an SSE-based MCP server that presents tools based on the National Weather Service APIs. By default, the server runs on 0.0.0.0:8080
, but is configurable with command line arguments:
uv run weather.py --host <your host> --port <your port>
Client
client.py
is an MCP Client that connects to and uses tools from the SSE-based MCP server. By default, it connects to the SSE endpoint provided in the command line argument:
uv run client.py http://0.0.0.0:8080/sse