Introduction
Build MCP servers in minutes with mcpcraft-sdk — the lightweight TypeScript SDK for the Model Context Protocol.
What is MCP?
The Model Context Protocol (MCP) is an open standard that lets AI applications discover and call functions on your server — the same way HTTP lets browsers talk to web APIs.
Think of it as a universal plugin system for AI:
| Layer | Web Analogy | MCP Analogy |
|---|---|---|
| Client | Browser (Chrome, Firefox) | AI App (Claude, Cursor, VS Code Copilot) |
| Protocol | HTTP | MCP (JSON-RPC over stdio/SSE) |
| Server | Express, Next.js API | Your MCP server |
| Endpoint | REST route (GET /users) | Tool (get_weather) or Resource (status://health) |
An MCP server exposes two kinds of endpoints:
- Tools — functions an LLM can execute (send an email, query a database, fetch an API). Return structured data.
- Resources — data an LLM can read (configuration, documentation, live metrics). Identified by URI, like
docs://readme.
Without MCP, you'd need custom integrations for every AI app. With MCP, you write your server once and any compatible client can use it.
MCP is to AI what HTTP is to the web — a universal protocol that decouples clients from servers.
How It Works
┌─────────────────┐ JSON-RPC ┌──────────────────┐ ┌─────────────┐
│ AI Agent │ ◄──── stdio/SSE ───► │ MCP Client │ ──► │ Your MCP │
│ (Claude, │ │ (Claude Desktop, │ │ Server │
│ Cursor, ...) │ │ VS Code, ...) │ │ │
└─────────────────┘ └──────────────────┘ └──────┬──────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
┌─────────┐ ┌──────────┐ ┌──────────┐
│ Tools │ │Resources │ │ CLI │
│ (exec) │ │ (read) │ │(scaffold)│
└─────────┘ └──────────┘ └──────────┘When a user asks "What's the weather in Tokyo?", the flow is:
- The AI agent decides it needs weather data
- It asks the MCP client for available tools
- The client sends a
tools/listrequest to your server over stdio - Your server responds with the
get_weathertool definition (name, description, input schema) - The AI agent sees the tool and decides to call it with
{ city: "Tokyo" } - The client sends a
tools/callrequest to your server - Your
runhandler executes, fetches live weather data, and returns it - The AI agent receives the response and crafts a natural language answer
Why mcpcraft-sdk?
The official @modelcontextprotocol/sdk gives you full control — but requires ~100 lines of boilerplate per server. mcpcraft-sdk distills that down to ~10 lines with automatic schema generation, type inference, and input validation.
import { createServer, tool } from "mcpcraft-sdk"
const server = createServer({ name: "hello-world" })
server.add(tool({
name: "greet",
description: "Greets a user by name",
input: {
name: { type: "string", description: "The user's name" }
},
run: async ({ name }) => {
return { message: `Hello, ${name}!` }
}
}))
server.start()| What the raw SDK makes you write | What mcpcraft-sdk does for you |
|---|---|
Server constructor + capability declaration | createServer({ name }) |
Manual JSON-RPC handlers (setRequestHandler) | server.add(tool({...})) |
inputSchema as raw JSON Schema | input as plain object → auto-generated |
| Manual type checks in handler | Inferred types + Zod validation |
StdioServerTransport + server.connect() | server.start() |
CLI, SDK & Templates
mcpcraft-sdk ships as three integrated layers:
| Layer | What it does | Command |
|---|---|---|
SDK (mcpcraft-sdk) | Runtime library for building MCP servers. Provides createServer, tool, resource. | npm install mcpcraft-sdk |
CLI (mcpcraft-sdk/cli) | Scaffolds new projects, generates boilerplate, runs dev servers. | npx mcpcraft-sdk init |
| Templates | Starter projects for common patterns. init prompts you to pick one (basic, gmail, weather). | Included in CLI |
The CLI is optional — you can use the SDK directly by installing the package. Templates are for when you want to skip the setup and start coding immediately.
Features
Zero Boilerplate
Define tools with plain objects. No JSON-RPC handlers, no transport setup, no manual schema definitions.
Full Type Safety
Handler parameters are typed automatically from your input schema — full autocomplete, zero casts.
Built-in Validation
Every tool input is validated with Zod before reaching your handler. Invalid calls get structured error responses, not crashes.
Tools & Resources
Register executable tools (for LLM actions) and read-only resources (for context) with the same .add() API.
Production Ready
Built on top of the official @modelcontextprotocol/sdk. Fully spec-compliant, works with Claude Desktop, VS Code Copilot, Cursor, and all MCP hosts.
Deploy Anywhere
Works with stdio (local), SSE (server-sent events), and can be deployed as Vercel serverless functions, Docker containers, or Node processes.
Next Steps
- Installation — Add mcpcraft-sdk to your project
- Quick Start — Build your first server in 5 minutes
- Deployment — Deploy to Vercel, Docker, or production
- API Reference — Full API documentation
- Examples — Real-world use cases