MCP Starter Kit
Production-ready TypeScript MCP server template — 4 tools, Zod validation, 19 tests, Claude Desktop + Code integration
README
MCP Server Starter Kit
A production-ready TypeScript template for building Model Context Protocol (MCP) servers. Skip the boilerplate and ship working tools to Claude and other MCP clients in minutes.
What's included
- Working MCP server using the official
@modelcontextprotocol/sdk - 3 example tools you can use as-is or adapt:
fetch_url— fetch web content with configurable limits and domain blockingread_file/list_directory— safe filesystem access with path traversal protectiontransform_data— convert between JSON, CSV, TSV, Markdown table, and plain text
- TypeScript throughout — strict mode, typed inputs/outputs, Zod validation
- Error handling patterns — every tool returns a typed
ToolResult<T>with ok/error discrimination - Environment-based config — all limits and paths configurable via
.env - Structured logging — stderr-only logger (MCP protocol uses stdout)
- Test suite — 19 tests with Vitest covering all three tools
- Build scripts —
npm run build,npm run dev,npm test,npm run typecheck
Requirements
- Node.js 18 or higher
- npm 9 or higher
Quick start
# 1. Install dependencies
npm install
# 2. Configure environment
cp .env.example .env
# Edit .env — at minimum, set FILE_READER_ROOT to a safe directory
# 3. Build
npm run build
# 4. Run
npm start
Development mode
npm run dev
Uses tsx for live reload — no build step required during development.
Connect to Claude Desktop
Add this to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"my-server": {
"command": "node",
"args": ["/absolute/path/to/mcp-starter-kit/dist/index.js"],
"env": {
"FILE_READER_ROOT": "/path/to/allowed/directory",
"LOG_LEVEL": "info"
}
}
}
}
Restart Claude Desktop. Your tools will appear in the tool picker.
Connect to Claude Code
Add to .claude/settings.json:
{
"mcpServers": {
"my-server": {
"command": "node",
"args": ["/absolute/path/to/mcp-starter-kit/dist/index.js"]
}
}
}
Tools reference
fetch_url
Fetches the text content of a URL.
| Parameter | Type | Required | Description |
|---|---|---|---|
url |
string | yes | HTTP or HTTPS URL to fetch |
headers |
object | no | Additional request headers |
timeout_ms |
number | no | Request timeout (100–30000ms, default from env) |
Returns the response body, status code, content type, and a truncated flag if the response exceeded FETCH_MAX_BYTES.
read_file
Reads a file within the configured FILE_READER_ROOT.
| Parameter | Type | Required | Description |
|---|---|---|---|
path |
string | yes | Relative path from root |
encoding |
utf8 or base64 |
no | Encoding (default: utf8) |
max_bytes |
number | no | Max bytes to read (default: 1MB) |
Path traversal (../) is blocked at the resolver level.
list_directory
Lists files and directories within the configured root.
| Parameter | Type | Required | Description |
|---|---|---|---|
path |
string | no | Relative directory path (default: .) |
recursive |
boolean | no | List nested files (default: false) |
transform_data
Converts data between formats.
| Parameter | Type | Required | Description |
|---|---|---|---|
input |
string | yes | Raw input data |
from_format |
json|csv|tsv|text |
yes | Input format |
to_format |
json|csv|tsv|markdown_table|text_summary |
yes | Output format |
options.pretty |
boolean | no | Pretty-print JSON (default: true) |
options.include_header |
boolean | no | Include CSV/TSV header row (default: true) |
options.delimiter |
string | no | Custom delimiter for CSV/TSV parsing |
Configuration
All configuration is via environment variables. See .env.example for the full list.
| Variable | Default | Description |
|---|---|---|
SERVER_NAME |
mcp-starter-kit |
Server identity reported to clients |
SERVER_VERSION |
1.0.0 |
Server version |
FETCH_MAX_BYTES |
1048576 |
Max response size for web fetcher (bytes) |
FETCH_TIMEOUT_MS |
10000 |
Default fetch timeout (ms) |
FETCH_BLOCKED_DOMAINS |
(empty) | Comma-separated blocked hostnames |
FILE_READER_ROOT |
./workspace |
Root directory for file access |
TRANSFORMER_MAX_INPUT |
50000 |
Max input characters for transformer |
LOG_LEVEL |
info |
Logging level (debug/info/warn/error) |
Adding your own tools
- Create
src/tools/my-tool.ts— export an async function that returnsToolResult<YourType> - Add input/output types to
src/types.tsusing Zod schemas - Register the tool in
src/index.tswithserver.tool(name, description, schema, handler) - Write tests in
src/tools/my-tool.test.ts
The pattern used by all three example tools:
export async function myTool(input: MyToolInput): Promise<ToolResult<MyToolOutput>> {
// validate, execute, return { ok: true, data: ... } or { ok: false, error: "...", code: "..." }
}
Project structure
mcp-starter-kit/
├── src/
│ ├── index.ts # Server entry point — tool registration
│ ├── config.ts # Environment variable loading
│ ├── logger.ts # Stderr logger
│ ├── types.ts # Shared types and Zod schemas
│ └── tools/
│ ├── web-fetcher.ts
│ ├── web-fetcher.test.ts (add your own)
│ ├── file-reader.ts
│ ├── file-reader.test.ts
│ ├── data-transformer.ts
│ └── data-transformer.test.ts
├── dist/ # Compiled output (after npm run build)
├── .env.example
├── package.json
├── tsconfig.json
└── vitest.config.ts
Running tests
npm test # Run once
npm run test:watch # Watch mode
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
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 模型以安全和受控的方式获取实时的网络信息。