Minimum Viable MCP Project
A starter template for building Model Context Protocol (MCP) servers using Node.js and TypeScript. It provides sample implementations for tools, resources, and prompts, designed to help developers test and integrate MCP capabilities into clients like Codex.
README
最小可用 MCP 项目(Node.js + TypeScript)
这个项目是一个可直接跑通的 MCP 学习样例,包含完整链路:
- 写 MCP Server(Tool / Resource / Prompt)
- 本地用 MCP Client 调用并验证
- 接入 Codex,让 Codex 直接调用你的 MCP 能力
1. 环境要求
- Node.js
>= 22(用--experimental-strip-types直接运行 TS) - npm
>= 9
2. 项目结构
.
├── src
│ ├── server.ts # MCP server (stdio)
│ └── smoke-client.ts # 本地全流程验证客户端
├── tsconfig.json
├── package.json
└── README.md
3. 安装依赖
npm install
4. 运行方式
4.1 开发模式(直接跑 TS)
npm run dev
4.2 启动服务
npm run start
4.3 全流程 Smoke Test(推荐先跑)
npm run smoke
这个命令会:
- 在同一个进程内创建 MCP server/client(
InMemoryTransport) - 用
src/smoke-client.ts依次调用:listToolscallTool(sum_numbers)readResource(note://quickstart)getPrompt(review_snippet)
5. 这个 Server 暴露了什么
Tools
ping: 健康检查sum_numbers: 两数求和,返回文本 + 结构化结果
Resource
note://quickstart: 学习提示文本
Prompt
review_snippet(language, snippet): 生成可复用的 code review prompt
6. 接入 Codex(重点)
推荐使用 Codex CLI 命令直接添加 MCP server。
6.1 添加到 Codex
codex mcp add learning-mcp -- node --experimental-strip-types /home/fezhang/mcp/src/server.ts
6.2 检查是否生效
codex mcp list
codex mcp get learning-mcp
6.3 在 Codex 会话里验证
你可以直接对 Codex 说:
列出 learning-mcp 的工具调用 sum_numbers,a=12,b=30读取资源 note://quickstart
6.4 删除配置(可选)
codex mcp remove learning-mcp
7. 常见问题
Q1: 为什么 server 日志写到 stderr,而不是 stdout?
MCP stdio 协议使用 stdin/stdout 传输 JSON-RPC。
如果把日志写到 stdout,会污染协议消息,导致调用失败。
Q2: 改了 src/server.ts 之后,Codex 什么时候生效?
这个样例是直接执行 src/server.ts。
下次启动新的 MCP server 进程就会生效,不需要构建。
8. 下一步建议
- 给
sum_numbers增加输入边界校验(如最大值)。 - 增加一个会访问真实 API 的 Tool(例如天气查询)。
- 再加一个
ResourceTemplate学习动态资源模式。
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.