finianoneill/mcp_fastapi_server_example
3.2
If you are the rightful owner of mcp_fastapi_server_example and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A production-ready Model Context Protocol (MCP) server built with FastAPI.
Tools
3
Resources
0
Prompts
0
MCP FastAPI Server
A production-ready Model Context Protocol (MCP) server built with FastAPI.
Directory Structure
.
├── main.py # Entry point
├── requirements.txt # Dependencies
├── README.md # Documentation
└── src/
├── __init__.py
├── app.py # FastAPI application
└── mcp_app/
├── __init__.py
├── models.py # Pydantic models
├── server.py # MCP server logic
└── tools.py # Tool registry & implementations
Installation
pip install -r requirements.txt
Usage
python main.py
Server runs on http://localhost:8000
Endpoints
GET /- Server informationGET /health- Health checkGET /tools- List available toolsWS /mcp- MCP WebSocket endpointPOST /mcp/http- MCP HTTP endpoint
Built-in Tools
- calculate - Mathematical calculations
- get_time - Current time in timezone
- echo - Echo messages
API Documentation
Visit http://localhost:8000/docs for interactive API documentation.