Skip to content
Back to skills

Mcp Builder

ASecurity

指导开发优质 MCP(Model Context Protocol)服务器,通过设计得当的工具让 LLM 与外部服务交互。需要在 Python(FastMCP)或 Node.js/TypeScript(MCP SDK)中接入外部 API 或服务时使用。

  • 626 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added February 10, 2026
ai-agentstypescriptpythonnodegitapi

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Pro scans all 10 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add LeastBit/Claude_skills_zh-CN --skill mcp-builder --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mcp Builder?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mcp Builder
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leastbit-mcp-builder/badge)](https://www.skillsdirectory.com/skills/leastbit-mcp-builder)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mcp-builder
description: 指导开发优质 MCP(Model Context Protocol)服务器,通过设计得当的工具让 LLM 与外部服务交互。需要在 Python(FastMCP)或 Node.js/TypeScript(MCP SDK)中接入外部 API 或服务时使用。
license: 完整条款见 LICENSE.txt
---

# MCP 服务器开发指南

MCP 服务器通过工具把 LLM 接入外部服务。衡量质量的标准是 LLM 能否借此完成实际任务。

## 一、调研和规划

### 理解 MCP 工具设计

- 平衡 API 覆盖和面向工作流的工具。高层工具便于完成常见流程,全面的端点覆盖给 Agent 留出组合空间。有些客户端可用代码执行来组合基础调用,另一些更适合高层工具。不确定时优先保证覆盖率。
- 工具名可搜索、可辨认,使用一致的服务前缀和动词,例如 `github_create_issue`、`github_list_repos`。
- 控制上下文用量。工具描述应简洁,结果应支持筛选和分页,并突出当前操作所需的数据。支持代码执行的客户端也可自行过滤。
- 错误信息应给出具体的恢复措施或下一步。

### 阅读协议与框架文档

从 `https://modelcontextprotocol.io/sitemap.xml` 查找规范页面,在 URL 后加 `.md` 获取 Markdown,例如 `https://modelcontextprotocol.io/specification/draft.md`。重点阅读架构概览、Streamable HTTP 和 stdio,以及 tool、resource、prompt 的定义。

推荐 TypeScript,SDK 完善、静态类型和 lint 工具成熟,并能在包括 MCPB 在内的多类环境运行。远程服务优先选用无状态 JSON 的 Streamable HTTP 以便扩展和运维。本地服务选用 stdio。

- [MCP 最佳实践](./reference/mcp_best_practices.md)汇总了命名、分页、传输、响应格式、安全和错误处理等通用规范。
- **TypeScript v2**(`@modelcontextprotocol/server`)是当前稳定版,新服务优先采用。[v2 实现指南](./reference/node_mcp_server_v2.md)提供项目结构、示例与自检方法。SDK [README](https://raw.githubusercontent.com/modelcontextprotocol/typescript-sdk/main/README.md)及[文档索引](https://ts.sdk.modelcontextprotocol.io/v2/llms.txt)可通过 WebFetch 获取。
- **TypeScript v1**(`@modelcontextprotocol/sdk`)仅接收缺陷和安全修复。项目的 `package.json` 已使用 v1 时,简单说明 v2 已稳定并提供迁移命令 `npx @modelcontextprotocol/codemod@latest v1-to-v2 .`,随后继续按 [v1 指南](./reference/node_mcp_server.md)维护,除非用户要求迁移。v1 的 [SDK 文档](https://raw.githubusercontent.com/modelcontextprotocol/typescript-sdk/v1.x/README.md)及 `@modelcontextprotocol/sdk/...` 导入只适用于 v1 项目。
- **Python** 使用 [Python SDK](https://raw.githubusercontent.com/modelcontextprotocol/python-sdk/main/README.md)与 [FastMCP 实现指南](./reference/python_mcp_server.md),里面有模块结构、Pydantic 模型和 `@mcp.tool` 的注册方法。

阅读上游 API 文档,确认关键端点、鉴权要求和数据模型。按使用频率列出首先要覆盖的端点,必要时使用 WebFetch 或搜索。

## 二、实现

参照对应语言指南组织模块和依赖。集中编写鉴权 API client、错误处理、JSON/Markdown 响应格式和分页逻辑。

每个工具应包含:

- **输入 Schema。** TypeScript 用 Zod,Python 用 Pydantic。加入约束、明确的字段说明和例子。
- **输出 Schema。** 能定义时提供 `outputSchema`,并用 SDK 支持的 `structuredContent` 暴露结构化结果。
- **描述。** 简述用途、参数及返回结构,使客户端容易选到正确工具。
- **实现。** I/O 使用 async/await,错误提供可操作的提示,适当分页。现代 SDK 中按需同时提供文本与结构化数据。
- **Annotations。** 按工具语义设置 `readOnlyHint`、`destructiveHint`、`idempotentHint`、`openWorldHint`。

## 三、审查与测试

审查代码重复、错误处理一致性、类型覆盖和工具描述。在 TypeScript 项目运行 `npm run build`,v2 另按[实现指南](./reference/node_mcp_server_v2.md#verify-your-server)对构建产物运行自检。Python 项目运行 `python -m py_compile your_server.py`。两种语言均可使用 `npx @modelcontextprotocol/inspector` 检查交互。

## 四、建立评测

根据[评测指南](./reference/evaluation.md)验证 LLM 能否借助服务器回答真实、复杂的问题。

1. 列出工具并了解其能力。
2. 用只读操作探索可用数据。
3. 编写 10 个有实际用途的问题,要求组合多个工具深入检索,并确保问题彼此独立。
4. 自己求解,核实每题只有一个可通过字符串比对验证的清晰答案,且答案具有长期稳定性。

将评测写成下列 XML。

```xml
<evaluation>
  <qa_pair>
    <question>Find discussions about AI model launches with animal codenames. One model needed a specific safety designation that uses the format ASL-X. What number X was being determined for the model named after a spotted wild cat?</question>
    <answer>3</answer>
  </qa_pair>
<!-- More qa_pairs... -->
</evaluation>
```

评测指南还提供问题和答案示例、验证方法和运行脚本。

<!-- 本文件基于 Anthropic Skills 进行简体中文翻译及适配。 -->

Files in this skill

  • LICENSE.txt11.1 KB
  • SKILL.md8.1 KB
  • reference/evaluation.md18.6 KB
  • reference/mcp_best_practices.md6.5 KB
  • reference/node_mcp_server.md26.6 KB
  • reference/python_mcp_server.md23.3 KB
  • scripts/connections.py4.7 KB
  • scripts/evaluation.py12.2 KB
  • scripts/example_evaluation.xml1.2 KB
  • scripts/requirements.txt29 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.