https://github.com/kimijl/fastapi-mcp
Example web app mounting a model context protocol (MCP) server on a FastAPI server
https://github.com/kimijl/fastapi-mcp
fastapi mcp mcp-server python
Last synced: about 2 months ago
JSON representation
Example web app mounting a model context protocol (MCP) server on a FastAPI server
- Host: GitHub
- URL: https://github.com/kimijl/fastapi-mcp
- Owner: KimiJL
- License: mit
- Created: 2025-05-06T21:45:04.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-06T21:54:23.000Z (about 1 year ago)
- Last Synced: 2025-05-08T02:52:24.905Z (about 1 year ago)
- Topics: fastapi, mcp, mcp-server, python
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Description
Simple example web app + client showing Model Context Protocol server mounted on an existing fastapi server
[Model Context Protocol](https://github.com/modelcontextprotocol/python-sdk)
[FastAPI Mounting](https://fastapi.tiangolo.com/advanced/sub-applications/)
Files
./src/main.py -> main fastapi server app
./src/mcp.py -> mcp sub server app logic
./client/client.py -> sample client showing some communication logic using mcp client lib
# Set up
## Using Docker to start server
```bash
docker build -t fastapi-mcp .
docker run -p 8000:8000 --net=host fastapi-mcp
```
## Set up python environment & run client
```
pip install -r requirements.txt
python client/client.py
# to run server as well without docker
uvicorn src.main:app
```
# Known Issues
## MCP server can only be mounted on root '/'
[GitHub Issue](https://github.com/modelcontextprotocol/python-sdk/issues/585)
Limitations on MCP python sdk that currently only allows for MCP server to work when mounted on root /