mcp-builder by jezweb/claude-skills
npx skills add https://github.com/jezweb/claude-skills --skill mcp-builder根据所需工具的描述构建一个可运行的 MCP 服务器。使用 FastMCP 生成一个可部署的 Python 服务器。
明确服务器需要提供什么:
像“用于查询我们客户数据库的 MCP 服务器”这样的简要描述就足够了。
pip install fastmcp
复制并自定义 assets/basic-server.py:
from fastmcp import FastMCP
# 对于 FastMCP Cloud,必须在模块级别
mcp = FastMCP("My Server")
@mcp.tool()
async def search_customers(query: str) -> str:
"""根据姓名或邮箱搜索客户。"""
# 在此处实现
return f"Found customers matching: {query}"
@mcp.resource("customers://{customer_id}")
async def get_customer(customer_id: str) -> str:
"""根据 ID 获取客户详情。"""
return f"Customer {customer_id} details"
if __name__ == "__main__":
mcp.run()
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
为了在 Claude Code 终端中使用,可以在 MCP 服务器旁边添加脚本:
my-mcp-server/
├── src/index.ts # MCP 服务器(用于 Claude.ai)
├── scripts/
│ ├── search.ts # 搜索工具的 CLI 版本
│ └── _shared.ts # 共享的认证/配置
├── SCRIPTS.md # 记录可用脚本的文档
└── package.json
CLI 脚本提供了 MCP 无法提供的文件 I/O、批处理和更丰富的输出。有关 TypeScript 模板,请参阅 assets/SCRIPTS-TEMPLATE.md 和 assets/script-template.ts。
# 直接运行服务器
python server.py
# 使用 FastMCP 开发模式(自动重载)
fastmcp dev server.py
# HTTP 模式用于远程客户端
python server.py --transport http --port 8000
# 使用 MCP Inspector 测试
fastmcp dev server.py --with-editable .
要进行全面的自动化测试,可以使用 FastMCP Client 生成测试脚本。有关异步测试模式,请参阅 references/testing-pattern.md。
FastMCP Cloud(最简单):
在部署之前,请完成 references/deploy-checklist.md 中的部署前检查清单,以发现常见问题(缺少模块级服务器、硬编码的密钥等)。
fastmcp deploy server.py --name my-server
Docker(自托管):有关 Dockerfile 模式,请参阅 references/cloud-deployment.md。
Cloudflare Workers(边缘):有关基于 Workers 的 MCP 服务器,请参阅 cloudflare-worker-builder 技能。
FastMCP Cloud 要求服务器实例在模块级别:
# 正确
mcp = FastMCP("My Server")
@mcp.tool()
def my_tool(): ...
# 错误 — Cloud 无法找到服务器
def create_server():
mcp = FastMCP("My Server")
return mcp
FastMCP 使用类型注解来生成工具模式:
@mcp.tool()
async def search(
query: str, # 必需参数
limit: int = 10, # 带默认值的可选参数
tags: list[str] = [] # 支持复杂类型
) -> str:
"""文档字符串将成为工具描述。"""
...
将错误作为字符串返回,不要抛出异常:
@mcp.tool()
async def get_data(id: str) -> str:
try:
result = await fetch_data(id)
return json.dumps(result)
except NotFoundError:
return f"Error: No data found for ID {id}"
assets/basic-server.py — 最小的 FastMCP 服务器模板assets/self-contained-server.py — 包含存储和中间件的服务器assets/tools-examples.py — 工具模式和类型注解示例assets/resources-examples.py — 资源 URI 模式示例assets/prompts-examples.py — 提示词模板模式示例assets/client-example.py — MCP 客户端使用示例assets/SCRIPTS-TEMPLATE.md — CLI 配套文档模板assets/script-template.ts — TypeScript CLI 脚本模板references/common-errors.md — 30 多个记录的错误及其修复方法references/cli-commands.md — FastMCP CLI 参考references/cloud-deployment.md — 部署模式(Cloud、Docker、Workers)references/production-patterns.md — 认证、中间件、存储后端references/integration-patterns.md — FastAPI 挂载、OpenAPI 导入references/context-features.md — 生命周期、依赖注入references/testing-pattern.md — FastMCP Client 异步测试模式references/deploy-checklist.md — 部署前验证检查清单每周安装次数
416
代码仓库
GitHub 星标数
643
首次出现
2026年2月18日
安全审计
安装于
opencode376
codex372
github-copilot371
gemini-cli369
cursor364
kimi-cli357
Build a working MCP server from a description of the tools you need. Produces a deployable Python server using FastMCP.
Ask what the server needs to provide:
A brief like "MCP server for querying our customer database" is enough.
pip install fastmcp
Copy and customise assets/basic-server.py:
from fastmcp import FastMCP
# MUST be at module level for FastMCP Cloud
mcp = FastMCP("My Server")
@mcp.tool()
async def search_customers(query: str) -> str:
"""Search customers by name or email."""
# Implementation here
return f"Found customers matching: {query}"
@mcp.resource("customers://{customer_id}")
async def get_customer(customer_id: str) -> str:
"""Get customer details by ID."""
return f"Customer {customer_id} details"
if __name__ == "__main__":
mcp.run()
For Claude Code terminal use, add scripts alongside the MCP server:
my-mcp-server/
├── src/index.ts # MCP server (for Claude.ai)
├── scripts/
│ ├── search.ts # CLI version of search tool
│ └── _shared.ts # Shared auth/config
├── SCRIPTS.md # Documents available scripts
└── package.json
CLI scripts provide file I/O, batch processing, and richer output that MCP can't. See assets/SCRIPTS-TEMPLATE.md and assets/script-template.ts for TypeScript templates.
# Run server directly
python server.py
# With FastMCP dev mode (auto-reload)
fastmcp dev server.py
# HTTP mode for remote clients
python server.py --transport http --port 8000
# Test with MCP Inspector
fastmcp dev server.py --with-editable .
For comprehensive automated testing, generate a test script using the FastMCP Client. See references/testing-pattern.md for the async test pattern.
FastMCP Cloud (simplest):
Before deploying, work through the pre-deploy checklist in references/deploy-checklist.md to catch common issues (missing module-level server, hardcoded secrets, etc.).
fastmcp deploy server.py --name my-server
Docker (self-hosted): See references/cloud-deployment.md for Dockerfile patterns.
Cloudflare Workers (edge): See the cloudflare-worker-builder skill for Workers-based MCP servers.
FastMCP Cloud requires the server instance at module level:
# CORRECT
mcp = FastMCP("My Server")
@mcp.tool()
def my_tool(): ...
# WRONG — Cloud can't find the server
def create_server():
mcp = FastMCP("My Server")
return mcp
FastMCP uses type annotations to generate tool schemas:
@mcp.tool()
async def search(
query: str, # Required parameter
limit: int = 10, # Optional with default
tags: list[str] = [] # Complex types supported
) -> str:
"""Docstring becomes the tool description."""
...
Return errors as strings, don't raise exceptions:
@mcp.tool()
async def get_data(id: str) -> str:
try:
result = await fetch_data(id)
return json.dumps(result)
except NotFoundError:
return f"Error: No data found for ID {id}"
assets/basic-server.py — Minimal FastMCP server templateassets/self-contained-server.py — Server with storage and middlewareassets/tools-examples.py — Tool patterns and type annotationsassets/resources-examples.py — Resource URI patternsassets/prompts-examples.py — Prompt template patternsassets/client-example.py — MCP client usageassets/SCRIPTS-TEMPLATE.md — CLI companion docs templateassets/script-template.ts — TypeScript CLI script templatereferences/common-errors.md — 30+ documented errors with fixesreferences/cli-commands.md — FastMCP CLI referencereferences/cloud-deployment.md — Deployment patterns (Cloud, Docker, Workers)references/production-patterns.md — Auth, middleware, storage backendsreferences/integration-patterns.md — FastAPI mount, OpenAPI importreferences/context-features.md — Lifespan, dependency injectionreferences/testing-pattern.md — FastMCP Client async test patternreferences/deploy-checklist.md — Pre-deploy validation checklistWeekly Installs
416
Repository
GitHub Stars
643
First Seen
Feb 18, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode376
codex372
github-copilot371
gemini-cli369
cursor364
kimi-cli357
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
138,300 周安装