Sample code for Model Context Protocl (MCP) with Server Sent Event (SSE)
LocalAbout Sample code for Model Context Protocl (MCP) with Server Sent Event (SSE)
A small Python example of an MCP server using Server-Sent Events (SSE), intended for people learning how SSE server behavior works. Its two sample methods are deliberately simple, keeping the implementation focused on demonstrating the transport.
Key features
- 01SSE transport example
- 02Two simple sample methods
- 03Python client example
Use cases
- 01Learn the flow of an MCP server over SSE
- 02Run a sample server and connect with its client
MCP support
Demonstrates an MCP server using SSE and includes a Python client that connects to it.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMESample code for Model Context Protocl (MCP) with Server Sent Event (SSE)
This repository is a sample for using SSE server. This server provides two unhelpful methods but this implementation is very simple and useful for understanding how work the SSE server.
This serer implementation is based on official sample code.
How to use
First, you must launch the server with uv command like below. This sample code has standard I/O version but this repository is just showing how to use SSE server then I don't explain the normal version. If you want to know about that please refer to the official code.
$ uv run mcp_server_sample --port 8080 --transport sse
Next, just execute client.py.
$ python client.py
Model Context Protocol (MCP) の Server Sent Event (SSE) を利用したサンプルコード
MCP の SSE での動作サンプルを実装したリポジトリです。実装自体はテキストを逆順にしたり upper case にしたりと実用的な動作はしませんが、大まかな動作の理解に役立つように実装したサンプルコードです。
サーバ側の実装は公式のサンプルを元にしています。
使い方
まずサーバサイドを起動します。サンプルでは SSE と標準入出力バージョンがありますが、このサンプルは SSE 向けなので SSE のみを紹介します。それ以外は公式サンプルをご覧ください。
uv コマンドを利用して以下のようにサーバを起動します。
$ uv run mcp_server_sample --port 8080 --transport sse
続いて、クライアント側を普通に実行します。
$ python client.py
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.