OpenSource-Hub

fastmcp

框架

PrefectHQ/fastmcp

快速构建MCP服务器与客户端的Python框架。

项目简介

FastMCP 是一个 Python 框架,用于简化 MCP(模型上下文协议)服务器和客户端的构建。它自动生成工具模式、验证和文档,专为 LLM 集成设计,支撑了跨语言的大多数 MCP 服务器。

README 预览

\n\n\n\n\n  \n  \n  \n\n\n# FastMCP 🚀\n\nMove fast and make things.\n\n*Made with 💙 by [Prefect](https://www.prefect.io/)*\n\n[](https://gofastmcp.com)\n[](https://discord.gg/uu8dJCgttd)\n[](https://pypi.org/project/fastmcp)\n[](https://github.com/PrefectHQ/fastmcp/actions/workflows/run-tests.yml)\n[](https://github.com/PrefectHQ/fastmcp/blob/main/LICENSE)\n\n\n\n\n---\n\nThe [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) connects LLMs to tools and data. FastMCP gives you everything you need to go from prototype to production:\n\n```python\nfrom fastmcp import FastMCP\n\nmcp = FastMCP("Demo 🚀")\n\n@mcp.tool\ndef add(a: int, b: int) -> int:\n    """Add two numbers"""\n    return a + b\n\nif __name__ == "__main__":\n    mcp.run()\n```\n\n## Why FastMCP\n\nBuilding 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.**\n\n**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.\n\nFastMCP has three pillars:\n\n\n\n\n\n\nServers\n\nExpose tools, resources, and prompts to LLMs.\n\n\n\n\nApps\n\nGive your tools interactive UIs rendered directly in the conversation.\n\n\n\n\nClients\n\nConnect to any MCP server — local or remote, programmatic or CLI.\n\n\n\n\n**[Servers](https://gofastmcp.com/servers/server)** wrap your Python functions into MCP-compliant tools, resources, and prompts. **[Clients](https://gofastmcp.com/clients/client)** connect to any serv