Name | fastapi-mcp JSON |
Version |
0.1.8
JSON |
| download |
home_page | None |
Summary | Automatic MCP server generator for FastAPI applications - converts FastAPI endpoints to MCP tools for LLM integration |
upload_time | 2025-04-09 11:08:48 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | MIT License
Copyright (c) 2024 Tadata Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. |
keywords |
ai
api
claude
conversion
fastapi
llm
mcp
modelcontextprotocol
openapi
tools
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<p align="center"><a href="https://github.com/tadata-org/fastapi_mcp"><img src="https://github.com/user-attachments/assets/609d5b8b-37a1-42c4-87e2-f045b60026b1" alt="fastapi-to-mcp" height="100"/></a></p>
<h1 align="center">FastAPI-MCP</h1>
<p align="center">A zero-configuration tool for automatically exposing FastAPI endpoints as Model Context Protocol (MCP) tools.</p>
<div align="center">
[](https://pypi.org/project/fastapi-mcp/)
[](https://pypi.org/project/fastapi-mcp/)
[](#)

[](https://github.com/tadata-org/fastapi_mcp/actions/workflows/ci.yml)
[](https://codecov.io/gh/tadata-org/fastapi_mcp)
</div>
<p align="center"><a href="https://github.com/tadata-org/fastapi_mcp"><img src="https://github.com/user-attachments/assets/1cba1bf2-2fa4-46c7-93ac-1e9bb1a95257" alt="fastapi-mcp-usage" height="400"/></a></p>
## Features
- **Direct integration** - Mount an MCP server directly to your FastAPI app
- **Zero configuration** required - just point it at your FastAPI app and it works
- **Automatic discovery** of all FastAPI endpoints and conversion to MCP tools
- **Preserving schemas** of your request models and response models
- **Preserve documentation** of all your endpoints, just as it is in Swagger
- **Extend** - Add custom MCP tools alongside the auto-generated ones
## Installation
We recommend using [uv](https://docs.astral.sh/uv/), a fast Python package installer:
```bash
uv add fastapi-mcp
```
Alternatively, you can install with pip:
```bash
pip install fastapi-mcp
```
## Basic Usage
The simplest way to use FastAPI-MCP is to add an MCP server directly to your FastAPI application:
```python
from fastapi import FastAPI
from fastapi_mcp import add_mcp_server
# Your FastAPI app
app = FastAPI()
# Mount the MCP server to your app
add_mcp_server(
app, # Your FastAPI app
mount_path="/mcp", # Where to mount the MCP server
name="My API MCP", # Name for the MCP server
)
```
That's it! Your auto-generated MCP server is now available at `https://app.base.url/mcp`.
## Advanced Usage
FastAPI-MCP provides several ways to customize and control how your MCP server is created and configured. Here are some advanced usage patterns:
```python
from fastapi import FastAPI
from fastapi_mcp import add_mcp_server
app = FastAPI()
mcp_server = add_mcp_server(
app, # Your FastAPI app
mount_path="/mcp", # Where to mount the MCP server
name="My API MCP", # Name for the MCP server
describe_all_responses=True, # False by default. Include all possible response schemas in tool descriptions, instead of just the successful response.
describe_full_response_schema=True # False by default. Include full JSON schema in tool descriptions, instead of just an LLM-friendly response example.
)
# Optionally add custom tools in addition to existing APIs.
@mcp_server.tool()
async def get_server_time() -> str:
"""Get the current server time."""
from datetime import datetime
return datetime.now().isoformat()
```
## Examples
See the [examples](examples) directory for complete examples.
## Connecting to the MCP Server using SSE
Once your FastAPI app with MCP integration is running, you can connect to it with any MCP client supporting SSE, such as Cursor:
1. Run your application.
2. In Cursor -> Settings -> MCP, use the URL of your MCP server endpoint (e.g., `http://localhost:8000/mcp`) as sse.
3. Cursor will discover all available tools and resources automatically.
## Connecting to the MCP Server using [mcp-proxy stdio](https://github.com/sparfenyuk/mcp-proxy?tab=readme-ov-file#1-stdio-to-sse)
If your MCP client does not support SSE, for example Claude Desktop:
1. Run your application.
2. Install [mcp-proxy](https://github.com/sparfenyuk/mcp-proxy?tab=readme-ov-file#installing-via-pypi), for example: `uv tool install mcp-proxy`.
3. Add in Claude Desktop MCP config file (`claude_desktop_config.json`):
On Windows:
```json
{
"mcpServers": {
"my-api-mcp-proxy": {
"command": "mcp-proxy",
"args": ["http://127.0.0.1:8000/mcp"]
}
}
}
```
On MacOS:
```json
{
"mcpServers": {
"my-api-mcp-proxy": {
"command": "/Full/Path/To/Your/Executable/mcp-proxy",
"args": ["http://127.0.0.1:8000/mcp"]
}
}
}
```
Find the path to mcp-proxy by running in Terminal: `which mcp-proxy`.
4. Claude Desktop will discover all available tools and resources automatically
## Development and Contributing
**Notice:** We are currently refactoring our MCP auto-generation system. To avoid potential conflicts, we kindly request that you delay submitting contributions until this notice is removed from the README. Thank you for your understanding and patience.
Thank you for considering contributing to FastAPI-MCP open source projects! It's people like you that make it a reality for users in our community.
Before you get started, please see [CONTRIBUTING.md](CONTRIBUTING.md).
## Community
Join [MCParty Slack community](https://join.slack.com/t/themcparty/shared_invite/zt-30yxr1zdi-2FG~XjBA0xIgYSYuKe7~Xg) to connect with other MCP enthusiasts, ask questions, and share your experiences with FastAPI-MCP.
## Requirements
- Python 3.10+
- uv
## License
MIT License. Copyright (c) 2024 Tadata Inc.
## About
Developed and maintained by [Tadata Inc.](https://github.com/tadata-org)
Raw data
{
"_id": null,
"home_page": null,
"name": "fastapi-mcp",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "ai, api, claude, conversion, fastapi, llm, mcp, modelcontextprotocol, openapi, tools",
"author": null,
"author_email": "\"Tadata Inc.\" <itay@tadata.com>",
"download_url": "https://files.pythonhosted.org/packages/4d/c4/b7857d660fe0a07e360eb51e8fc051499d67a2ea7af6e6fc57b8e8d0f574/fastapi_mcp-0.1.8.tar.gz",
"platform": null,
"description": "<p align=\"center\"><a href=\"https://github.com/tadata-org/fastapi_mcp\"><img src=\"https://github.com/user-attachments/assets/609d5b8b-37a1-42c4-87e2-f045b60026b1\" alt=\"fastapi-to-mcp\" height=\"100\"/></a></p>\n<h1 align=\"center\">FastAPI-MCP</h1>\n<p align=\"center\">A zero-configuration tool for automatically exposing FastAPI endpoints as Model Context Protocol (MCP) tools.</p>\n<div align=\"center\">\n\n[](https://pypi.org/project/fastapi-mcp/)\n[](https://pypi.org/project/fastapi-mcp/)\n[](#)\n\n[](https://github.com/tadata-org/fastapi_mcp/actions/workflows/ci.yml)\n[](https://codecov.io/gh/tadata-org/fastapi_mcp)\n\n</div>\n\n<p align=\"center\"><a href=\"https://github.com/tadata-org/fastapi_mcp\"><img src=\"https://github.com/user-attachments/assets/1cba1bf2-2fa4-46c7-93ac-1e9bb1a95257\" alt=\"fastapi-mcp-usage\" height=\"400\"/></a></p>\n\n\n## Features\n\n- **Direct integration** - Mount an MCP server directly to your FastAPI app\n- **Zero configuration** required - just point it at your FastAPI app and it works\n- **Automatic discovery** of all FastAPI endpoints and conversion to MCP tools\n- **Preserving schemas** of your request models and response models\n- **Preserve documentation** of all your endpoints, just as it is in Swagger\n- **Extend** - Add custom MCP tools alongside the auto-generated ones\n\n## Installation\n\nWe recommend using [uv](https://docs.astral.sh/uv/), a fast Python package installer:\n\n```bash\nuv add fastapi-mcp\n```\n\nAlternatively, you can install with pip:\n\n```bash\npip install fastapi-mcp\n```\n\n## Basic Usage\n\nThe simplest way to use FastAPI-MCP is to add an MCP server directly to your FastAPI application:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_mcp import add_mcp_server\n\n# Your FastAPI app\napp = FastAPI()\n\n# Mount the MCP server to your app\nadd_mcp_server(\n app, # Your FastAPI app\n mount_path=\"/mcp\", # Where to mount the MCP server\n name=\"My API MCP\", # Name for the MCP server\n)\n```\n\nThat's it! Your auto-generated MCP server is now available at `https://app.base.url/mcp`.\n\n## Advanced Usage\n\nFastAPI-MCP provides several ways to customize and control how your MCP server is created and configured. Here are some advanced usage patterns:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_mcp import add_mcp_server\n\napp = FastAPI()\n\nmcp_server = add_mcp_server(\n app, # Your FastAPI app\n mount_path=\"/mcp\", # Where to mount the MCP server\n name=\"My API MCP\", # Name for the MCP server\n describe_all_responses=True, # False by default. Include all possible response schemas in tool descriptions, instead of just the successful response.\n describe_full_response_schema=True # False by default. Include full JSON schema in tool descriptions, instead of just an LLM-friendly response example.\n)\n\n# Optionally add custom tools in addition to existing APIs.\n@mcp_server.tool()\nasync def get_server_time() -> str:\n \"\"\"Get the current server time.\"\"\"\n from datetime import datetime\n return datetime.now().isoformat()\n```\n\n## Examples\n\nSee the [examples](examples) directory for complete examples.\n\n## Connecting to the MCP Server using SSE\n\nOnce your FastAPI app with MCP integration is running, you can connect to it with any MCP client supporting SSE, such as Cursor:\n\n1. Run your application.\n\n2. In Cursor -> Settings -> MCP, use the URL of your MCP server endpoint (e.g., `http://localhost:8000/mcp`) as sse.\n\n3. Cursor will discover all available tools and resources automatically.\n\n## Connecting to the MCP Server using [mcp-proxy stdio](https://github.com/sparfenyuk/mcp-proxy?tab=readme-ov-file#1-stdio-to-sse)\n\nIf your MCP client does not support SSE, for example Claude Desktop:\n\n1. Run your application.\n\n2. Install [mcp-proxy](https://github.com/sparfenyuk/mcp-proxy?tab=readme-ov-file#installing-via-pypi), for example: `uv tool install mcp-proxy`.\n\n3. Add in Claude Desktop MCP config file (`claude_desktop_config.json`):\n\nOn Windows:\n```json\n{\n \"mcpServers\": {\n \"my-api-mcp-proxy\": {\n \"command\": \"mcp-proxy\",\n \"args\": [\"http://127.0.0.1:8000/mcp\"]\n }\n }\n}\n```\nOn MacOS:\n```json\n{\n \"mcpServers\": {\n \"my-api-mcp-proxy\": {\n \"command\": \"/Full/Path/To/Your/Executable/mcp-proxy\",\n \"args\": [\"http://127.0.0.1:8000/mcp\"]\n }\n }\n}\n```\nFind the path to mcp-proxy by running in Terminal: `which mcp-proxy`.\n\n4. Claude Desktop will discover all available tools and resources automatically\n\n## Development and Contributing\n\n**Notice:** We are currently refactoring our MCP auto-generation system. To avoid potential conflicts, we kindly request that you delay submitting contributions until this notice is removed from the README. Thank you for your understanding and patience.\n\nThank you for considering contributing to FastAPI-MCP open source projects! It's people like you that make it a reality for users in our community.\n\nBefore you get started, please see [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Community\n\nJoin [MCParty Slack community](https://join.slack.com/t/themcparty/shared_invite/zt-30yxr1zdi-2FG~XjBA0xIgYSYuKe7~Xg) to connect with other MCP enthusiasts, ask questions, and share your experiences with FastAPI-MCP.\n\n## Requirements\n\n- Python 3.10+\n- uv\n\n## License\n\nMIT License. Copyright (c) 2024 Tadata Inc.\n\n## About\n\nDeveloped and maintained by [Tadata Inc.](https://github.com/tadata-org)\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2024 Tadata Inc.\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.",
"summary": "Automatic MCP server generator for FastAPI applications - converts FastAPI endpoints to MCP tools for LLM integration",
"version": "0.1.8",
"project_urls": {
"Bug Tracker": "https://github.com/tadata-org/fastapi_mcp/issues",
"Changelog": "https://github.com/tadata-org/fastapi_mcp/blob/main/CHANGELOG.md",
"Documentation": "https://github.com/tadata-org/fastapi_mcp#readme",
"Homepage": "https://github.com/tadata-org/fastapi_mcp",
"PyPI": "https://pypi.org/project/fastapi-mcp/",
"Source Code": "https://github.com/tadata-org/fastapi_mcp"
},
"split_keywords": [
"ai",
" api",
" claude",
" conversion",
" fastapi",
" llm",
" mcp",
" modelcontextprotocol",
" openapi",
" tools"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "66efc2516a0e1b1b45293d87d1e6659c82e0da6fe5e887436e9a602c02401812",
"md5": "f3bfc76053c7bd299cc5f12ba044f07a",
"sha256": "4638de33390e1667813aad91b2080a63f72656b43d2862038c352131b92d2192"
},
"downloads": -1,
"filename": "fastapi_mcp-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f3bfc76053c7bd299cc5f12ba044f07a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 15445,
"upload_time": "2025-04-09T11:08:47",
"upload_time_iso_8601": "2025-04-09T11:08:47.296591Z",
"url": "https://files.pythonhosted.org/packages/66/ef/c2516a0e1b1b45293d87d1e6659c82e0da6fe5e887436e9a602c02401812/fastapi_mcp-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4dc4b7857d660fe0a07e360eb51e8fc051499d67a2ea7af6e6fc57b8e8d0f574",
"md5": "adb17e14fff9f3675154086e7df1d88f",
"sha256": "46fb043931685409451182b9c64de9ff8ddd4e228320f14afeaa06d32da697da"
},
"downloads": -1,
"filename": "fastapi_mcp-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "adb17e14fff9f3675154086e7df1d88f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 64003,
"upload_time": "2025-04-09T11:08:48",
"upload_time_iso_8601": "2025-04-09T11:08:48.928923Z",
"url": "https://files.pythonhosted.org/packages/4d/c4/b7857d660fe0a07e360eb51e8fc051499d67a2ea7af6e6fc57b8e8d0f574/fastapi_mcp-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-04-09 11:08:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tadata-org",
"github_project": "fastapi_mcp",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "fastapi-mcp"
}