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...
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.
Frequently Asked Questions
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.
Citations (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
Related on TokRepo
Source & Thanks
Created by Anthropic. Licensed under MIT. anthropics/skills
Discussion
Related Assets
/babysit — Auto-Respond to PR Review Comments
Open-source slash command that watches a PR for review comments and auto-pushes fixes. Inspired by Boris Cherny's /babysit pattern.
/loop — Local Recurring Task Scheduler (Boris-Style)
Open-source slash command for recurring local Claude Code tasks with a 3-day safety cap. Inspired by Boris Cherny's /loop scheduler.
/batch — Parallel Worktree Migration Slash Command
Open-source slash command that splits a migration across parallel git worktrees. Inspired by Boris Cherny's /batch worktree pattern.