MCP Server Starter Kit

MCP Server Starter Kit

A production-ready boilerplate for building MCP servers, featuring TypeScript, Zod validation, rate limiting, and example tools like echo and fetch_url, enabling quick setup of custom MCP servers.

Category
访问服务器

README

🚀 MCP Server Starter Kit

Production-ready Model Context Protocol (MCP) server boilerplate.
Ship your first MCP server in minutes, not days.

CI License: MIT TypeScript Node MCP

💎 Premium edition with Python (FastMCP) version, Railway/Render deploy configs, auth patterns, and 1-on-1 setup support → Get it on Gumroad →


What's included

Feature Status
TypeScript with strict mode ✅
Proper stderr logging (won't break MCP stdio) ✅
Token-bucket rate limiter ✅
Environment variable validation (Zod) ✅
Centralized error handling ✅
2 example tools (echo + fetch_url) ✅
Docker + docker-compose ✅
Claude Desktop auto-config script ✅
Unit test setup (Vitest) ✅
Python/FastMCP version 💎 Premium
Railway one-click deploy 💎 Premium
API key auth middleware 💎 Premium
OAuth 2.0 integration pattern 💎 Premium
Webhook receiver tool 💎 Premium
Database connection pattern 💎 Premium

Why this starter kit?

Every MCP server tutorial shows you a 30-line "hello world." Then you try to build something real and discover:

  • Logging to stdout breaks MCP — the protocol uses stdout for communication; your console.log corrupts it
  • No rate limiting — a runaway AI agent can hammer your APIs
  • No input validation — AI can send malformed arguments and crash your server
  • No error handling — unhandled exceptions crash the whole server
  • No deploy story — how do you actually run this in production?

This starter kit solves all of that from day one.


Quick start

Option 1: Use as a template

# Clone and rename
git clone https://github.com/srmcguirt/mcp-server-starter-kit my-mcp-server
cd my-mcp-server

# Install dependencies
npm install

# Copy env file and fill in your values
cp .env.example .env

# Start in dev mode (hot reload)
npm run dev

Option 2: Scaffold with npx

npx @wireforge/mcp-server-starter init my-server-name
cd my-server-name
npm install && npm run dev

Option 3: Install as a library

npm install @wireforge/mcp-server-starter

Add your first tool

Open src/tools/ and create a new file:

// src/tools/my-tool.ts
import { z } from 'zod';
import { toolResult } from '../lib/error-handler.js';
import type { MCPTool } from '../types.js';

const MyInputSchema = z.object({
  query: z.string().min(1).max(500),
  limit: z.number().int().positive().max(100).default(10),
});

export const myTool: MCPTool = {
  name: 'my_tool',
  description: 'Search for something and return results. Be specific about what this does — the AI reads this description.',
  inputSchema: {
    type: 'object',
    properties: {
      query: { type: 'string', description: 'The search query' },
      limit: { type: 'number', description: 'Max results to return', default: 10 },
    },
    required: ['query'],
  },
  async execute(args) {
    const { query, limit } = MyInputSchema.parse(args);

    // Your implementation here
    const results = await myApi.search(query, { limit });

    return toolResult(JSON.stringify(results, null, 2));
  },
};

Then register it in src/tools/index.ts:

import { myTool } from './my-tool.js';

export const tools: MCPTool[] = [
  echoTool,
  fetchUrlTool,
  myTool, // 👈 Add here
];

Connect to Claude Desktop

# Build and add to Claude Desktop config automatically
chmod +x scripts/add-to-claude.sh
./scripts/add-to-claude.sh my-server-name

# Then restart Claude Desktop

Or manually add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "my-server-name": {
      "command": "node",
      "args": ["/absolute/path/to/my-mcp-server/dist/index.js"],
      "env": {
        "MY_API_KEY": "your-key-here"
      }
    }
  }
}

Connect to Cursor / Cline / Windsurf

Add to your editor's MCP settings:

