Skills2026年3月29日·1 分钟阅读

Claude Official Skill: mcp-builder

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP serve...

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 17/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Mcp Config
安装
Stage only
信任
信任等级:Community
入口
Claude Official Skill: mcp-builder
安全暂存命令
npx -y tokrepo@latest install 04ab7e67-695d-4138-b53a-6ecae4f695ea --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

TL;DR
The mcp-builder skill teaches Claude Code to create production-quality MCP servers with proper tool definitions and testing.
§01

What it is

The mcp-builder is an official Claude Code skill that guides the agent through creating high-quality MCP (Model Context Protocol) servers. MCP servers enable LLMs to interact with external services, databases, APIs, and tools through a standardized protocol. This skill encapsulates best practices for server architecture, tool definitions, resource handling, error management, and testing.

Developers building MCP integrations for Claude Code, Claude Desktop, or other MCP-compatible clients benefit most. The skill eliminates guesswork about MCP server structure and ensures the output follows the protocol specification.

§02

How it saves time or tokens

Building an MCP server from scratch requires understanding the protocol specification, setting up the transport layer, defining tool schemas, handling errors correctly, and writing tests. The mcp-builder skill front-loads all of this knowledge so Claude Code produces correct server code on the first attempt. Instead of iterating through protocol misunderstandings, the agent follows a validated template that covers common patterns.

§03

How to use

  1. Add the mcp-builder skill to your Claude Code project. It is included as an official skill in Claude Code installations.
  1. Ask Claude Code to build an MCP server:
Build an MCP server that connects to my PostgreSQL database and exposes query and schema inspection tools
  1. Claude Code follows the skill's guidance to generate:
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';

const server = new Server({
  name: 'postgres-mcp',
  version: '1.0.0'
}, {
  capabilities: { tools: {} }
});

server.setRequestHandler('tools/list', async () => ({
  tools: [
    {
      name: 'query',
      description: 'Execute a read-only SQL query',
      inputSchema: {
        type: 'object',
        properties: {
          sql: { type: 'string', description: 'SQL query to execute' }
        },
        required: ['sql']
      }
    }
  ]
}));
§04

Example

// Tool handler with proper error handling
server.setRequestHandler('tools/call', async (request) => {
  const { name, arguments: args } = request.params;
  
  if (name === 'query') {
    try {
      const result = await pool.query(args.sql);
      return { content: [{ type: 'text', text: JSON.stringify(result.rows) }] };
    } catch (error) {
      return { content: [{ type: 'text', text: `Query error: ${error.message}` }], isError: true };
    }
  }
});

const transport = new StdioServerTransport();
await server.connect(transport);
§05

Related on TokRepo

§06

Common pitfalls

  • MCP servers must handle errors gracefully with isError: true in the response. Throwing unhandled exceptions crashes the server and disconnects the client.
  • Tool input schemas must use JSON Schema format. Missing required fields or incorrect types cause silent failures when the client validates inputs.
  • The stdio transport reads from stdin and writes to stdout. Any console.log statements in your server code corrupt the protocol stream. Use stderr for debug logging.

常见问题

What is MCP?+

MCP (Model Context Protocol) is a standard protocol for connecting AI models to external tools and data sources. It defines how a client (Claude Code, Claude Desktop) communicates with a server that provides tools, resources, and prompts.

What languages can I build MCP servers in?+

The official MCP SDK is available for TypeScript/JavaScript and Python. The mcp-builder skill primarily generates TypeScript servers using the @modelcontextprotocol/sdk package. Community SDKs exist for Go, Rust, and other languages.

Can this skill build MCP servers for any service?+

Yes. The skill guides Claude Code to build MCP servers for databases, APIs, file systems, cloud services, and custom tools. You describe what the server should connect to and what operations it should expose, and the skill structures the implementation.

How do I test an MCP server?+

The mcp-builder skill includes testing guidance. Use the MCP Inspector tool to manually test tool calls, or write automated tests that spawn the server process and send protocol messages via stdin/stdout.

Do I need to install anything special to use this skill?+

The mcp-builder skill is included with Claude Code. To build servers, you need Node.js (for TypeScript servers) or Python. The @modelcontextprotocol/sdk package is installed as a dependency of your server project.

引用来源 (3)
🙏

来源与感谢

Created by Anthropic. Licensed under MIT. anthropics/skills

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产