Skip to main content
skill CX Codex

mcp-builder · shareai-lab — Claude Code skill: build MCP servers

A skill that walks you through writing MCP servers in Python and TypeScript: tools, resources, testing and config registration.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add shareAI-lab/learn-claude-code --skill mcp-builder -a claude-code
Open on GitHub

What mcp-builder does

MCP servers let an agent reach external services over one protocol. This skill covers the three things a server exposes: tools the agent calls like functions, resources it can read, and ready-made prompt templates. Then come working templates in Python and TypeScript.

The setup path is spelled out: create the project, make a virtualenv, install the SDK (pip install mcp or npm install @modelcontextprotocol/sdk), write a basic stdio server, register it in ~/.claude/mcp.json. Separate sections handle external APIs through httpx, SQLite access that rejects anything not starting with SELECT, and resources such as file://{path}. For testing there is MCP Inspector via npx @anthropics/mcp-inspector python3 my_server.py, or you can pipe raw JSON-RPC messages in.

Servers that call someone else's API need a key — the weather example passes one as the key parameter. The best-practices list also puts authentication on you: if a tool touches anything sensitive, don't ship it open. Worth checking before you wire the server into a real project.

What it helps with

  • scaffold an MCP server in Python or TypeScript
  • write tool descriptions the agent can act on
  • wrap an external API and return a clean result
  • expose a database for read-only queries
  • test a server before registering it in config

Example prompts for the agent

  • build an MCP server that lists tasks from our API
  • add a SQLite tool that only runs SELECT queries
  • how do I test my MCP server with Inspector?

How to install mcp-builder

1Skills CLI (Vercel)

npx skills add shareAI-lab/learn-claude-code --skill mcp-builder -a claude-code

2Manually: put the files in place

~/.claude/skills/mcp-builder/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/mcp-builder/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about mcp-builder

How do I install mcp-builder in Claude?

Run npx skills add shareAI-lab/learn-claude-code --skill mcp-builder -a claude-code. The skill lands in ~/.claude/skills/mcp-builder/SKILL.md.

What does mcp-builder do?

It helps you write MCP servers, with templates in Python and TypeScript, examples of tools, resources and external API calls, plus testing commands.

What do I need for an MCP server to run?

The mcp SDK for Python or @modelcontextprotocol/sdk for TypeScript, and an API key for servers that call external services. Registration goes into ~/.claude/mcp.json.

Source text

SKILL.md · MIT
---
name: mcp-builder
description: Build MCP (Model Context Protocol) servers that give Claude new capabilities. Use when user wants to create an MCP server, add tools to Claude, or integrate external services.
---

# MCP Server Building Skill

You now have expertise in building MCP (Model Context Protocol) servers. MCP enables Claude to interact with external services through a standardized protocol.

## What is MCP?

MCP servers expose:
- **Tools**: Functions Claude can call (like API endpoints)
- **Resources**: Data Claude can read (like files or database records)
- **Prompts**: Pre-built prompt templates

## Quick Start: Python MCP Server

### 1. Project Setup

```bash
# Create project
mkdir my-mcp-server && cd my-mcp-server
python3 -m venv venv && source venv/bin/activate

# Install MCP SDK
pip install mcp
```

### 2. Basic Server Template

```python
#!/usr/bin/env python3
"""my_server.py - A simple MCP server"""

from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp.types import Tool, TextContent

# Create server instance
server = Server("my-server")

# Define a tool
@server.tool()
async def hello(name: str) -> str:
    """Say hello to someone.

    Args:
        name: The name to greet
    """
    return f"Hello, {name}!"

@server.tool()
async def add_numbers(a: int, b: int) -> str:
    """Add two numbers together.

    Args:
        a: First number
        b: Second number
    """
    return str(a + b)

# Run server
async def main():
    async with stdio_server() as (read, write):
        await server.run(read, write)

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())
```

### 3. Register with Claude

Add to `~/.claude/mcp.json`:
```json
{
  "mcpServers": {
    "my-server": {
      "command": "python3",
      "args": ["/path/to/my_server.py"]
    }
  }
}
```

## TypeScript MCP Server

### 1. Setup

```bash
mkdir my-mcp-server && cd my-mcp-server
npm init -y
npm install @modelcontextprotocol/sdk
```

### 2. Template

