MCP Configs2026年3月30日·1 分钟阅读

FastMCP — Build MCP Servers in Python, Fast

The fast, Pythonic way to build MCP servers and clients. Clean decorator API, automatic type validation, built-in testing, and OpenAPI integration. 24K+ GitHub stars.

TO
TokRepo精选 · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

pip install fastmcp
from fastmcp import FastMCP

mcp = FastMCP("My Server")

@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

mcp.run()

介绍

FastMCP is the fastest way to build MCP (Model Context Protocol) servers and clients in Python. It provides a clean, decorator-based API that handles all the protocol complexity — type validation, error handling, serialization — so you can focus on building tools. 24,000+ GitHub stars, actively maintained.

Best for: Python developers building MCP servers for AI coding tools Works with: Claude Code, Cursor, Gemini CLI, VS Code, any MCP client


Key Features

Simple Decorator API

Define tools, resources, and prompts with Python decorators — no boilerplate:

@mcp.tool()
def search_files(query: str, max_results: int = 10) -> list[str]:
    """Search files matching query."""
    ...

Automatic Type Validation

Uses Pydantic for automatic request/response validation from type hints.

Built-in Testing

from fastmcp.testing import MCPTestClient
async with MCPTestClient(mcp) as client:
    result = await client.call_tool("add", {"a": 1, "b": 2})
    assert result == 3

MCP Client

Also includes a Python MCP client for connecting to any MCP server.

OpenAPI Integration

Import existing OpenAPI/Swagger specs to auto-generate MCP tools from REST APIs.


FAQ

Q: What is FastMCP? A: FastMCP is a Python framework for building MCP servers and clients with a clean decorator API. It handles protocol complexity, type validation, and serialization automatically. 24K+ stars on GitHub.

Q: How is FastMCP different from the official MCP SDK? A: FastMCP provides a higher-level, more Pythonic API with decorators, automatic type validation, built-in testing, and OpenAPI integration — reducing boilerplate significantly.


🙏

来源与感谢

Created by PrefectHQ. Licensed under Apache 2.0. PrefectHQ/fastmcp — 24,000+ GitHub stars

相关资产