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 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。
npx -y tokrepo@latest install 04ab7e67-695d-4138-b53a-6ecae4f695ea --target codex先暂存文件;激活前需要读取暂存 README 和安装计划。
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.
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.
How to use
- Add the mcp-builder skill to your Claude Code project. It is included as an official skill in Claude Code installations.
- 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
- 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']
}
}
]
}));
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);
Related on TokRepo
- MCP Postgres Integration -- PostgreSQL MCP server configuration
- MCP GitHub Integration -- GitHub MCP server for code operations
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.
常见问题
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.
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.
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.
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.
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)
- Model Context Protocol Specification— MCP enables LLMs to interact with external services through a standardized proto…
- Anthropic Claude Code Documentation— Claude Code supports custom skills for extending agent capabilities
- MCP SDK GitHub Repository— MCP SDK for TypeScript and Python
TokRepo 相关
来源与感谢
Created by Anthropic. Licensed under MIT. anthropics/skills
讨论
相关资产
Claude Official Skill: web-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifact...
GitHub MCP Server — Official GitHub AI Integration
GitHub's official MCP server that lets AI assistants manage repos, issues, PRs, Actions, and code search through the Model Context Protocol.
Claude Official Skill: frontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or appli...
Notion MCP Server — Official Notion Integration
Official Notion MCP server. Search, read, create, and update Notion pages, databases, and blocks from Claude Code, Cursor, or any MCP client. By Notion. 4.1K+ stars.