Skip to main content
Glama

FastAPI-MCP

by tadata-org

特征

  • 内置身份验证,使用您现有的 FastAPI 依赖项!
  • **FastAPI-native:**不仅仅是另一个 OpenAPI -> MCP 转换器
  • 无需/只需极少配置- 只需将其指向您的 FastAPI 应用程序即可运行
  • 保留请求模型和响应模型的模式
  • 保存所有端点的文档,就像在 Swagger 中一样
  • 灵活部署- 将您的 MCP 服务器安装到同一应用程序,或单独部署
  • ASGI 传输- 直接使用 FastAPI 的 ASGI 接口进行高效通信

安装

我们建议使用uv ,一个快速的 Python 包安装程序:

uv add fastapi-mcp

或者,您可以使用 pip 安装:

pip install fastapi-mcp

基本用法

使用 FastAPI-MCP 最简单的方法是将 MCP 服务器直接添加到你的 FastAPI 应用程序中:

from fastapi import FastAPI from fastapi_mcp import FastApiMCP app = FastAPI() mcp = FastApiMCP(app) # Mount the MCP server directly to your FastAPI app mcp.mount()

就这样!您自动生成的 MCP 服务器现在可以在https://app.base.url/mcp上使用。

文档、示例和高级用法

FastAPI-MCP 提供了详尽的文档。此外,您还可以查看示例目录,获取演示这些功能的代码示例。

FastAPI 优先方法

FastAPI-MCP 被设计为 FastAPI 的原生扩展,而不仅仅是一个从 API 生成 MCP 工具的转换器。这种方法有几个关键优势:

  • 本机依赖项:使用熟悉的 FastAPI Depends()进行身份验证和授权,保护您的 MCP 端点
  • ASGI 传输:使用其 ASGI 接口直接与您的 FastAPI 应用通信,无需从 MCP 向您的 API 进行 HTTP 调用
  • 统一的基础架构:您的 FastAPI 应用无需与 MCP 服务器单独运行(尽管也支持单独部署

这种设计理念可确保在向现有 FastAPI 服务添加 MCP 功能时产生最小的摩擦。

开发与贡献

感谢您考虑为 FastAPI-MCP 做出贡献!我们鼓励社区发布问题 (Issues) 并创建拉取请求 (Pull Request)。

在开始之前,请参阅我们的贡献指南

社区

加入MCParty Slack 社区与其他 MCP 爱好者联系、提出问题并分享您使用 FastAPI-MCP 的经验。

要求

  • Python 3.10+(推荐3.12)
  • 紫外线

执照

MIT 许可证。版权所有 (c) 2024 Tadata Inc.

-
security - not tested
A
license - permissive license
-
quality - not tested

一种零配置工具,可自动将 FastAPI 端点公开为模型上下文协议 (MCP) 工具,从而允许 Claude 等 LLM 系统无需额外编码即可与您的 API 交互。

  1. 安装
    1. 基本用法
      1. 文档、示例和高级用法
        1. FastAPI 优先方法
          1. 开发与贡献
            1. 社区
              1. 要求
                1. 执照

                  Related MCP Servers

                  • -
                    security
                    F
                    license
                    -
                    quality
                    A MCP server that exposes OpenAPI schema information to LLMs like Claude. This server allows an LLM to explore and understand large OpenAPI schemas through a set of specialized tools, without needing to load the whole schema into the context
                    Last updated -
                    37
                    5
                    JavaScript
                    • Apple
                    • Linux
                  • -
                    security
                    F
                    license
                    -
                    quality
                    A simple application demonstrating Model Context Protocol (MCP) integration with FastAPI and Streamlit, allowing users to interact with LLMs through a clean interface.
                    Last updated -
                    3
                    Python
                    • Linux
                  • A
                    security
                    A
                    license
                    A
                    quality
                    A Model Context Protocol server that loads multiple OpenAPI specifications and exposes them to LLM-powered IDE integrations, enabling AI to understand and work with your APIs directly in development tools like Cursor.
                    Last updated -
                    7
                    292
                    7
                    TypeScript
                    MIT License
                  • -
                    security
                    A
                    license
                    -
                    quality
                    A zero-configuration tool that automatically converts FastAPI endpoints into Model Context Protocol (MCP) tools, enabling AI systems to interact with your API through natural language.
                    Last updated -
                    1
                    Python
                    MIT License

                  View all related MCP servers

                  MCP directory API

                  We provide all the information about MCP servers via our MCP API.

                  curl -X GET 'https://glama.ai/api/mcp/v1/servers/tadata-org/fastapi_mcp'

                  If you have feedback or need assistance with the MCP directory API, please join our Discord server