Sponsored by Deepsite.site

SSE-based Server and Client for

Created By
sidharthrajarama year ago
A working pattern for SSE-based MCP clients and servers
Content

SSE-based Server and Client for MCP

smithery badge

This demonstrates a working pattern for SSE-based MCP servers and standalone MCP clients that use tools from them. Based on an original discussion here.

Usage

Note: 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
Initialized SSE client...
Listing tools...

Connected to server with tools: ['get_alerts', 'get_forecast']

MCP Client Started!
Type your queries or 'quit' to exit.

Query: whats the weather like in Spokane?

I can help you check the weather forecast for Spokane, Washington. I'll use the get_forecast function, but I'll need to use Spokane's latitude and longitude coordinates.

Spokane, WA is located at approximately 47.6587° N, 117.4260° W.
[Calling tool get_forecast with args {'latitude': 47.6587, 'longitude': -117.426}]
Based on the current forecast for Spokane:

Right now it's sunny and cold with a temperature of 37°F and ...

Why?

This means the MCP server can now be some running process that agents (clients) connect to, use, and disconnect from whenever and wherever they want. In other words, an SSE-based server and clients can be decoupled processes (potentially even, on decoupled nodes). This is different and better fits "cloud-native" use-cases compared to the STDIO-based pattern where the client itself spawns the server as a subprocess.

Installing via Smithery

To install 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 a SSE-based MCP server that presents some tools based on the National Weather Service APIs. Adapted from the MCP docs' example STDIO server implementation.

By default, server runs on 0.0.0.0:8080, but is configurable with command line arguments like:

uv run weather.py --host <your host> --port <your port>

Client

client.py is a MCP Client that connects to and uses tools from the SSE-based MCP server. Adapted from the MCP docs' example STDIO client implementation.

By default, client connects to SSE endpoint provided in the command line argument like:

uv run client.py http://0.0.0.0:8080/sse
Recommend Clients
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
HyperChatHyperChat is a Chat client that strives for openness, utilizing APIs from various LLMs to achieve the best Chat experience, as well as implementing productivity tools through the MCP protocol.
LutraLutra is the first MCP compatible client built for everyone
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
WindsurfThe new purpose-built IDE to harness magic
Roo Code (prev. Roo Cline)Roo Code (prev. Roo Cline) gives you a whole dev team of AI agents in your code editor.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Continue⏩ Create, share, and use custom AI code assistants with our open-source IDE extensions and hub of models, rules, prompts, docs, and other building blocks
chatmcpChatMCP is an AI chat client implementing the Model Context Protocol (MCP).
ZedCode at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
A Sleek AI Assistant & MCP Client5ire is a cross-platform desktop AI assistant, MCP client. It compatible with major service providers, supports local knowledge base and tools via model context protocol servers .
DeepChatYour AI Partner on Desktop
MCP ConnectEnables cloud-based AI services to access local Stdio based MCP servers via HTTP requests
MCP PlaygroundCall MCP Server Tools Online
Cherry Studio🍒 Cherry Studio is a desktop client that supports for multiple LLM providers.
MCP-CONNECT
Cline – #1 on OpenRouterAutonomous coding agent right in your IDE, capable of creating/editing files, executing commands, using the browser, and more with your permission every step of the way.
ChatWiseThe second fastest AI chatbot™
CursorThe AI Code Editor
Refact.aiOpen-source AI Agent for VS Code and JetBrains that autonomously solves coding tasks end-to-end.
y-cli 🚀A Tiny Terminal Chat App for AI Models with MCP Client Support