```typescript
// src/index.ts
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

const server = new Server({
  name: "my-server",
  version: "1.0.0",
});

// Define tools
server.setRequestHandler("tools/list", async () => ({
  tools: [
    {
      name: "hello",
      description: "Say hello to someone",
      inputSchema: {
        type: "object",
        properties: {
          name: { type: "string", description: "Name to greet" },
        },
        required: ["name"],
      },
    },
  ],
}));

server.setRequestHandler("tools/call", async (request) => {
  if (request.params.name === "hello") {
    const name = request.params.arguments.name;
    return { content: [{ type: "text", text: `Hello, ${name}!` }] };
  }
  throw new Error("Unknown tool");
});

// Start server
const transport = new StdioServerTransport();
server.connect(transport);
```

## Advanced Patterns

### External API Integration

```python
import httpx
from mcp.server import Server

server = Server("weather-server")

@server.tool()
async def get_weather(city: str) -> str:
    """Get current weather for a city."""
    async with httpx.AsyncClient() as client:
        resp = await client.get(
            f"https://api.weatherapi.com/v1/current.json",
            params={"key": "YOUR_API_KEY", "q": city}
        )
        data = resp.json()
        return f"{city}: {data['current']['temp_c']}C, {data['current']['condition']['text']}"
```

### Database Access

```python
import sqlite3
from mcp.server import Server

server = Server("db-server")

@server.tool()
async def query_db(sql: str) -> str:
    """Execute a read-only SQL query."""
    if not sql.strip().upper().startswith("SELECT"):
        return "Error: Only SELECT queries allowed"

    conn = sqlite3.connect("data.db")
    cursor = conn.execute(sql)
    rows = cursor.fetchall()
    conn.close()
    return str(rows)
```

### Resources (Read-only Data)

```python
@server.resource("config://settings")
async def get_settings() -> str:
    """Application settings."""
    return open("settings.json").read()

@server.resource("file://{path}")
async def read_file(path: str) -> str:
    """Read a file from the workspace."""
    return open(path).read()
```

## Testing

```bash
# Test with MCP Inspector
npx @anthropics/mcp-inspector python3 my_server.py

# Or send test messages directly
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | python3 my_server.py
```

## Best Practices

1. **Clear tool descriptions**: Claude uses these to decide when to call tools
2. **Input validation**: Always validate and sanitize inputs
3. **Error handling**: Return meaningful error messages
4. **Async by default**: Use async/await for I/O operations
5. **Security**: Never expose sensitive operations without auth
6. **Idempotency**: Tools should be safe to retry

© shareAI-lab · MIT · shareAI-lab/learn-claude-code

Similar skills

All skills for Agent setup: memory, context, orchestration →

mcp-builder by other authors comes first.

mcp-builder official anthropics This skill walks through building an MCP server in TypeScript or Python, from reading the protocol spec to writing tests and evaluation questions. 130,949installs mcp-builder jezweb A skill that takes a short brief and turns it into a deployable MCP server on Python with FastMCP, complete with local tests and a pre-deploy checklist. CX Codex +1 1,400installs mcp-builder microsoft Guide for building Model Context Protocol servers in TypeScript, Python, or C# to connect LLMs with custom APIs. 108installs build-with-exa Exa Tells your agent which Exa endpoint to pick and how to shape the request: search, content extraction, answers, Agent API. CX Codex +1 3,600installs mcp-server-builder Alireza Rezvani Turns an OpenAPI spec into an MCP server: tool manifest plus starter code in Python or TypeScript, with a validator to check it. 644installs context-matic official APIMatic Connects verified API and SDK documentation to GitHub Copilot. It stops agents from hallucinating method signatures during payment and service integrations. ★ 40,418repo stars notion-api sanjeed5 A Cursor rule that shapes how your agent writes Notion API code: separate modules, tokens from environment variables, official SDKs, paginated queries. ★ 3,579repo stars dm-limits-and-best-practices cognitedata A reference skill on CDF Data Modeling limits: concurrency and 429s, pagination, batching, QueuedTaskRunner. Useful when your code starts failing under load. CX Codex +1 1,900installs fastapi-python Mindrally Tells the agent how to write FastAPI code: async I/O, Pydantic v2 models, early returns and router layout. Useful when you build a Python API. CX Codex +1 13,900installs

From the same set3

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor