drio
Open app

FastAPI MCP SSE

Source

A working example to create a FastAPI server with SSE-based MCP support

Catalog onlyCatalog onlySTDIO

Overview

FastAPI MCP SSE is a project that demonstrates how to create a FastAPI server with Server-Sent Events (SSE) support, integrating the Model Context Protocol (MCP) for enhanced AI model interactions.

To use this project, you can either run it directly without installation using UV's execution tool or set up a virtual environment and install the required dependencies. After starting the server, you can access various endpoints for both standard web routes and MCP SSE functionality.

  • Implementation of Server-Sent Events (SSE) with MCP integration. - Customizable route structure within a FastAPI application. - Unified web application with both MCP and standard web endpoints. - Clean separation of concerns between MCP functionality and web routes.
  1. Real-time data streaming for AI applications.
  2. Integration of external tools and APIs with AI models.
  3. Development of modular web applications using FastAPI.

Add to your AI client

Use these steps to connect FastAPI MCP 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": {
    "fastapi-mcp-sse-panz2018": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-fastapi-mcp-sse-panz2018"
      ]
    }
  }
}

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": {
    "fastapi-mcp-sse-panz2018": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-fastapi-mcp-sse-panz2018"
      ]
    }
  }
}

Claude Code

Add this to your project's .mcp.json file. Claude Code will detect it automatically.

.mcp.json (project root)

{
  "mcpServers": {
    "fastapi-mcp-sse-panz2018": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-fastapi-mcp-sse-panz2018"
      ]
    }
  }
}

VS Code (Copilot)

Add this to your .vscode/mcp.json file. Requires the GitHub Copilot extension with MCP support enabled.

.vscode/mcp.json

{
  "servers": {
    "fastapi-mcp-sse-panz2018": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-fastapi-mcp-sse-panz2018"
      ]
    }
  }
}

Windsurf

Add this to your Windsurf MCP config file, then restart Windsurf.

~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "fastapi-mcp-sse-panz2018": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-fastapi-mcp-sse-panz2018"
      ]
    }
  }
}

Cline

Open Cline settings, navigate to MCP Servers, and add this server configuration.

Cline MCP Settings (via UI)

{
  "mcpServers": {
    "fastapi-mcp-sse-panz2018": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-fastapi-mcp-sse-panz2018"
      ]
    }
  }
}

FAQ

What is the Model Context Protocol (MCP)?

MCP is an open standard that allows AI models to interact with external tools and data sources, addressing context limitations and enabling tool integration.

How can I run the application?

You can run it directly using UV's execution tool or set up a virtual environment and install dependencies.

What endpoints are available?

The application provides standard web routes and MCP SSE endpoints, including `/sse` for SSE functionality.7:["$","div",null,{"className":"container mx-auto flex flex-col gap-4","children":["$L26","$L27",["$","$L28",null,{"currentProject":{"id":2670,"uuid":"3eced6b9-0fe7-4199-b535-26734602f64f","name":"fastapi_mcp_sse","title":"FastAPI MCP SSE","description":"A working example to create a FastAPI server with SSE-based MCP support","avatar_url":"https://avatars.githubusercontent.com/u/49798383?v=4","created_at":"2025-03-13T09:30:53.891Z","updated_at":"2025-03-13T09:39:57.017Z","status":"created","author_name":"panz2018","author_avatar_url":"https://avatars.githubusercontent.com/u/49798383?v=4","tags":"fastapi,sse,mcp","category":"developer-tools","is_featured":false,"sort":1,"url":"https://github.com/panz2018/fastapi_mcp_sse","target":"_self","content":"$29","summary":"$2a","img_url":null,"type":null,"metadata":"{\"star\":\"4\",\"license\":\"MIT license\",\"language\":\"Python\",\"is_official\":false,\"latest_commit_time\":\"2025-03-09 18:10:24\"}","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"}]]}]