Skip to content

Contrite42/mcp-server-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Server Starter Template

Minimal, opinionated starter for building your own Model Context Protocol (MCP) server. Fork this, rename, replace the two example tools with yours, ship.

Use it to wrap any HTTP API as MCP tools that Claude Desktop, Cursor, Cline, or any MCP-compatible client can call.

What you get

  • Single-file TypeScript implementation (src/index.ts) — ~100 lines, no clever abstractions
  • Generic api() helper that handles auth headers, JSON, error messages
  • Two reference tools: one parameterless read, one with zod-validated input
  • Build script + bin entry for npm publish
  • Install snippets for Claude Desktop, Cursor, Cline
  • MIT licensed

Why this exists

I built 5 MCP servers in a week (Gumroad, Resend, Stripe Subscriptions, Cloudflare Workers, Vercel Deploy). The first one took 4 hours of finding the right SDK package, transport pattern, schema format, install config. The other 4 took 30 minutes each because I had the pattern locked in.

This is that pattern, extracted, so you can skip the 4 hours.

Quick start

# Clone + rename
git clone https://github.com/Contrite42/mcp-server-starter your-service-mcp-server
cd your-service-mcp-server
# Edit package.json (name, description), src/index.ts (SERVICE_*, tool definitions)

npm install
npm run build

Wire into your MCP client

Claude Desktop

~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "your-service": {
      "command": "node",
      "args": ["/absolute/path/to/your-service-mcp-server/build/index.js"],
      "env": {
        "SERVICE_API_KEY": "your_key"
      }
    }
  }
}

Cursor

~/.cursor/mcp.json:

{
  "mcpServers": {
    "your-service": {
      "command": "node",
      "args": ["/absolute/path/to/your-service-mcp-server/build/index.js"],
      "env": {
        "SERVICE_API_KEY": "your_key"
      }
    }
  }
}

Cline (VS Code)

Same JSON shape, paste into Cline's MCP Servers settings.

What the example tools demonstrate

list_items — a tool with no required input. The most common shape. Used for "list X" / "get current state" tools.

create_item — a tool with required + optional inputs, validated by zod. The most common write shape. The zod schemas become the JSON Schema that the MCP client uses for autocomplete + validation.

Both tools share the api() helper, which:

  • Adds the auth header
  • Serializes JSON bodies
  • Returns parsed JSON on 2xx
  • Throws with status + body excerpt on non-2xx

Replace the body of each tool function with your actual API calls.

Patterns I'd repeat

  • One file. Easy to audit, easy to fork. No need for src/tools/ src/transports/ src/etc/.
  • Zod for schemas. The MCP TypeScript SDK takes zod directly. Error messages are good.
  • Stderr for logs. Stdout is the MCP frame transport. Any console.log() will break the protocol. Use console.error() for diagnostics — your MCP client surfaces them in its log panel.
  • One API key per server. Don't accept multiple credentials. Run multiple instances with different env vars if you need that.
  • Cents not dollars. Or whatever the smallest unit is for your service. Floats are the enemy.

What this doesn't do

  • HTTP transport (this uses stdio — the standard MCP client pattern)
  • Authentication beyond a single bearer token (extend if your service has OAuth)
  • Caching (add a Map or in-memory store inside the helper if needed)
  • Streaming responses (most MCP tools return one payload — streaming is for the AI's output, not yours)

Examples of MCP servers built from this pattern

These are the production servers I built using this exact template:

For the curated bundle of all 6 (with the full READMEs + zip packages): MCP Server Toolkit Vol. 1 on Gumroad (launching soon).

License

MIT. Fork, modify, embed in your own product, no attribution required.

About

Minimal MCP server starter template. Fork, replace example tools with yours, ship. Reference patterns for HTTP API wrappers + zod inputs + stdio transport. MIT.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors