MCP Server Generation Patterns in the mcp-builder Skill: A Complete Guide

The mcp-builder skill in the anthropics/skills repository provides automated generation patterns that extract tool descriptions from docstrings, build input schemas from type hints using Pydantic or Zod, and enforce standardized naming conventions to eliminate boilerplate when building MCP servers.

The mcp-builder skill streamlines the creation of Model Context Protocol (MCP) servers by automating the repetitive aspects of tool definition. By leveraging MCP server generation patterns, developers can write standard Python or TypeScript functions and automatically obtain fully-documented, schema-validated MCP tools without manual metadata entry.

Core MCP Server Generation Patterns in mcp-builder

The skill implements four primary generation patterns that work across both Python and TypeScript implementations.

Automatic Description Generation from Docstrings

The server extracts a human-readable description for each tool directly from the function’s docstring in Python or the JSDoc comment in TypeScript. This removes the need to manually write a description field in the tool manifest.

In Python, as documented in skills/mcp-builder/reference/python_mcp_server.md, the generator parses the function’s docstring at line 38. In TypeScript, documented in skills/mcp-builder/reference/node_mcp_server.md at line 111, the description field must be explicitly provided but is typically sourced from JSDoc comments.

Automatic inputSchema Generation with Pydantic and Zod

For Python, the server builds a Pydantic model from the function signature and type hints, converting it into an inputSchema. In TypeScript, a Zod object is created from the declared parameter types. This guarantees that the MCP runtime validates inputs before your tool runs.

According to python_mcp_server.md, this pattern is detailed at line 38 under "Automatic … inputSchema generation". The TypeScript equivalent in node_mcp_server.md at line 35 shows the pattern using inputSchema: { param: z.string() }.

Standardized Naming Conventions

Both languages prescribe a naming pattern for the server file, the service class, and the individual tools. This prevents naming collisions and makes the generated OpenAPI-like definitions deterministic.

The Python naming convention is documented in python_mcp_server.md at line 45 under "Server Naming Convention". The TypeScript pattern appears in node_mcp_server.md at line 67 under "Naming pattern".

Tool Registration Patterns

A concise registration block automatically wires the generated description and schema into the MCP server’s manifest. In Python, this uses server.add_tool(...), while TypeScript uses server.registerTool(...).

The Python registration pattern is documented in python_mcp_server.md at line 25 under "Tool Registration Pattern". The TypeScript equivalent is in node_mcp_server.md at line 5 under "Tool registration patterns".

Implementation Examples

Python Implementation with FastMCP

The following example from skills/mcp-builder/reference/python_mcp_server.md demonstrates how the generation patterns work in practice:


# file: my_service.py

from fastmcp import MCPServer
from pydantic import BaseModel, Field

class SearchUserInput(BaseModel):
    """Search for a user by name or email."""
    query: str = Field(..., description="Search string (e.g. ‘[email protected]’)")
    limit: int = Field(10, ge=1, le=100, description="Maximum results to return")

def search_user(params: SearchUserInput):
    """Look up users in the Example system.

    Args:
        params: The validated search parameters.

    Returns:
        A list of matching user records.
    """
    # implementation omitted …

    return results

# Server initialization – the description and inputSchema are generated automatically

server = MCPServer(name="ExampleUserService")
server.add_tool(search_user)   # description and schema extracted from docstring & model

What happens: The docstring becomes the tool’s description, SearchUserInput is turned into the inputSchema (Pydantic → JSON schema), and add_tool registers the tool with the generated metadata.

TypeScript Implementation with Zod

The TypeScript equivalent from skills/mcp-builder/reference/node_mcp_server.md shows the Zod-based pattern:

// file: myService.ts
import { MCPServer } from '@anthropic/mcp';
import { z } from 'zod';

const SearchUserSchema = z.object({
  /** Search string (e.g. “alice@example.com”) */
  query: z.string().min(1),
  /** Max results to return (default 10) */
  limit: z.number().int().min(1).max(100).optional(),
});

/**
 * Look up users in the Example system.
 *
 * @param params Validated search parameters.
 * @returns Array of matching users.
 */
async function searchUser(params: z.infer<typeof SearchUserSchema>) {
  // implementation omitted …
  return results;
}

// Server initialization – description is taken from the JSDoc comment,
// inputSchema is the Zod object above.
const server = new MCPServer({ name: "ExampleUserService" });
server.registerTool({
  title: "searchUser",
  description: "Look up users in the Example system.",   // must be provided explicitly
  inputSchema: SearchUserSchema,
  handler: searchUser,
});

What happens: The JSDoc comment supplies the description (explicitly required in TypeScript), SearchUserSchema serves as the inputSchema, and registerTool wires everything together.

Key Reference Files in the mcp-builder Skill

The following files in the anthropics/skills repository contain the authoritative documentation for these generation patterns:

Summary

  • Automatic description generation extracts tool descriptions from Python docstrings or TypeScript JSDoc comments, eliminating manual metadata entry.
  • Automatic inputSchema generation converts Pydantic models (Python) or Zod objects (TypeScript) into JSON schemas for runtime validation.
  • Standardized naming conventions ensure deterministic server files, service classes, and tool names across both languages.
  • Tool registration patterns use concise add_tool() (Python) or registerTool() (TypeScript) calls to wire generated metadata into the MCP manifest.
  • Reference documentation in skills/mcp-builder/reference/ provides the authoritative specifications for implementing these patterns.

Frequently Asked Questions

How does the mcp-builder skill automatically generate tool descriptions?

The skill parses the Python function’s docstring or the TypeScript function’s JSDoc comment to populate the tool’s description field. In Python, this happens automatically when using server.add_tool(), while TypeScript requires explicitly passing the description string to registerTool() even though it is typically sourced from JSDoc.

What libraries does mcp-builder use for inputSchema generation in Python and TypeScript?

For Python, the skill leverages Pydantic models to generate JSON schemas from function type hints and signatures. For TypeScript, it uses Zod objects to define and validate the input structures. Both approaches ensure that the MCP runtime validates inputs against the generated schema before invoking the tool handler.

Where are the naming conventions documented in the mcp-builder skill?

Standardized naming conventions are documented in skills/mcp-builder/reference/python_mcp_server.md at line 45 for Python and skills/mcp-builder/reference/node_mcp_server.md at line 67 for TypeScript. Additional quality guidelines appear in skills/mcp-builder/reference/mcp_best_practices.md at line 33.

Can I use mcp-builder patterns with existing FastMCP or Anthropic MCP servers?

Yes. The generation patterns are designed to integrate with existing server implementations. The Python patterns work with fastmcp.MCPServer and its add_tool() method, while the TypeScript patterns integrate with @anthropic/mcp and its registerTool() function. Both approaches allow you to retrofit existing services with automatic schema and description generation without restructuring your codebase.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →