Cover image
Try Now
2025-04-14

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

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

  1. Clone this repository:

    git clone https://github.com/ragieai/fastapi-sse-mcp.git
    cd fastapi-sse-mcp
    
  2. 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 greeting
  • GET /sse/ - SSE endpoint for establishing connections
  • POST /messages/ - Endpoint for sending messages over SSE

Examples

The application provides three example MCP functions:

  1. Tool Function: Echoes messages

    @mcp.tool()
    def echo_tool(message: str) -> str:
        """Echo a message as a tool"""
        return f"Tool echo: {message}"
    
  2. Prompt Function: Creates echo prompts

    @mcp.prompt()
    def echo_prompt(message: str) -> str:
        """Create an echo prompt"""
        return f"Please process this message: {message}"
    
  3. 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 (c) 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.

相关推荐

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

  • 1Panel-dev
  • 🔥 1Panel proporciona una interfaz web intuitiva y un servidor MCP para administrar sitios web, archivos, contenedores, bases de datos y LLM en un servidor de Linux.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llM 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Resumen de los mejores recursos del mundo.

  • rulego
  • ⛓️Rulego es un marco de motor de regla de orquestación de componentes de alta generación de alto rendimiento, de alto rendimiento y de alto rendimiento para GO.

  • Onelevenvy
  • Flock es una plataforma de bajo código de flujo de trabajo para construir rápidamente chatbots, trapo y coordinar equipos de múltiples agentes, impulsados ​​por Langgraph, Langchain, Fastapi y Nextjs.

  • Byaidu
  • Traducción de papel científico en PDF con formatos preservados - 基于 Ai 完整保留排版的 PDF 文档全文双语翻译 , 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 等服务 等服务 等服务 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 cli/mcp/docker/zotero

  • n8n-io
  • Plataforma de automatización de flujo de trabajo de código justo con capacidades de IA nativas. Combine el edificio visual con código personalizado, auto-anfitrión o nube, más de 400 integraciones.

  • sigoden
  • Cree fácilmente herramientas y agentes de LLM utilizando funciones Plain Bash/JavaScript/Python.

  • hkr04
  • SDK liviano C ++ MCP (Protocolo de contexto del modelo)

  • RockChinQ
  • 😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 Qq / 微信(企业微信、个人微信) / 飞书 / 钉钉 / Discord / Telegram / Slack 等平台 | 支持 Chatgpt 、 Deepseek 、 DiFy 、 Claude 、 Gemini 、 Xai 、 PPIO 、 Ollama 、 LM Studio 、阿里云百炼、火山方舟、 Siliconflow 、 Qwen 、 Moonshot 、 Chatglm 、 SillyTraven 、 MCP 等 LLM 的机器人 / Agente | Plataforma de bots de mensajería instantánea basada en LLM, admite Discord, Telegram, WeChat, Lark, Dingtalk, QQ, Slack

  • dmayboroda
  • Trapo conversacional local con contenedores configurables

    Reviews

    2.7 (17)
    Avatar
    user_oQNcOv5D
    2025-04-23

    I recently started using fastapi-sse-mcp by fgsoap, and it has been a game-changer for my projects. The seamless integration with FastAPI and the real-time capabilities provided by SSE are outstanding. It simplifies a lot of the complexities I faced before, and the documentation is clear and helpful. Highly recommend for anyone needing efficient server-sent events in their FastAPI applications!

    Avatar
    user_HK9jd1Sf
    2025-04-23

    As a devoted user of the fastapi-sse-mcp application by fgsoap, I am thoroughly impressed with its seamless integration of server-sent events in FastAPI. The setup is straightforward, and the real-time capabilities have significantly enhanced my web applications. This product exemplifies reliability and efficiency, making it a must-have for modern web development. Highly recommended!

    Avatar
    user_eLhluiDT
    2025-04-23

    As a devoted user of fastapi-sse-mcp, I find this tool invaluable for Server-Sent Events (SSE) in my FastAPI projects. The seamless integration and excellent support by the author, fgsoap, make setting up real-time communication a breeze. Its comprehensive documentation and user-friendly features significantly streamline my development process. Highly recommended for developers looking for efficient SSE solutions in FastAPI apps!

    Avatar
    user_PSvbhMtm
    2025-04-23

    I've been using fastapi-sse-mcp and it's just incredible! The integration with FastAPI makes handling server-sent events seamless and efficient. Kudos to fgsoap for creating such a robust and easy-to-use tool. Highly recommended for anyone working with real-time data streaming!

    Avatar
    user_Uu9GWr2d
    2025-04-23

    As a dedicated MCP application user, I am thoroughly impressed with fastapi-sse-mcp by fgsoap. This innovative tool enhances server-sent events integration with FastAPI, making real-time data streaming seamless and efficient. The intuitive design and robust functionality elevate productivity and streamline an otherwise complex process. Highly recommended for any developer working with real-time applications!

    Avatar
    user_poTGFg7s
    2025-04-23

    Fastapi-sse-mcp is a brilliant tool by fgsoap! It seamlessly integrates with FastAPI applications to provide Server-Sent Events (SSE) functionality, making real-time updates a breeze. The documentation and support are top-notch, and its ease of use is impressive, even for beginners. Highly recommended for anyone looking to enhance their FastAPI projects with SSE.

    Avatar
    user_Ud1qVNo2
    2025-04-23

    I'm thoroughly impressed with fastapi-sse-mcp by fgsoap. This tool makes server-sent events integration seamless and efficient, greatly enhancing real-time capabilities for my FastAPI projects. The documentation is clear, and the setup is straightforward, making it a go-to for developers looking to boost their app's live data handling. Highly recommend!

    Avatar
    user_qEaIgXiY
    2025-04-23

    As a devoted MCP application user, I have to say that fastapi-sse-mcp by fgsoap is a game-changer! It's incredibly efficient and easy to integrate into any project. The real-time updates with SSE are seamless, and the developer support is top-notch. Highly recommend it to anyone looking to enhance their FastAPI applications with server-sent events.

    Avatar
    user_h9igGhns
    2025-04-23

    Fastapi-sse-mcp by fgsoap is a fantastic solution for scalable server-sent events in FastAPI applications. It stands out for its seamless integration and simplicity, making real-time data streaming a breeze. I've found it incredibly effective in managing live updates and notifications. Highly recommended for anyone looking to enhance their FastAPI projects with real-time capabilities!

    Avatar
    user_tns9Nr7m
    2025-04-23

    As a devoted MCP user, I find fastapi-sse-mcp by fgsoap to be immensely beneficial. This well-crafted FastAPI extension enhances server-sent events (SSE) handling, making real-time data updates seamless and efficient. The implementation is straightforward and the documentation is clear, providing a great developer experience. Highly recommended for anyone needing reliable SSE in their FastAPI projects!

    Avatar
    user_icWI8NiL
    2025-04-23

    As a loyal MCP user, I have to say that the fastapi-sse-mcp by fgsoap is an impressive solution! Its seamless integration with FastAPI and real-time capabilities through server-sent events (SSE) have significantly improved our application's performance and user experience. Highly recommend it to any developer working on dynamic web applications!

    Avatar
    user_gAeCfMmV
    2025-04-23

    As a loyal user of the fastapi-sse-mcp, I must say it has significantly simplified my real-time data streaming tasks. The seamless integration with FastAPI and the robustness provided by fgsoap's development make it a go-to choice for any developer working on server-sent events. Highly recommend for anyone looking to optimize their async workflows!

    Avatar
    user_1jrqtjEZ
    2025-04-23

    Fastapi-sse-mcp by fgsoap is an exceptional product for implementing server-sent events with FastAPI. It's efficient, reliable, and its integration is seamless. The documentation provided is clear and concise, making it easy even for beginners to get started. Highly recommend it for any FastAPI project requiring real-time data streaming.

    Avatar
    user_Upw5INey
    2025-04-23

    As a dedicated user of the fastapi-sse-mcp application by fgsoap, I am thoroughly impressed by its seamless integration and efficient performance. The ability to handle server-sent events with ease has significantly improved the responsiveness of my projects. Its functionality and reliability in real-time data communication set it apart, making it an invaluable tool in modern web development. Highly recommended for anyone looking to enhance their FastAPI applications!

    Avatar
    user_GENB0YIC
    2025-04-23

    As a dedicated user of fastapi-sse-mcp, I am extremely impressed by fgsoap's creation. This tool simplifies implementing server-sent events with FastAPI, making real-time communication effortless. Its seamless integration and robust performance have significantly enhanced my application's responsiveness. Highly recommend for anyone needing efficient and effective SSE solutions!

    Avatar
    user_qIMPcFTr
    2025-04-23

    fastapi-sse-mcp by fgsoap is a fantastic tool for real-time web applications. The seamless integration and robust performance make it a go-to for handling server-sent events efficiently. As a developer, I find it incredibly user-friendly, streamlining the process of developing dynamic web apps with ease. I highly recommend giving it a try!

    Avatar
    user_FK0Rc6Dd
    2025-04-23

    As a dedicated MCP application user, I find fastapi-sse-mcp by fgsoap absolutely impressive. Its seamless integration and real-time capabilities make it a must-have for any developer working with server-sent events. The straightforward setup through the provided URL and the welcoming guide ensured a smooth start. Highly recommend!