FastAPI MCP Streamable HTTP Starter
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@FastAPI MCP Streamable HTTP Starteruse the echo tool to say hello from MCP"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
FastAPI MCP Streamable HTTP Starter ๐
A minimal, production-ready starter template for building Model Context Protocol (MCP) servers in Python with FastAPI over Streamable HTTP.
Implements the official MCP Specification version 2025-11-25, handling standard JSON-RPC 2.0 requests:
initialize(protocol handshake and capability negotiation)tools/list(dynamic tool discovery)tools/call(tool execution)
โก Quickstart
1. Clone the repository
git clone https://github.com/kshitijkumrawat20/fastapi-mcp-streamable-http-starter.git
cd fastapi-mcp-streamable-http-starter2. Install dependencies
Using uv:
uv pip install -r requirements.txtOr standard pip:
pip install -r requirements.txt3. Run the MCP server
uvicorn main:app --host 127.0.0.1 --port 8000 --reloadRelated MCP server: MCP Server Scaffold
๐งช Testing with cURL
1. Protocol Handshake (initialize)
curl -X POST http://127.0.0.1:8000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-11-25",
"capabilities": {},
"clientInfo": {"name": "curl-client", "version": "1.0.0"}
}
}'2. Discover Tools (tools/list)
curl -X POST http://127.0.0.1:8000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list"
}'3. Execute a Tool (tools/call)
curl -X POST http://127.0.0.1:8000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "echo",
"arguments": {
"message": "Hello from MCP Streamable HTTP!"
}
}
}'๐ Adding Custom Tools
Subclass MCPTool and register it in mcp_server.py:
from mcp_server import MCPTool
class WeatherTool(MCPTool):
@property
def name(self) -> str:
return "get_weather"
@property
def description(self) -> str:
return "Returns current weather for a city."
@property
def input_schema(self) -> dict:
return {
"type": "object",
"properties": {
"city": {"type": "string", "description": "City name"}
},
"required": ["city"]
}
async def execute(self, arguments: dict) -> dict:
city = arguments["city"]
return {"city": city, "temperature": "72ยฐF", "condition": "Sunny"}
# Register in ToolRegistry:
server.registry.register(WeatherTool())๐ License
MIT License. Feel free to use this template for your hackathons and production MCP servers!
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for progressive tool usage at any scale (see https://klavis.ai)
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Python template for building Model Context Protocol (MCP) servers that expose tools via JSON-RPC, enabling secure and scalable context and tool invocation for language models.MIT
- AlicenseBqualityDmaintenanceA basic starter project for building Model Context Protocol (MCP) servers that enables standardized interactions between AI systems and various data sources through secure, controlled tool implementations.2MIT
- AlicenseBqualityDmaintenanceA template repository for building Model Context Protocol (MCP) servers that enable LLM clients to interact with custom tools and services through standardized JSON-RPC communication.3MIT
- AlicenseNot gradedqualityDmaintenanceA bare-bones FastMCP server template designed to serve as a starting point for building custom Model Context Protocol servers. It provides a foundational structure for implementing tools over HTTP and includes a built-in health check utility.GPL 3.0