- Explore MCP Servers
- fastapi-sse-mcp
Fastapi Sse Mcp
What is Fastapi Sse Mcp
fastapi-sse-mcp is a FastAPI application that integrates Server-Sent Events (SSE) with the Model Context Protocol (MCP), showcasing how to use SSE as a transport layer for MCP in a web application.
Use cases
Use cases include creating echo tools and prompts, handling resource requests, and establishing real-time connections for applications that benefit from immediate updates.
How to use
To use fastapi-sse-mcp, clone the repository, install the required dependencies, and run the FastAPI server using the provided commands. Access the API endpoints to interact with the application.
Key features
Key features include handling FastAPI HTTP requests, implementing MCP tools, resources, and prompts using the MCP python-sdk, and providing a simple echo service via SSE.
Where to use
fastapi-sse-mcp can be used in web applications that require real-time data streaming, such as chat applications, notifications systems, or any scenario where server-to-client communication is needed.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Fastapi Sse Mcp
fastapi-sse-mcp is a FastAPI application that integrates Server-Sent Events (SSE) with the Model Context Protocol (MCP), showcasing how to use SSE as a transport layer for MCP in a web application.
Use cases
Use cases include creating echo tools and prompts, handling resource requests, and establishing real-time connections for applications that benefit from immediate updates.
How to use
To use fastapi-sse-mcp, clone the repository, install the required dependencies, and run the FastAPI server using the provided commands. Access the API endpoints to interact with the application.
Key features
Key features include handling FastAPI HTTP requests, implementing MCP tools, resources, and prompts using the MCP python-sdk, and providing a simple echo service via SSE.
Where to use
fastapi-sse-mcp can be used in web applications that require real-time data streaming, such as chat applications, notifications systems, or any scenario where server-to-client communication is needed.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
FastAPI SSE MCP
A FastAPI application that demonstrates Server-Sent Events (SSE) integration with the Model Context Protocol
Overview
This project showcases how to use Server-Sent Events (SSE) as a transport layer for MCP in a FastAPI application. It provides a simple echo service that can:
- Handle FastAPI HTTP requests
- Implement MCP tools, resources and prompts using the MCP python-sdk
Requirements
- Python 3.12+
- FastAPI 0.115.11+
- MCP 1.4.1+
Installation
-
Clone this repository:
git clone https://github.com/ragieai/fastapi-sse-mcp.git cd fastapi-sse-mcp -
Install dependencies:
uv sync --dev
Running the Application
Start the FastAPI server:
uv run uvicorn app.main:app --reload
The server will be available at http://127.0.0.1:8000.
API Endpoints
GET /- Returns a simple JSON greetingGET /sse/- SSE endpoint for establishing connectionsPOST /messages/- Endpoint for sending messages over SSE
Examples
The application provides three example MCP functions:
-
Tool Function: Echoes messages
@mcp.tool() def echo_tool(message: str) -> str: """Echo a message as a tool""" return f"Tool echo: {message}" -
Prompt Function: Creates echo prompts
@mcp.prompt() def echo_prompt(message: str) -> str: """Create an echo prompt""" return f"Please process this message: {message}" -
Resource Function: Handles resource requests
@mcp.resource("echo://{message}") def echo_resource(message: str) -> str: """Echo a message as a resource""" return f"Resource echo: {message}"
License
MIT License
Copyright © 2024 Ragie Corp
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










