Home
cd ../playbooks
Developer ToolsAdvanced

MCP Server Builder

Guide for creating high-quality Model Context Protocol (MCP) servers that enable LLMs to interact with external services and APIs.

30 minutes
By ComposioSource
#mcp#api#integration#llm#tools#python#typescript

You want to build a custom MCP server so Claude can access your internal API, but the docs are sparse and your first attempt returns cryptic JSON-RPC errors. Getting the transport layer, tool definitions, and error handling right takes longer than the actual integration logic.

Who it's for: developers building custom MCP servers for internal tools, API engineers exposing services to LLM agents, platform teams creating MCP integrations for their product, open-source contributors building community MCP servers, technical founders adding AI capabilities to existing products

Example

"Build an MCP server for our inventory management API" → Production-ready MCP server in TypeScript with tool definitions, authentication handling, error responses, rate limiting, and deployment configuration for both stdio and SSE transports

CLAUDE.md Template

New here? 3-minute setup guide → | Already set up? Copy the template below.

Or install from your terminal:
npx ccplaybooks add mcp-server-builder
# MCP Server Builder

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

## Overview

MCP servers provide tools that allow LLMs to access external services and APIs. Quality is measured by how effectively agents can accomplish real-world tasks using the tools provided.

## Development Process

### Phase 1: Research and Planning

Get new playbooks like this one

One email a week with new Claude Code workflows. Free, like everything here.

No spam. Unsubscribe anytime.

README.md

What This Does

Build high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services and APIs. Follow best practices for Python (FastMCP) or Node/TypeScript implementations.


Quick Start

Step 1: Create an MCP Project

mkdir -p ~/Projects/my-mcp-server

Step 2: Download the Template

Click Download above, then:

mv ~/Downloads/CLAUDE.md ~/Projects/my-mcp-server/

Step 3: Start Building

cd ~/Projects/my-mcp-server
claude

Then say: "Help me build an MCP server for [service/API]"


Development Phases

Phase Activities
1. Research API docs, protocol specs, tool design
2. Implementation Core infrastructure, tools, validation
3. Review Code quality, testing, documentation
4. Evaluation Create test scenarios, verify functionality

Key Design Principles

Build for Workflows

  • Don't just wrap API endpoints
  • Create tools that enable complete tasks
  • Consolidate related operations

Optimize for Context

  • LLMs have limited context windows
  • Return high-signal information only
  • Provide concise vs detailed options

Actionable Errors

  • Guide agents toward correct usage
  • Suggest specific next steps
  • Make errors educational

Language Options

Language SDK Best For
Python FastMCP Quick prototyping, data science
TypeScript MCP SDK Type safety, Node ecosystem

Example Prompts

  • "Create an MCP server for the GitHub API"
  • "Build tools to integrate with Slack"
  • "Design an MCP server for database queries"

Tool Annotations

@mcp.tool(
    readOnlyHint=True,      # Read-only operations
    destructiveHint=False,   # Non-destructive
    idempotentHint=True,     # Same result on repeat
    openWorldHint=True       # External systems
)

Quality Checklist

  • Pydantic/Zod input validation
  • Comprehensive docstrings
  • Error handling for all external calls
  • Async/await for I/O operations
  • Character limits and truncation
  • Multiple response formats

Tips

  • Research thoroughly: Study all API documentation first
  • Design for agents: Think about what workflows LLMs need
  • Test with evaluation: Create realistic test scenarios
  • Iterate based on feedback: Let agent performance guide improvements

$Related Playbooks

Developer Tools

Motion (Framer Motion): Animation Rules for React, JS and Vue

Give Claude the Motion team's own animation guidance: when to use CSS instead of Motion, AnimatePresence and layout animations done right, springs, performance rules, reduced motion and the framer-motion to motion migration

5 minutes
Intermediate
Developer Tools

Multi-Stage Prompt Pipeline

A methodology for building Claude-to-Claude prompt pipelines where one stage's output feeds the next — a four-purpose taxonomy (Research/Plan/Do/Refine), per-prompt provenance folders, XML-structured outputs with required metadata tags, a fixed human-scannable SUMMARY.md, dependency-aware layered execution, and per-stage validation before anything chains forward.

10 minutes
Advanced
Developer Tools

Nuxt UI Component Guidance

Build interfaces correctly with @nuxt/ui v4 — five core rules (UApp wrapper, semantic colors, reading generated theme files for real slot names, override priority, icon naming), a task-to-focus-area routing table, the Nuxt UI MCP server for live component API lookups, and full installation for both Nuxt and standalone Vue.

5 minutes
Beginner
Developer Tools

n8n Workflow Builder

Automate document workflows with n8n - 7800+ workflow templates

10 minutes
Advanced
Developer Tools

Office MCP Server Setup

MCP server with 39 tools for Word, Excel, PowerPoint, PDF, OCR operations

10 minutes
Intermediate
Developer Tools

Frontend Enhancer

Enhance Next.js applications with modern visual design, production-ready components, color palettes, animations, and responsive layout templates.

10 minutes
Intermediate
Developer Tools

Saga Orchestration for Distributed Transactions

Implement the saga pattern for multi-step workflows that span services and can't use a single ACID transaction — choreography vs. orchestration, a step/compensation model with explicit saga states, reverse-order compensation on failure, persisted saga state that survives an orchestrator restart, timeouts, and the idempotency and compensation-testing discipline that makes rollback actually work.

15 minutes
Advanced
Developer Tools

Reshape PR Commits

Turn a branch's messy WIP/fixup commit history into a clean, logically-grouped set of commits before review — proposed regrouping with explicit approval, git reset --soft plus staged re-commits instead of interactive rebase, and hard guardrails (feature branches only, force-with-lease only, never touch another author's commits).

5 minutes
Intermediate
Developer Tools

Reproducible Database Lookup

A methodology for querying public database APIs — scientific, regulatory, financial, or otherwise — so another agent or human can repeat exactly what you did: bounded calls, count reconciliation, identifier-conversion tracking, and untrusted-data handling for every response.

10 minutes
Advanced
Developer Tools

Redesign Existing Projects: UI Audit and Upgrade

A design audit checklist that finds generic AI-look patterns in an existing codebase and fixes them without breaking functionality or migrating frameworks

10 minutes
Intermediate
Developer Tools

Repomix Safe Mixer

Package codebases with repomix while automatically detecting and removing hardcoded credentials before packing — so you never leak secrets when sharing code.

5 minutes
Beginner
Developer Tools

Repomix Unmixer

Extract files from repomix-packed repositories — restore the original directory structure from XML, Markdown, or JSON output, reversing the packing process.

5 minutes
Beginner

Browse all Developer Tools playbooks →