
🚀 快速、Python式的方式构建MCP服务器和客户端。
概览
模型上下文协议(MCP)将大型语言模型与工具和数据连接起来。FastMCP为您提供从原型到生产所需的一切: 构建一个有效的MCP应用比看起来难。FastMCP能处理所有这些。声明一个带有Python函数的工具,模式、验证和文档会自动生成。连接服务器并输入URL,传输协商、认证和协议生命周期都会被管理。你专注于逻辑,MCP部分就简单地工作: FastMCP 1.0 于 2024 年被整合进官方的 MCP Python SDK 中。如今,这个积极维护的独立项目每天下载量达百万次,FastMCP 的某个版本驱动了所有语言中 70% 的 MCP 服务器。 服务器 向大型语言模型展示工具、资源和提示。应用 为你的工具提供直接在对话中渲染的交互式界面。客户端连接任何MCP服务器——本地或远程,程序化还是CLI。
概述(AI 翻译)
动作快,创造东西。
由学长制作💙
模型上下文协议(MCP)将大型语言模型与工具和数据连接起来。FastMCP 是一个完整的 MCP 应用框架,适用于服务器、客户端和交互应用。服务器起始于普通的 Python:
为什么是FastMCP
构建一个有效的MCP应用比看起来要难得多。FastMCP会处理所有这些。声明一个带有Python函数的工具,模式、验证和文档会自动生成。通过URL连接到服务器,传输协商、认证和协议生命周期都会被自动管理。你专注于逻辑,MCP部分就很正常:FastMCP内置了最佳实践。
这就是为什么FastMCP是使用MCP的标准框架。 FastMCP 1.0于2024年被整合进官方MCP Python SDK中。如今,这个活跃维护的独立项目每天下载量达百万次,FastMCP的某个版本驱动了70%的MCP服务器,涵盖所有语言。
FastMCP有三大支柱:
服务器
向大型语言模型展示工具、资源和提示。
应用
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
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:
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →