- Home
- MCP servers
- FastAPI
FastAPI
- python
0
GitHub Stars
python
Language
5 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"nabeelshar-fastapi-mcp-server": {
"command": "python",
"args": [
"-m",
"fastapi_mcp_server.server"
]
}
}
}You run a FastAPI MCP Server to inspect and interact with FastAPI applications. It exposes practical tools to load apps, explore routes, view schemas, and analyze dependencies, making it easier to understand, document, and test your FastAPI projects from a centralized MCP client.
How to use
You connect to the MCP server from your MCP client to perform discovery, inspection, and debugging tasks. You can load your FastAPI app, list all routes, view route details, extract the OpenAPI schema, and inspect models. You can also search routes, analyze dependency injection usage, and view the source code of route handlers. These capabilities help you understand the API surface, generate documentation, and diagnose issues.
How to install
Prerequisites you need before installing and running the server:
-
Python 3.10 or higher
-
pip for installing Python packages
How to install
# From your project directory, install the MCP package in editable mode
pip install -e .
How to install
Run the MCP server locally in standalone mode to start serving MCP requests from your FastAPI project.
# Start the MCP server for your FastAPI project
python -m fastapi_mcp_server.server
Claude Desktop configuration (MCP client setup)
{
"mcpServers": {
"fastapi": {
"command": "python",
"args": [
"-m",
"fastapi_mcp_server.server"
],
"cwd": "/path/to/your/fastapi/project"
}
}
}
Standalone usage
To run directly from your FastAPI project directory, execute the following command. This starts the server in the foreground, ready to accept MCP client connections.
python -m fastapi_mcp_server.server
Additional configuration and notes
- The MCP server exposes a set of tools for introspecting FastAPI applications, including loading apps, listing routes, retrieving route details, accessing the OpenAPI schema, listing models, and viewing individual model schemas.
Security and maintenance
- Run the MCP server in a controlled environment and limit access to trusted clients. If you expose it over a network, consider adding authentication or network access controls. Regularly update the MCP package to benefit from new introspection features and fixes.
Troubleshooting
- If the server fails to start, verify that you have Python 3.10+ installed and that the required package is installed in editable mode. Check that the working directory points to your FastAPI project when using Claude Desktop.
Available tools
load_fastapi_app
Load a FastAPI application from a module path so you can query routes, models, and OpenAPI.
list_routes
List all routes with optional filtering by HTTP method or tags to quickly understand the API surface.
get_route_details
Fetch comprehensive details about a specific route, including parameters, dependencies, and responses.
get_openapi_schema
Extract the OpenAPI schema for the loaded application or for selected paths.
list_models
List all Pydantic models used in the app to understand data structures.
get_model_schema
Get a detailed schema for a specific model, including fields and validation rules.
search_routes
Search routes by text query and criteria like authentication or tags.
analyze_dependencies
Analyze dependency injection usage to reveal how dependencies are resolved.
get_route_source
View the source code of route handlers for debugging and understanding implementations.