fastmcp

PrefectHQApache-2.0活跃维护

用 Python 快速搭建 MCP 服务器和客户端的框架,让大模型和 Agent 能方便地接入外部工具与数据源。

🚀 The fast, Pythonic way to build MCP servers and clients.

v4.1.6发布于 2026-11-03 02:52 UTC28,371star +32 / 7 天2,577fork同步于 2026-11-10 17:22 UTC

怎么上手

由 README 提炼,执行前请确认
uv add fastmcp
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用普通 Python 函数快速构建 MCP 服务器和客户端,自动处理协议细节

用 Python 快速搭建 MCP 服务器和客户端的框架,让大模型和 Agent 能方便地接入外部工具与数据源。

核心能力

  • 用 @mcp.tool 装饰器把 Python 函数变成 MCP 工具
  • 自动生成工具 schema、参数校验和文档
  • 客户端用 URL 连接任意本地或远程 MCP 服务器
  • 支持在对话中直接渲染交互式 UI 的 Apps
  • 提供 TypeScript 版本,npm 安装 @prefecthq/fastmcp-ts

容易踩的坑

从 FastMCP 2/3 或 MCP SDK 升级需按官方升级指南迁移;完整安装与验证步骤需参考官网安装指南

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v4.1.6
  1. v4.2.0a3v4.2.0a3: A Particular Set of Skillspre-release2026-11-03 · 2026-11-03 23:39 UTC
    查看更新说明

    FastMCP 4.2.0a3 consolidates skills around Skill, SkillCatalogProvider, and the new strict SkillsDirectoryProvider in fastmcp.skills.provider. Directory loading validates each skill before publication, and skills with structured metadata or YAML allowed-tools lists are accepted without changing their values. This alpha also fixes stale proxy discovery caches, preserves OpenAPI schema references and explicit null values, and improves client connection recovery. Skills support remains experimental; this prerelease is intended for integration testing.

    If you import the 4.1 skills providers directly, they keep their behavior in 4.2 and now warn ahead of removal in 4.3. Move directory loading to from fastmcp.skills.provider import SkillsDirectoryProvider; its startup errors and the legacy providers' warnings identify folders that need fixing. For a single skill, use Skill.from_directory(...) with SkillCatalogProvider from fastmcp.skills.provider. Client.list_skill_resources() remains available for servers without the Skills extension. The old experimental_skills=True path redirects to the new provider for the base class and rejects subclasses to preserve access controls. Legacy Skill wire-model construction still works with a warning, wire entries retain isinstance(entry, Skill) behavior, and existing Pydantic Skill fields still validate wire payloads. Use MCPSkill for wire entries, annotations, and checks, and Skill for authoring. For manifest metadata on resource-only servers, read skill://<name>/_manifest with client.read_resource() and parse its JSON; client.get_skill() requires the Skills extension, while client.read_skill() downloads and validates the whole skill.

    Since a2, ClientGroup retains known tool routes after its context exits, OpenAPI tool inputs omit readOnly properties, and header and path parameters follow their declared simple serialization style. OAuth consent bindings survive concurrent approvals, exception middleware matches subclasses, and empty logging method filters mean “log nothing.”

    Thanks to our 46 contributors, including 29 first-time contributors.

    What's Changed

    Breaking Changes ⚠️

    Enhancements ✨

  2. v4.1.6v4.1.6: Group Therapy最新正式版2026-11-03 · 2026-11-03 02:52 UTC

    ClientGroup keeps its known tool routes after the group context exits, so a resolved tool can be called with only its own client connected (#6271). Thanks to @hntrl and @YingzuoLiu.

    What's Changed

    Fixes 🐞

    Full Changelog: https://github.com/PrefectHQ/fastmcp/compare/v4.1.5...v4.1.6

  3. v4.2.0a2v4.2.0a2: Skill Waters Run Deeppre-release2026-11-01 · 2026-11-01 22:58 UTC
    查看更新说明

    The second 4.2 alpha carries every fix from 4.1.5 plus the ones that only land on 4.2: Skills discovery through proxies pages its backends with a bound, pre-4.2 Prefab backend addresses rebind through 4.2 proxies, large tool catalogs expand their schemas faster, and kept-alive stdio transports respect each client's timeout. Before tagging, this build ran against pydantic-ai, langchain, agno, Microsoft Agent Framework, and the OpenAI Agents SDK. Skills support remains experimental; this prerelease is intended for integration testing.

    Behavior changes since a1: JSON Schema const and enum compare by JSON equality, so true no longer passes for 1; prompts/get with a missing argument returns invalid params (-32602); OpenAPI upstream errors are cut to 1 KB with HTML bodies dropped, and strict input validation rejects undeclared OpenAPI arguments; a later client with a different timeout restarts an idle kept-alive stdio subprocess, while one nested inside a live client shares its session's timeout and logs a warning.

    Thanks to our 22 contributors, including 13 first-time contributors.

    What's Changed

    Breaking Changes ⚠️

    Enhancements ✨

    Security 🔒

  4. v4.1.5v4.1.5: Back to the Fourture2026-11-01 · 2026-11-01 20:52 UTC
    查看更新说明

    Twelve fixes backported from main onto the new release/4.1 line: mounted resource templates keep their list-style query parameters, FastMCPStdioTransport forwards script arguments, OpenAPI tools report timeouts and concise upstream errors (and reject undeclared arguments under strict validation), a missing prompt argument returns invalid params, and JSON Schema const/enum compare by JSON equality, so true no longer passes for 1. Thanks to our 12 contributors, including 7 first-time contributors.

    What's Changed

    Security 🔒

    Fixes 🐞

    New Contributors

    Full Changelog: https://github.com/PrefectHQ/fastmcp/compare/v4.1.4...v4.1.5

  5. v4.2.0a1v4.2.0a1: Skill Issuepre-release2026-10-27 · 2026-10-27 18:47 UTC
    查看更新说明

    FastMCP 4.2's first alpha brings code-defined skills, discovery through mounted and proxied servers, and verified downloads into one workflow. Build a Skill in Python or load one from a folder or package, publish it through SkillCatalogProvider, and let clients discover its metadata or download and export its files. Proxy discovery is opt-in with skills=True. Skills support remains experimental; this prerelease is intended for integration testing. It also includes lazy, shared Prefab renderer resources and backend-addressing fixes.

    Migration: Skill now represents file contents; the wire metadata model is named MCPSkill. Whole-skill downloads require a standard SKILL.md with a name matching its URI and a description. Exports with overwrite=True replace the installed folder, including locally added files. Ordinary resource providers still support their existing document formats.

    Thanks to our 8 contributors, including 3 first-time contributors.

    What's Changed

    Breaking Changes ⚠️

    Enhancements ✨

    Security 🔒

    Fixes 🐞

    Docs 📚

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    FastMCP 🚀

    Move fast and make things.

    Made with 💙 by Prefect

    Docs Discord PyPI - Version TypeScript Tests License


    The Model Context Protocol (MCP) connects LLMs to tools and data. FastMCP is a full MCP application framework for servers, clients, and interactive apps. A server starts with ordinary Python:

    from fastmcp import FastMCP
    
    mcp = FastMCP("Demo 🚀")
    
    @mcp.tool
    def add(a: int, b: int) -> int:
        """Add two numbers"""
        return a + b
    
    if __name__ == "__main__":
        mcp.run()
    

    Why FastMCP

    Building an effective MCP application is harder than it looks. FastMCP handles all of it. Declare a tool with a Python function, and the schema, validation, and documentation are generated automatically. Connect to a server with a URL, and transport negotiation, authentication, and protocol lifecycle are managed for you. You focus on your logic, and the MCP part just works: with FastMCP, best practices are built in.

    That's why FastMCP is the standard framework for working with MCP. FastMCP 1.0 was incorporated into the official MCP Python SDK in 2024. Today, the actively maintained standalone project is downloaded a million times a day, and some version of FastMCP powers 70% of MCP servers across all languages.

    FastMCP has three pillars:

    Servers wrap your Python functions into MCP-compliant tools, resources, and prompts. Clients connect to any server with full protocol support. And Apps give your tools interactive UIs rendered directly in the conversation.

    Building in TypeScript? FastMCP for TypeScript is the official counterpart, built and maintained by the same team. Same pillars, same ideas, npm install @prefecthq/fastmcp-ts.

    Ready to build? Start with the installation guide or jump straight to the quickstart.

    Scale MCP with FastMCP Gateway

    FastMCP handles the MCP application layer. FastMCP Gateway is the enterprise MCP gateway for scaling servers and tools across teams, with centralized governance over how they are deployed, discovered, secured, and used.

    FastMCP and FastMCP Gateway are built by the same team at Prefect.

    Deploy FastMCP servers from GitHub with branch previews and instant rollback. Create a private registry of every MCP your company uses. Secure access with SSO and tool-level RBAC. Get audit logs, observability, and governance across your MCP stack. Remix approved tools into purpose-built endpoints for teams and agents.

    Start with FastMCP. Scale with FastMCP Gateway →

    Installation

    We recommend adding FastMCP to your project with uv:

    uv add fastmcp
    

    For full installation instructions, including verification and upgrading, see the Installation Guide.

    Upgrading? We have guides for:

    📚 Documentation

    FastMCP's complete documentation is available at gofastmcp.com, including detailed guides, API references, and advanced patterns.

    Documentation is also available in llms.txt format, which is a simple markdown standard that LLMs can consume easily:

    • llms.txt is essentially a sitemap, listing all the pages in the documentation.
    • llms-full.txt contains the entire documentation. Note this may exceed the context window of your LLM.

    Give your coding agent llms.txt as its starting point. See Coding Agents for version-matched documentation and the optional server authoring skill.

    Community: Join our Discord server to connect with other FastMCP developers and share what you're building.

    Contributing

    Start with CONTRIBUTING.md for accepted contributions and the issue-assignment workflow, then follow the Contributing Guide for setup and validation. Agents should read AGENTS.md.