fastmcp-server
Skill này làm gì
Skill này hướng dẫn viết máy chủ MCP bằng Python với thư viện FastMCP. Nó dành cho lập trình viên muốn các công cụ AI của mình cung cấp tool, tài nguyên hoặc prompt theo một cách chuẩn.
Khi nào nên dùng
- ✓Khi bạn muốn xây dựng một máy chủ MCP mới bằng Python với FastMCP.
- ✓Khi bạn cần thêm tool, tài nguyên hoặc prompt vào một máy chủ FastMCP hiện có.
- ✓Khi bạn muốn xem lại schema và định nghĩa của máy chủ FastMCP xem có vấn đề không.
Liên kết skill
https://github.com/PrefectHQ/fastmcp/blob/main/docs/.mintlify/skills/fastmcp-server/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Giúp tôi xây dựng một máy chủ MCP nhỏ bằng Python, cung cấp một công cụ để tra cứu trạng thái đơn hàng.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent kiểm tra phiên bản FastMCP đã cài trong dự án, đọc tài liệu tương ứng và viết mã máy chủ mà schema của công cụ được lấy từ type hint và mô tả Python.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Authoring MCP servers with FastMCP
Find the current API
Check the project's installed FastMCP version and dependency constraints.
Fetch the documentation index and read the
relevant pages for that version. The index includes versioned documentation;
select /v3/ pages for FastMCP 3 and unversioned pages for FastMCP 4. Read
individual pages through their .md URLs instead of loading llms-full.txt.
For APIs newer than the installed release, check that release's source or
signatures. Preserve the project's dependency constraints unless an upgrade is
part of the request. For a new project, check the current stable release before
choosing a dependency.
Use the standalone fastmcp package. Its API differs from
mcp.server.fastmcp in the Python MCP SDK.
Author the server
Choose the MCP interface to suit what the server exposes: tools for callable
operations, resources for addressable content, and prompts for reusable message
templates. FastMCP derives tool schemas from Python annotations and descriptions;
use Literal or enums for finite choices and Field descriptions for parameter
semantics. SDK wrappers need to preserve signatures and docstrings, for example
with functools.wraps, or discovery loses that information. Inspect the schema
the client receives, especially after transforms or custom discovery rendering:
requiredness, enum values, and nested fields can disappear from a summary.
Let the intended client tasks guide tool boundaries, descriptions, and result shape. Give clients enough context to use results and recover from errors. The right granularity depends on the service; generated API tools, custom tools, and compositions can all be appropriate.
For paginated or bounded results, expose whether the answer is complete and how
to continue. An upstream failure is not an empty result. Return useful recovery
information through tool errors rather than a successful-looking payload. Use
ToolError, ResourceError, or PromptError from fastmcp.exceptions for
intentional client-facing messages. With mask_error_details=True, ordinary
exceptions such as ValueError lose their messages; do not put sensitive backend
details in the explicit error types, whose messages remain visible.
When using tool search or code mode, make exact named operations discoverable and explain the execution contract: what persists between calls and what becomes the result. A short fetch/filter/return example can prevent repeated empty outputs. Check the installed implementation before describing that behavior.
Look up FastMCP's relevant facilities as needed: context and dependencies, lifespan, authentication, composition, and transports. Use the project's runtime and hosting choices to determine configuration.
When clients need a repeatable workflow across the server's capabilities,
consider shipping a skill alongside those capabilities. Put task selection,
operation sequencing, and recovery guidance in the skill; keep tool descriptions
focused on their individual contracts. Read the version-matched Skills Provider
and Experimental Skills Extension docs from the index before implementing it.
SkillsDirectoryProvider exposes skill files as resources; the experimental
extension adds skills/list and skills/get discovery. Check the installed
release and target host's support before selecting either interface. Discovery
does not activate a skill: verify that the host reads and uses it in the intended
workflow. The experimental extension currently requires directly registered
providers and does not support mounted or transformed skill sources.
Verify the server through FastMCP's Client, which can connect directly to a
server instance for in-process testing. Check a representative operation, its
client-visible schema and result, and a meaningful failure. For composed or
transformed servers, verify the public names and URIs through the outer server,
including resource references returned by prompts. Namespace transforms change
component names and resource URIs, but do not rewrite URI text inside prompt
messages. When a prompt must work both standalone and mounted, direct the client
to discover the resource template instead of hardcoding the child's URI.
Exercise the chosen transport when connection or deployment behavior is part
of the change.
Evaluate agent workflows
When the task includes evaluating how agents use the server, test a representative workflow using the proj
Câu hỏi thường gặp
Nó dùng gói nào?
Nó dùng gói Python fastmcp độc lập, có API khác với lớp bao (wrapper) của chính SDK MCP.
Agent chọn đúng phiên bản API bằng cách nào?
Nó kiểm tra phiên bản đã cài trong dự án và đọc tài liệu cho phiên bản đó.
Schema của công cụ được tạo ra thế nào?
FastMCP tạo chúng từ annotation và mô tả Python, nên type hint rõ ràng và docstring rất quan trọng.
Chi tiết
Mô tả gốc của tác giả
Build, extend, or review MCP servers with Python FastMCP, using documentation matched to the project's version.
repo: PrefectHQ/fastmcp
Độ phổ biến
- Sao GitHub
- 28k
- Vị trí xếp hạng
- #9867
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
Skill tương tự
mcporter
394kGiúp agent của bạn liệt kê, gọi và kiểm tra các máy chủ MCP cùng công cụ của chúng qua HTTP hoặc stdio, và quản lý cài đặt đăng nhập.
fastmcp
260kGiúp bạn xây dựng, kiểm thử và triển khai một máy chủ MCP bằng Python, cấp cho trợ lý AI quyền truy cập API, cơ sở dữ liệu hoặc file của bạn dưới dạng công cụ.
mcp-oauth-remote-gateway
260kHướng dẫn bạn đăng nhập OAuth cho máy chủ MCP từ xa khi Hermes chạy trên máy chủ, nơi đăng nhập bằng trình duyệt thông thường không thể truy cập được.