{
  "mcp": {
    "servers": {
      "my-server-name": {
        "command": "node",
        "args": ["/absolute/path/to/my-mcp-server/dist/index.js"]
      }
    }
  }
}

Deploy with Docker

# Build and run with docker-compose
cd docker && docker-compose up --build

# Or build manually
docker build -f docker/Dockerfile -t my-mcp-server .
docker run -it --env-file .env my-mcp-server

Project structure

mcp-server-starter/
├── src/
│   ├── index.ts              # Server entry point — wire everything together here
│   ├── types.ts              # MCPTool interface and shared types
│   ├── lib/
│   │   ├── logger.ts         # Winston logger — always logs to stderr
│   │   ├── rate-limiter.ts   # Token-bucket rate limiter
│   │   ├── env.ts            # Environment variable validation (Zod)
│   │   └── error-handler.ts  # Centralized error handling + toolResult helpers
│   └── tools/
│       ├── index.ts          # Tool registry — add your tools here
│       ├── echo.ts           # Example: simple string echo
│       └── fetch-url.ts      # Example: HTTP fetch with timeout + size limit
├── docker/
│   ├── Dockerfile            # Multi-stage production build
│   └── docker-compose.yml    # Local development + production compose
├── scripts/
│   └── add-to-claude.sh      # Auto-add to Claude Desktop config
├── .env.example              # Required environment variables
├── tsconfig.json             # Strict TypeScript config
└── package.json

Key patterns

✅ Always log to stderr

// ❌ WRONG — corrupts MCP protocol
console.log('something happened');

// ✅ CORRECT — logs to stderr, leaves stdout clean
logger.info('something happened');

✅ Validate all input with Zod

// ❌ WRONG — trusting AI-provided args
const { query } = args as { query: string };

// ✅ CORRECT — parse and validate
const { query } = MySchema.parse(args); // throws McpError on invalid input

✅ Use withErrorHandling for every tool

// ❌ WRONG — unhandled exceptions crash the server
async execute(args) {
  return await riskyOperation(args);
}

// ✅ CORRECT — errors logged + safe message returned to AI
return withErrorHandling('my_tool', () => riskyOperation(args));

💎 Premium Edition — $49

The open source version is a solid foundation. The Gumroad premium download adds:

  • ✅ Python/FastMCP version (same patterns, same quality)
  • ✅ API key authentication middleware
  • ✅ OAuth 2.0 integration pattern (GitHub, Google, etc.)
  • ✅ Railway + Render one-click deploy configs
  • ✅ Database connection patterns (Postgres, SQLite, Redis)
  • ✅ Webhook receiver tool template
  • ✅ Streaming responses pattern
  • ✅ MCP resources and prompts examples
  • ✅ 30-min video walkthrough: building a real production MCP server
  • ✅ 6 real-world example servers (GitHub, Notion, Slack, Postgres, filesystem, web search)
  • ✅ Commercial license (use in client work and products)

Get the premium edition →


FAQ

Q: Why TypeScript and not JavaScript?
A: MCP tool schemas need to match your implementation exactly. TypeScript catches mismatches at build time, not at 2am when an AI passes unexpected input.

Q: Why log to stderr?
A: MCP uses stdio transport — stdout carries the JSON-RPC protocol. Anything you write to stdout that isn't valid MCP JSON will corrupt the connection. The logger in this kit always writes to stderr.

Q: Can I use this with Python?
A: The Python/FastMCP version is in the premium edition. The patterns are identical — just in Python.

Q: Is this compatible with all MCP clients?
A: Yes. Uses the official @modelcontextprotocol/sdk. Tested with Claude Desktop, Cursor, Cline, and Windsurf.


Contributing

PRs welcome. See CONTRIBUTING.md.


License

MIT — free for personal and open source use.
Commercial license (client work, products, resale) included in the Premium Edition on Gumroad.


📬 Stay Updated

Get a free sample prompt + updates when new tools ship:

→ srmcguirt.github.io

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选