Sponsored by Deepsite.site

mcp-transport-prototype

Created By
Amishk5998 months ago
A prototype implementation to build custom MCP server that is accessible over stdio and SSE transport
Content

mcp-transport-prototype

A prototype implementation to understand building custom MCP server that is accessible over stdio and SSE transport. The goal here is to understand SSE and stdio transports.

SSE Transport?

Server-Sent Events (SSE) is a simple, efficient way to push real-time updates from the server to the client over HTTP.

  • Unlike WebSockets, SSE is one-way: the server can stream data to the client, but not vice versa.
  • It works over standard HTTP and is well-suited for scenarios like live updates, notifications, or streaming responses.

In this prototype, SSE is used to stream JSON-RPC responses from the MCP server to connected clients.

Unlike stdio, SSE runs the MCP server as a separate HTTP service. This makes it well-suited for use cases like web dashboards or browser-based apps that need to receive streamed updates from the server over the network.

sse_transport.py

It sets up an MCP server over HTTP using Server-Sent Events (SSE).

  • Clients send request via a POST API
  • Clients can listen to response using an SSE stream

See in action

# Run FastAPI server in terminal 1
python main.py --transport sse

# Open an SSE connection in terminal 2
curl http://localhost:8000/stream/test

# Send client POST reqeuest in terminal 2
curl -X POST http://localhost:8000/send/test \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "params": {
      "name": "Amish"
    }
  }'

Output

event: mcp_response
data: {"jsonrpc": "2.0", "id": 1, "result": {"echo": {"name": "Amish"}}}

What is stdio?

Stdio (short for standard input/output) is a traditional way for programs to communicate by reading from and writing to the terminal or connected processes.

  • stdin (standard input): receives input data — usually from the keyboard, a file, or another program.
  • stdout (standard output): sends output data — usually printed on the terminal or piped to another program.

In this prototype, the MCP server reads JSON-RPC requests line-by-line from stdin, processes them, and returns responses via stdout.

Compared to SSE, stdio-based MCP servers feel more like in-process tools. They're ideal when you're launching the MCP server as a subprocess, such as from a command-line tool, an LLM agent, or a background script that needs to send and receive structured data efficiently without using a network.

stdio_transport.py

It sets up an MCP server that communicates using standard input/output (stdio)

  • Reads requests from stdin
  • Writes the response back to stdout

See in action

# Run in-process MCP server
uv run main.py --transport stdio
# Send client request over STDIN
{"jsonrpc": "2.0", "id": 1, "params": {"name": "Amish"}}

Output

{"jsonrpc": "2.0", "id": 1, "result": {"echo": {"name": "Amish"}}}  # STDOUT
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
CursorThe AI Code Editor
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Serper MCP ServerA Serper MCP Server
DeepChatYour AI Partner on Desktop
Playwright McpPlaywright MCP server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
WindsurfThe new purpose-built IDE to harness magic
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Tavily Mcp
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
ChatWiseThe second fastest AI chatbot™
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Amap Maps高德地图官方 MCP Server