mcp-server-starter-kit
A production-shaped starter for building MCP servers in TypeScript, featuring stdio and streamable HTTP transport, bearer auth, and example tools including ping and http_get_json with SSRF guards.
README
mcp-server-starter-kit
A production-shaped starter for building a Model Context Protocol server in TypeScript.
Most MCP tutorials stop at "hello world" over stdio. The hard parts — the ones that actually break servers in the wild — start right after: authentication, transport choice, request timeouts, SSRF guards, and a deploy that survives cold starts. This kit ships those, small enough to read in one sitting.
The MCP protocol is the easy part. Everything around it is where servers die. This kit is that "everything around it," kept minimal and honest.
- stdio + streamable HTTP, switched by one env var.
- Bearer auth that fails closed — no token configured means every HTTP request is rejected, with a real
401+WWW-Authenticate, constant-time comparison, and the token never logged. - Legible errors — a typed
ToolErrorbecomes a proper MCP error result (isError: true), so an agent sees[forbidden_host] ...instead of a silent hang or an opaqueinternal error. - A real example tool (
http_get_json) with the guards every fetch tool needs and most omit: input validation, https-only, an SSRF host allowlist, and a hard timeout. - Stateless HTTP by design — the shape that survives serverless cold starts (see
DEPLOYMENT.md). - Tests + typecheck out of the box (a drop-in GitHub Actions CI is in
DEPLOYMENT.md).
Quickstart (stdio, ~60 seconds)
git clone https://github.com/park11innyc-lgtm/mcp-server-starter-kit
cd mcp-server-starter-kit
npm install
cp .env.example .env
npm run dev # starts on stdio; logs "ready on stdio" to stderr
Point Claude Desktop / Cursor at it — claude_desktop_config.json:
{
"mcpServers": {
"starter-kit": {
"command": "npx",
"args": ["tsx", "/absolute/path/to/mcp-server-starter-kit/src/index.ts"]
}
}
}
Restart the client and you'll have two tools: ping and http_get_json.
Run it remotely (streamable HTTP + auth)
# generate a token
node -e "console.log(require('crypto').randomBytes(24).toString('base64url'))"
# put it in .env -> MCP_BEARER_TOKENS=<that token>
npm run serve:http # POST http://localhost:3000/mcp (GET /healthz is open)
Every request to /mcp now needs Authorization: Bearer <token>. With no token set, the server refuses everything — that "fail closed" default is the point.
The two example tools
| Tool | What it shows |
|---|---|
ping |
The minimum viable tool: zero input, structured JSON out. Use it as your liveness check. |
http_get_json |
The patterns a real outbound tool needs — zod input validation, an https-only rule, an SSRF allowlist (ALLOWED_FETCH_HOSTS), and an AbortController timeout — with every failure mapped to a typed error. |
Add your own in src/tools.ts and register it in src/server.ts. The try/catch → toToolResult wrapper there is what keeps your failures legible; keep using it.
The parts tutorials skip (and where they live)
- Auth that fails closed →
src/auth.ts. Bearer tokens are the correct first step; full delegated OAuth 2.1 is a deliberate non-goal of a starter —DEPLOYMENT.mdpoints at where to add it. - stdout is sacred on stdio →
src/index.ts. One strayconsole.logcorrupts the JSON-RPC stream. Log to stderr only. - Cold starts →
src/http.tsis stateless on purpose.DEPLOYMENT.mdexplains why and when to add sessions. - SSRF → an MCP tool that fetches URLs is an open proxy into your network unless you allowlist hosts.
http_get_jsondoes.
Layout
src/
index.ts entry — picks stdio vs http
server.ts builds the McpServer, registers tools, wraps handlers
tools.ts the example tools (add yours here)
auth.ts bearer auth for the HTTP transport (fail closed)
http.ts stateless streamable-HTTP server
errors.ts ToolError + toToolResult
test/
tools.test.ts
Scripts
npm run dev # stdio, hot
npm run serve:http # http transport
npm run build # tsc -> dist/
npm start # run built server
npm test # vitest
npm run typecheck # tsc --noEmit
License
MIT — do whatever you want with it. Attribution appreciated, not required.
<sub>Built as an honest reference, not a paywall. A production companion focused on ops automation (retry/dedup, cost caps, runbooks) is in the works — a link will land here when it ships.</sub>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。