Sample code for Model Context Protocl (MCP) with Server Sent Event (SSE)
Overview
MCP-SSE-Server-Sample is a sample code repository demonstrating the use of Server Sent Events (SSE) with the Model Context Protocol (MCP). It provides a simple implementation to help users understand how an SSE server operates.
To use this sample, first launch the server using the uv command: shell $ uv run mcp_server_sample --port 8080 --transport sse Then, execute the client script: shell $ python client.py
- Simple implementation of an SSE server for educational purposes. - Demonstrates basic server-client interaction using MCP. - Based on official sample code for better understanding.
- Learning how to implement a basic SSE server.
- Understanding the interaction between server and client using MCP.
- Experimenting with server-side event handling in Python.
Add to your AI client
Use these steps to connect Sample code for Model Context Protocl (MCP) with Server Sent Event (SSE) in Cursor, Claude, VS Code, and other MCP-compatible apps. The same JSON appears in the Use with menu above for one-click copy.
Cursor
Add this to your .cursor/mcp.json file in your project root, then restart Cursor.
.cursor/mcp.json
{
"mcpServers": {
"mcp-sse-server-sample-edom18": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mcp-sse-server-sample-edom18"
]
}
}
}Claude Desktop
Add this server entry to the mcpServers object in your Claude Desktop config, then restart the app.
~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
{
"mcpServers": {
"mcp-sse-server-sample-edom18": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mcp-sse-server-sample-edom18"
]
}
}
}Claude Code
Add this to your project's .mcp.json file. Claude Code will detect it automatically.
.mcp.json (project root)
{
"mcpServers": {
"mcp-sse-server-sample-edom18": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mcp-sse-server-sample-edom18"
]
}
}
}VS Code (Copilot)
Add this to your .vscode/mcp.json file. Requires the GitHub Copilot extension with MCP support enabled.
.vscode/mcp.json
{
"servers": {
"mcp-sse-server-sample-edom18": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mcp-sse-server-sample-edom18"
]
}
}
}Windsurf
Add this to your Windsurf MCP config file, then restart Windsurf.
~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"mcp-sse-server-sample-edom18": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mcp-sse-server-sample-edom18"
]
}
}
}Cline
Open Cline settings, navigate to MCP Servers, and add this server configuration.
Cline MCP Settings (via UI)
{
"mcpServers": {
"mcp-sse-server-sample-edom18": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-mcp-sse-server-sample-edom18"
]
}
}
}FAQ
What is Server Sent Events (SSE)?
SSE is a standard describing how servers can initiate data transmission to web clients once an initial client connection has been established.
Is this sample suitable for production use?
No, this sample is intended for educational purposes and may not be suitable for production environments.
Where can I find the official documentation?
You can refer to the official Model Context Protocol documentation for more details.7:["$","div",null,{"className":"container mx-auto flex flex-col gap-4","children":["$L26","$L27",["$","$L28",null,{"currentProject":{"id":2911,"uuid":"d5fea27b-84da-46ff-a21a-6a9264844c4a","name":"MCP-SSE-Server-Sample","title":"Sample code for Model Context Protocl (MCP) with Server Sent Event (SSE)","description":"","avatar_url":"https://avatars.githubusercontent.com/u/208165?v=4","created_at":"2025-03-16T04:07:56.590Z","updated_at":"2025-03-16T16:22:07.886Z","status":"created","author_name":"edom18","author_avatar_url":"https://avatars.githubusercontent.com/u/208165?v=4","tags":"[]","category":"developer-tools","is_featured":false,"sort":1,"url":"https://github.com/edom18/MCP-SSE-Server-Sample","target":"_self","content":"$29","summary":"$2a","img_url":null,"type":null,"metadata":"{\"star\":\"0\",\"license\":\"\",\"language\":\"Python\",\"is_official\":false,\"latest_commit_time\":\"2025-03-16 11:33:53\"}","user_uuid":null,"tools":null,"sse_url":null,"sse_provider":null,"sse_params":null,"is_official":false,"server_command":null,"server_params":null,"server_config":null,"allow_call":false,"is_innovation":false,"is_dxt":false,"dxt_manifest":null,"dxt_file_url":null,"is_audit":false},"randomProjects":[],"currentServerKey":"$undefined"}]]}]