STARLETTE_MCP_SSE
Ein Arbeitsbeispiel, um einen Starlette-Server mit SSE-basierter MCP-Support zu erstellen
1
Github Watches
4
Github Forks
6
Github Stars
Starlette MCP SSE
English | 简体中文
A Server-Sent Events (SSE) implementation using Starlette framework with Model Context Protocol (MCP) integration.
What is MCP?
The Model Context Protocol (MCP) is an open standard that enables AI models to interact with external tools and data sources. MCP solves several key challenges in AI development:
- Context limitations: Allows models to access up-to-date information beyond their training data
 - Tool integration: Provides a standardized way for models to use external tools and APIs
 - Interoperability: Creates a common interface between different AI models and tools
 - Extensibility: Makes it easy to add new capabilities to AI systems without retraining
 
This project demonstrates how to implement MCP using Server-Sent Events (SSE) in a Starlette web application.
Description
This project demonstrates how to implement Server-Sent Events (SSE) using the Starlette framework while integrating Model Context Protocol (MCP) functionality. The key feature is the seamless integration of MCP's SSE capabilities within a full-featured Starlette web application that includes custom routes.
Features
- Server-Sent Events (SSE) implementation with MCP
 - Starlette framework integration with custom routes
 - Unified web application with both MCP and standard web endpoints
 - Customizable route structure
 - Clean separation of concerns between MCP and web functionality
 
Architecture
This project showcases a modular architecture that:
- Integrates MCP SSE endpoints (
/sseand/messages/) into a Starlette application - Provides standard web routes (
/,/about,/status,/docs) - Demonstrates how to maintain separation between MCP functionality and web routes
 
Installation & Usage Options
Prerequisites
Install UV Package Manager - A fast Python package installer written in Rust:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Option 1: Quick Run Without Installation
Run the application directly without cloning the repository using UV's execution tool:
uvx --from git+https://github.com/panz2018/starlette_mcp_sse.git start
Option 2: Full Installation
Create Virtual Environment
Create an isolated Python environment for the project:
uv venv
Activate Virtual Environment
Activate the virtual environment to use it:
.venv\Scripts\activate
Install Dependencies
Install all required packages:
uv pip install -r pyproject.toml
Start the Integrated Server
Launch the integrated Starlette server with MCP SSE functionality:
python src/server.py
or
uv run start
Available Endpoints
After starting the server (using either Option 1 or Option 2), the following endpoints will be available:
- Main server: http://localhost:8000
 - Standard web routes:
- Home page: http://localhost:8000/
 - About page: http://localhost:8000/about
 - Status API: http://localhost:8000/status
 - Documentation: http://localhost:8000/docs
 
 - MCP SSE endpoints:
- SSE endpoint: http://localhost:8000/sse
 - Message posting: http://localhost:8000/messages/
 
 
Debug with MCP Inspector
For testing and debugging MCP functionality, use the MCP Inspector:
mcp dev ./src/weather.py
Connect to MCP Inspector
- Open MCP Inspector at http://localhost:5173
 - Configure the connection:
- Set Transport Type to 
SSE - Enter URL: http://localhost:8000/sse
 - Click 
Connect 
 - Set Transport Type to 
 
Test the Functions
- Navigate to 
Toolssection - Click 
List Toolsto see available functions:- 
get_alerts: Get weather alerts - 
get_forcast: Get weather forecast 
 - 
 - Select a function
 - Enter required parameters
 - Click 
Run Toolto execute 
Extending the Application
Adding Custom Routes
The application structure makes it easy to add new routes:
- Define new route handlers in routes.py
 - Add routes to the routes list in routes.py
 - The main application will automatically include these routes
 
Customizing MCP Integration
The MCP SSE functionality is integrated in server.py through:
- Creating an SSE transport
 - Setting up an SSE handler
 - Adding MCP routes to the Starlette application
 
Integration with Continue
To use this MCP server with the Continue VS Code extension, add the following configuration to your Continue settings:
{
  "experimental": {
    "modelContextProtocolServers": [
      {
        "transport": {
          "name": "weather",
          "type": "sse",
          "url": "http://localhost:8000/sse"
        }
      }
    ]
  }
}
                                相关推荐
I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.
I find academic articles and books for research and literature reviews.
Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.
Confidential guide on numerology and astrology, based of GG33 Public information
Advanced software engineer GPT that excels through nailing the basics.
Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.
Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.
Converts Figma frames into front-end code for various mobile frameworks.
Entdecken Sie die umfassendste und aktuellste Sammlung von MCP-Servern auf dem Markt. Dieses Repository dient als zentraler Hub und bietet einen umfangreichen Katalog von Open-Source- und Proprietary MCP-Servern mit Funktionen, Dokumentationslinks und Mitwirkenden.
Die All-in-One-Desktop & Docker-AI-Anwendung mit integriertem Lappen, AI-Agenten, No-Code-Agent Builder, MCP-Kompatibilität und vielem mehr.
Fair-Code-Workflow-Automatisierungsplattform mit nativen KI-Funktionen. Kombinieren Sie visuelles Gebäude mit benutzerdefiniertem Code, SelbstHost oder Cloud, 400+ Integrationen.
🧑🚀 全世界最好的 llm 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Zusammenfassung der weltbesten LLM -Ressourcen.
Reviews
user_dCjmIr41
I'm really impressed with BinoculoMCP (WIP) by Girorme! It offers innovative features that simplify my workflow significantly. The interface is user-friendly, and the performance is quite remarkable. I can't wait to see the final version and more updates. Highly recommend to anyone interested in enhancing their productivity.