starter-mcp-server

starter-mcp-server

A foundational MCP server scaffold that provides pre-configured tools, resources, and prompts to jumpstart development for Claude Desktop. It enables users to perform mathematical calculations and access system information while offering a standardized pattern for building custom extensions.

Category
访问服务器

README

starter-mcp-server

Course: MCP & Tool Ecosystems Path: Agentic Coding Path · Position 11

A Gold Standard MCP server scaffold. Three working primitives (tools, resources, prompts) wired to your MCP host in under 5 minutes. Extend it with your own tools using the patterns in agent.spec.md.


What Is MCP?

The Model Context Protocol is an open standard that lets your AI model call code you write — fetching data, running calculations, querying databases — without leaving the conversation.

You → your AI → calls your tool → tool runs → result back to your AI → your AI answers you

This server implements MCP over stdio, which means your MCP host spawns it as a child process and communicates via stdin/stdout. No HTTP, no ports, no hosting needed.


Quick Start

1. Install and build

npm install
npm run build

2. Find your absolute path

pwd
# → /Users/yourname/projects/starter-mcp-server

3. Configure your MCP host

Open (or create) your MCP host config file. For Claude Desktop:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Add the mcpServers block (replace the path with your real path from step 2):

{
  "mcpServers": {
    "starter-mcp-server": {
      "command": "node",
      "args": ["/Users/yourname/projects/starter-mcp-server/dist/index.js"]
    }
  }
}

See claude_desktop_config.json.example for a full example with environment variables.

4. Restart your MCP host

Fully quit and reopen your MCP host. Look for the tools indicator near the chat input. Click it — you should see starter-mcp-server listed with three tools.

5. Test it

Try asking your AI:

"Use the calculate_sum tool to add 847 and 293."

"Read the system://info resource and tell me how much free memory this machine has."


What's Included

Tools (your AI can call these)

Tool What it does
calculate_sum Adds two numbers: a + b
calculate_percentage part is X% of whole
calculate_compound_interest Final balance after compounding

Resources (your AI can read these)

URI What it returns
system://info Platform, Node version, memory, uptime (JSON)
system://env Variables prefixed with SAFE_ from your .env (JSON)

Prompts (appear in your MCP host's prompt menu)

Prompt What it does
/explain_tool Ask your AI to explain any tool by name

Development Workflow

Test without an MCP host (uses the MCP Inspector UI):

npm run inspect

Watch mode (auto-restarts on file changes):

npm run dev

After editing source files, run npm run build before testing with your MCP host. Your MCP host caches the built output — it reads from dist/, not src/.


Adding Your First Tool

  1. Create src/tools/weather.ts — follow the exact pattern in src/tools/math.ts
  2. Export weatherTools: Tool[] and handleWeatherTool(name, args): string | null
  3. In src/index.ts, add two lines (marked with // ADD NEW ... comments)
  4. Run npm run build
  5. Restart your MCP host

The agent.spec.md file contains a copy-paste prompt you can give to your AI coding tool to build a complete new tool for you.


File Structure

src/
  index.ts              ← server setup + request routing
  tools/
    math.ts             ← 3 math tools (the pattern to copy)
  resources/
    system.ts           ← 2 system info resources
  prompts/
    index.ts            ← 1 sample prompt
dist/                   ← compiled JS (generated by npm run build)
claude_desktop_config.json.example
.env.example
agent.spec.md           ← AI prompt to extend this server

Critical Rule: Never Use console.log

stdout is reserved for the MCP JSON-RPC protocol. Any console.log() call will corrupt the stream and break your MCP host's connection to this server.

Always use console.error() for debug output. It writes to stderr, which is safe.

// ✅ Safe — writes to stderr
console.error("debug:", someValue);

// ❌ Breaks the server — writes to stdout
console.log("debug:", someValue);

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选