Skip to main content
Glama
fongfai

Minimum Viable MCP Project

by fongfai

最小可用 MCP 项目(Node.js + TypeScript)

这个项目是一个可直接跑通的 MCP 学习样例,包含完整链路:

  1. 写 MCP Server(Tool / Resource / Prompt)

  2. 本地用 MCP Client 调用并验证

  3. 接入 Codex,让 Codex 直接调用你的 MCP 能力

1. 环境要求

  • Node.js >= 22(用 --experimental-strip-types 直接运行 TS)

  • npm >= 9

Related MCP server: JSON MCP Boilerplate

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

这个命令会:

  1. 在同一个进程内创建 MCP server/client(InMemoryTransport

  2. src/smoke-client.ts 依次调用:

    • listTools

    • callTool(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. 下一步建议

  1. sum_numbers 增加输入边界校验(如最大值)。

  2. 增加一个会访问真实 API 的 Tool(例如天气查询)。

  3. 再加一个 ResourceTemplate 学习动态资源模式。

Available Tools

2 tools
pingA

Quick health check. Returns current server timestamp.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the action ('Returns current server timestamp'), which implies a read-only operation, but does not detail aspects like response format, error handling, or performance characteristics. It adds basic context but lacks comprehensive behavioral traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise and front-loaded, consisting of two short sentences that efficiently convey the tool's purpose and output. Every sentence earns its place without any wasted words, making it highly effective in minimal space.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (0 parameters, no output schema, no annotations), the description is complete enough for a health check tool. It explains what the tool does and what it returns, though it could benefit from more detail on behavioral aspects like error cases or usage constraints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter information is needed. The description does not add parameter semantics, but this is acceptable given the absence of parameters, aligning with the baseline score for zero parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Quick health check') and resource ('server timestamp'), distinguishing it from the sibling tool 'sum_numbers' which performs mathematical operations. It precisely communicates what the tool does without being vague or tautological.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context ('health check') but does not explicitly state when to use this tool versus alternatives or provide exclusions. It offers clear context for its purpose but lacks detailed guidance on specific scenarios or comparisons with other tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

sum_numbersB

Add two numbers and return structured output.

ParametersJSON Schema
NameRequiredDescriptionDefault
aYesFirst number
bYesSecond number

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes
expressionYes

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'return structured output,' which hints at the return format, but doesn't specify what that structure entails, error handling, or any constraints like numeric limits. This leaves significant gaps for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without any wasted words. It is appropriately sized and front-loaded, making it easy to understand at a glance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (basic arithmetic), 2 parameters with full schema coverage, and the presence of an output schema, the description is reasonably complete. It covers the core purpose and hints at the output, though it could benefit from more behavioral details given the lack of annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with clear documentation for both parameters ('a' and 'b'). The description adds no additional meaning beyond the schema, as it doesn't explain parameter interactions or constraints. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Add two numbers') and the resource ('numbers'), making the purpose immediately understandable. However, it doesn't distinguish from the sibling 'ping' tool, which is unrelated, so it doesn't fully differentiate from alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives or in what context it should be applied. It simply states what it does without any usage context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv0.1.0
    • First observedping
    • First observedsum_numbers

TDQS

B3.4/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have completely distinct purposes: ping is a health check returning a timestamp, while sum_numbers performs arithmetic addition. There is no overlap or ambiguity between them, making it trivial for an agent to select the correct tool.

Naming Consistency4/5

The tools use a consistent snake_case naming convention, but the verb patterns differ slightly: ping is a single verb, while sum_numbers is a verb_noun combination. This minor deviation keeps the naming mostly consistent and readable.

Tool Count2/5

With only two tools, the server feels thin and under-scoped for a general-purpose project. While it might be minimal by design, such a limited set restricts functionality and suggests an incomplete or overly narrow implementation.

Completeness1/5

The tool surface is severely incomplete for any meaningful domain. There are no CRUD operations, lifecycle management, or coherent workflows; the tools are isolated utilities with no apparent coverage of a broader purpose, leading to significant gaps for agent tasks.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A minimal, production-ready TypeScript starter template for building Model Context Protocol (MCP) servers with auto-loading architecture for tools, resources, and prompts. Provides boilerplate code, generators, and examples to quickly create MCP servers that can connect AI applications to any data source or tool.
    -
  • F
    license
    A
    quality
    D
    maintenance
    A starter template for building MCP (Model Context Protocol) servers with TypeScript support. Provides a clean foundation with example tools, resources, and prompts for creating custom integrations with Claude, Cursor, or other MCP-compatible AI assistants.
    2
    4 npm
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    A starter template designed to jumpstart the development of Model Context Protocol (MCP) servers using TypeScript. It provides pre-configured examples for creating tools and resources, along with integration guides for MCP clients like Cursor.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    A template project for quickly building Model Context Protocol (MCP) servers using TypeScript and the official SDK. It includes pre-configured examples for tools and resources to help developers jumpstart their custom MCP server development.
    67 npm
    -