mcpcraft-sdk

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:

LayerWeb AnalogyMCP Analogy
ClientBrowser (Chrome, Firefox)AI App (Claude, Cursor, VS Code Copilot)
ProtocolHTTPMCP (JSON-RPC over stdio/SSE)
ServerExpress, Next.js APIYour MCP server
EndpointREST 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:

  1. The AI agent decides it needs weather data
  2. It asks the MCP client for available tools
  3. The client sends a tools/list request to your server over stdio
  4. Your server responds with the get_weather tool definition (name, description, input schema)
  5. The AI agent sees the tool and decides to call it with { city: "Tokyo" }
  6. The client sends a tools/call request to your server
  7. Your run handler executes, fetches live weather data, and returns it
  8. 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 writeWhat mcpcraft-sdk does for you
Server constructor + capability declarationcreateServer({ name })
Manual JSON-RPC handlers (setRequestHandler)server.add(tool({...}))
inputSchema as raw JSON Schemainput as plain object → auto-generated
Manual type checks in handlerInferred types + Zod validation
StdioServerTransport + server.connect()server.start()

CLI, SDK & Templates

mcpcraft-sdk ships as three integrated layers:

LayerWhat it doesCommand
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
TemplatesStarter 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