从 FastMCP 2/3 或 MCP SDK 升级需按官方升级指南迁移;完整安装与验证步骤需参考官网安装指南
用普通 Python 函数快速构建 MCP 服务器和客户端,自动处理协议细节
用 Python 快速搭建 MCP 服务器和客户端的框架,让大模型和 Agent 能方便地接入外部工具与数据源。
核心能力
- 用 @mcp.tool 装饰器把 Python 函数变成 MCP 工具
- 自动生成工具 schema、参数校验和文档
- 客户端用 URL 连接任意本地或远程 MCP 服务器
- 支持在对话中直接渲染交互式 UI 的 Apps
- 提供 TypeScript 版本,npm 安装 @prefecthq/fastmcp-ts
容易踩的坑
- 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 strictSkillsDirectoryProviderinfastmcp.skills.provider. Directory loading validates each skill before publication, and skills with structured metadata or YAMLallowed-toolslists 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, useSkill.from_directory(...)withSkillCatalogProviderfromfastmcp.skills.provider.Client.list_skill_resources()remains available for servers without the Skills extension. The oldexperimental_skills=Truepath redirects to the new provider for the base class and rejects subclasses to preserve access controls. LegacySkillwire-model construction still works with a warning, wire entries retainisinstance(entry, Skill)behavior, and existing PydanticSkillfields still validate wire payloads. UseMCPSkillfor wire entries, annotations, and checks, andSkillfor authoring. For manifest metadata on resource-only servers, readskill://<name>/_manifestwithclient.read_resource()and parse its JSON;client.get_skill()requires the Skills extension, whileclient.read_skill()downloads and validates the whole skill.Since a2,
ClientGroupretains known tool routes after its context exits, OpenAPI tool inputs omitreadOnlyproperties, 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 ⚠️
- Make Skill a storage-neutral object with folders as one loader by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6065
Enhancements ✨
- Rename the resource-era list_skills helper to list_skill_summaries by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6051
- Discover skills through mounted servers by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6067
- Share Prefab renderer resources across equivalent tools by @jlowin, @fprieto14, and @keremoktener in https://github.com/PrefectHQ/fastmcp/pull/6077
- Export Skill from fastmcp by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6071
- Add skills discovery to ClientGroup by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6072
- Add --skills to fastmcp list by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6073
- Add Client.read_skill and tighten skills docs by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6087
- Verify and export skills with resource-manifest fallback by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6086
- Forward Skills discovery through proxies by @jakekaplan in https://github.com/PrefectHQ/fastmcp/pull/5788
- Share strict skill snapshot projection by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6089
- Use scoped local tests and leave full suites to CI by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6094
- Share ClientGroup skill client lookup by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6101
- Share filesystem skill supporting-file reads by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6102
- Deliver concurrent triage reviews, draft fixes and mutation proposals by @zzstoatzz in https://github.com/P
- v4.1.6v4.1.6: Group Therapy最新正式版2026-11-03 · 2026-11-03 02:52 UTC
ClientGroupkeeps 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 🐞
- fix(client): keep ClientGroup tool routes after the group context exits by @zzstoatzz, @hntrl and @YingzuoLiu in https://github.com/PrefectHQ/fastmcp/pull/6271
Full Changelog: https://github.com/PrefectHQ/fastmcp/compare/v4.1.5...v4.1.6
- 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
constandenumcompare by JSON equality, sotrueno longer passes for1;prompts/getwith 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 ⚠️
- Make Skill a storage-neutral object with folders as one loader by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6065
Enhancements ✨
- Rename the resource-era list_skills helper to list_skill_summaries by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6051
- Discover skills through mounted servers by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6067
- Share Prefab renderer resources across equivalent tools by @jlowin, @fprieto14, and @keremoktener in https://github.com/PrefectHQ/fastmcp/pull/6077
- Export Skill from fastmcp by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6071
- Add skills discovery to ClientGroup by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6072
- Add --skills to fastmcp list by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6073
- Add Client.read_skill and tighten skills docs by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6087
- Verify and export skills with resource-manifest fallback by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6086
- Forward Skills discovery through proxies by @jakekaplan in https://github.com/PrefectHQ/fastmcp/pull/5788
- Share strict skill snapshot projection by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6089
- Use scoped local tests and leave full suites to CI by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6094
- Share ClientGroup skill client lookup by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6101
- Share filesystem skill supporting-file reads by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6102
- Deliver concurrent triage reviews, draft fixes and mutation proposals by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6116
- Post Marvin's dedupe and too-long comments from workflow steps by @gaker in https://github.com/PrefectHQ/fastmcp/pull/6170
- Remove the unused triage mutation batch by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6208
- Restore the status site by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6216
- Add agno, Agent Framework, and OpenAI Agents SDK to downstream smoke by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6222
Security 🔒
- Verify advertised skill frontmatter when reading content by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6090
- Check skill limits before reading directory and remote files by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6092
- fix: preserve _list_query_params in FastMCPProviderResourceTemplate.wrap by @RS-ITACHI in https://github.com/PrefectHQ/fastmcp/pull/6130
- Read composite action inputs from env and pin actions by digest by @gaker in https://github.com/PrefectHQ/fastmcp/pull/6168
- Scope the /marvin App token to th
- 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.1line: mounted resource templates keep their list-style query parameters,FastMCPStdioTransportforwards 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 Schemaconst/enumcompare by JSON equality, sotrueno longer passes for1. Thanks to our 12 contributors, including 7 first-time contributors.What's Changed
Security 🔒
- fix: preserve _list_query_params in FastMCPProviderResourceTemplate.wrap by @RS-ITACHI in https://github.com/PrefectHQ/fastmcp/pull/6130
Fixes 🐞
- fix: forward script arguments in FastMCPStdioTransport by @KashifManzer and @BlueX888 in https://github.com/PrefectHQ/fastmcp/pull/6119
- Improve OpenAPI upstream error details by @zzstoatzz and @mssaleh in https://github.com/PrefectHQ/fastmcp/pull/6141
- Compare JSON const and enum values by JSON equality by @prassu017 and @alpaylan in https://github.com/PrefectHQ/fastmcp/pull/6126
- Return invalid params for prompts/get with a missing required argument by @asasemahmed and @xubenqiang in https://github.com/PrefectHQ/fastmcp/pull/6027
- fix(cli): prefer Claude Code project servers by @mikamikasuki in https://github.com/PrefectHQ/fastmcp/pull/5522
- fix(cli): preserve JSON content block fields by @mikamikasuki in https://github.com/PrefectHQ/fastmcp/pull/5530
- Keep schema definitions when hydrating a wrapped tool result by @asasemahmed in https://github.com/PrefectHQ/fastmcp/pull/5927
- Reject undeclared OpenAPI tool arguments under strict input validation by @prassu017 and @mssaleh in https://github.com/PrefectHQ/fastmcp/pull/6140
- fix(resources): reverse hostless URIs through Namespace unchanged by @serhiizghama and @andreivince in https://github.com/PrefectHQ/fastmcp/pull/5230
- fix(openapi): preserve timeouts so the server maps them to the actionable message by @BlueX888 in https://github.com/PrefectHQ/fastmcp/pull/5847
- Drop client context holds left by finished tasks by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6205
- Backport 12 fixes to release/4.1 for v4.1.5 by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6218
New Contributors
- @RS-ITACHI made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/6130
- @KashifManzer made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/6119
- @mssaleh made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/6141
- @prassu017 made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/6126
- @alpaylan made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/6126
- @serhiizghama made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/5230
- @xubenqiang made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/6027
Full Changelog: https://github.com/PrefectHQ/fastmcp/compare/v4.1.4...v4.1.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
Skillin Python or load one from a folder or package, publish it throughSkillCatalogProvider, and let clients discover its metadata or download and export its files. Proxy discovery is opt-in withskills=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:
Skillnow represents file contents; the wire metadata model is namedMCPSkill. Whole-skill downloads require a standardSKILL.mdwith anamematching its URI and adescription. Exports withoverwrite=Truereplace 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 ⚠️
- Make Skill a storage-neutral object with folders as one loader by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6065
Enhancements ✨
- Rename the resource-era list_skills helper to list_skill_summaries by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6051
- Discover skills through mounted servers by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6067
- Share Prefab renderer resources across equivalent tools by @jlowin, @fprieto14, and @keremoktener in https://github.com/PrefectHQ/fastmcp/pull/6077
- Export Skill from fastmcp by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6071
- Add skills discovery to ClientGroup by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6072
- Add --skills to fastmcp list by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6073
- Add Client.read_skill and tighten skills docs by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6087
- Verify and export skills with resource-manifest fallback by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6086
- Forward Skills discovery through proxies by @jakekaplan in https://github.com/PrefectHQ/fastmcp/pull/5788
- Share strict skill snapshot projection by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6089
- Use scoped local tests and leave full suites to CI by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6094
- Share ClientGroup skill client lookup by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6101
- Share filesystem skill supporting-file reads by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6102
Security 🔒
- Verify advertised skill frontmatter when reading content by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6090
- Check skill limits before reading directory and remote files by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6092
Fixes 🐞
- Make the version-check InvalidURL regression independent of proxy parsing by @HootRock in https://github.com/PrefectHQ/fastmcp/pull/6048
- Build the Prefab renderer page on read, not on resources/list by @adam-zovos in https://github.com/PrefectHQ/fastmcp/pull/6039
- Install mounted skills under their own name in sync_skills by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6078
- Stage skill exports before replacing installed files by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6091
- fix: Prefix backend hash addresses with double underscores by @jlowin and @BlueX888 in https://github.com/PrefectHQ/fastmcp/pull/6100
Docs 📚
- Add v4.2.0a1 changelog entries by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6105
- Consolidate skills docs into one Skills over MCP page by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6049
- Rewrite skills docs around Skill and SkillCatalogProvider by @zzstoatzz in https://github.com/PrefectHQ/fastmcp/pull/6066
- Tighten
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
FastMCP 🚀
Move fast and make things.
Made with 💙 by Prefect
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:
- Upgrading from FastMCP 3
- Upgrading from FastMCP 2
- Upgrading from MCP SDK v1 or v2
- Upgrading from the low-level SDK v1 or v2
📚 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.txtis essentially a sitemap, listing all the pages in the documentation.llms-full.txtcontains 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.