Skip to main content
Glama

todo-full · 串起手册要点的完整示例

一个 todo list,两条路对比实现,接真 DeepSeek。用一份可运行代码把 MCP 全套手册的要点串起来。

覆盖的要点

  • 三原语:MCP server 里 Tools + Resources + Prompts 都有

  • function calling:MCP client 把工具翻译成 DeepSeek 的 tools,跑工具循环

  • JSON-RPC 原始消息VERBOSE=1 打印底层 tools/call 请求与响应

  • 手搓 vs MCPmanual_way.py 是不用 MCP 的对照组

  • 换个 Host 也能跑:同一个 server 经 .mcp.json 接进 Claude Code,代码一行不改

Related MCP server: Enhanced Todoist MCP Server Extended

文件

文件

是什么

db.py

共用的 SQLite 数据库层(两条路都调它)

mcp_server.py

路 A:MCP server,三原语齐全

mcp_client.py

路 A:MCP client + DeepSeek 工具循环(主程序)

manual_way.py

路 B:手搓 prompt + 解析 + 分发(对照组)

对照说明.md

代码 ↔ 手册要点的逐条对照

pyproject.toml / uv.lock

uv 项目清单与锁文件,统一管理依赖

跑起来

需要 uv 和一个 DeepSeek API key。

# 首次运行前安装依赖(uv run 也会自动同步,这一步可省略)
uv sync

# 路 A:MCP(主示例)
DEEPSEEK_API_KEY=sk-xxx uv run mcp_client.py

# 路 A + 看底层 JSON-RPC 消息
DEEPSEEK_API_KEY=sk-xxx VERBOSE=1 uv run mcp_client.py

# 路 B:手搓对照
DEEPSEEK_API_KEY=sk-xxx uv run manual_way.py

mcp_client.py 会自动把 mcp_server.py 当子进程拉起(stdio),你不用单独启动它。 依赖统一声明在 pyproject.toml 里,uv run 会按 uv.lock 自动建虚拟环境并安装,无需手动管理。

配合 Claude Code 使用

除了跑 mcp_client.py(自己当 Host+Client),也可以让 Claude Code 直接当 Host 连这个 server —— 同一个 mcp_server.py 一行不用改,这正是「server 不关心对面是谁」的体现。

.mcp.json 已经把它注册好了:

{
  "mcpServers": {
    "todo": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/mcp-primer", "mcp_server.py"]
    }
  }
}

在项目目录里启动 claude 即可自动加载,/mcp 面板能看到连接状态和三原语。用法:

  • Tools:直接说「加一个任务:写周报」,模型会调 mcp__todo__add_task

  • Resources@todo:todos://all 引用全部任务;todos://{status} 是模板资源, @todo:todos://done / @todo:todos://pending 同样可读(模板资源不会出现在资源列表里,但能直接取)

  • Promptsdaily_review 也会一并暴露,具体入口见 /mcp 面板

这条路看不到 JSON-RPC 原始消息

VERBOSE=1mcp_client.py 自己在应用层打印的,走 Claude Code 这条路不生效。Claude Code 的 claude --debug mcp --debug-file <path> 只给连接生命周期的摘要,不含协议报文:

[DEBUG] MCP server "todo": Successfully connected (transport: stdio) in 313ms
[DEBUG] MCP server "todo": Connection established with capabilities: {"hasTools":true,...}
[DEBUG] ToolSearchTool: selected mcp__todo__add_task

实测这份日志里 grep jsonrpc / tools/call / tools/list 命中数为 0。/mcp 面板同理,是状态面板不是协议探针。

想看原始报文,就在 Host 和 server 之间插一层 tee —— stdio 传输本质就是两条管道,原样转发不影响功能:

#!/bin/bash
# mcp_server_debug.sh,记得 chmod +x
DIR="$(cd "$(dirname "$0")" && pwd)"
mkdir -p "$DIR/mcp_logs"
tee -a "$DIR/mcp_logs/in.jsonl" \
  | uv run --directory "$DIR" mcp_server.py \
  | tee -a "$DIR/mcp_logs/out.jsonl"

.mcp.jsoncommand 指向这个脚本("command": "/path/to/mcp_server_debug.sh", "args": []),重连后 in.jsonl(Host→server)和 out.jsonl(server→Host)会记下全部方法的报文 —— 不只是 tools/callinitializetools/listresources/read 都在里面,比 VERBOSE=1 只覆盖 tools/call 更全。 日志是追加写且含任务内容,记得加进 .gitignore

说明

  • 数据库文件 todos.db 首次运行自动创建在项目目录,重启后任务不丢。

  • 若访问 DeepSeek 需要代理,脚本已带 httpx[socks],设置 ALL_PROXY 即可。

  • mcp 锁在 1.x(mcp>=1.28,<2):2.0 是大改版、API 不同,示例按 1.x 写。

Available Tools

3 tools
add_taskC

添加一条待办任务。

ParametersJSON Schema
NameRequiredDescriptionDefault
titleYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.6/5.0
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. '添加' (add) implies a mutation, but the description does not mention side effects, permission requirements, return values, or error behavior. This lack of detail is a significant gap for a mutation tool.

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

Conciseness4/5

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

The description is a single, concise sentence, front-loaded with the verb and resource. It contains no unnecessary words, which is appropriate for a simple tool, though it is too brief to convey behavioral nuance.

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

Completeness2/5

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

Despite having only one parameter and an output schema, the description lacks behavioral transparency and usage guidance. As a mutation tool with no annotations, it is incomplete for an agent to understand side effects or invoke it safely. The description covers only the basic purpose and omits critical context.

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

Parameters1/5

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

Schema description coverage is 0%, and the description does not mention the 'title' parameter at all. The schema only indicates that 'title' is a required string, but the description adds no meaning about what the title represents or how it is used, failing to compensate for the schema's sparse information.

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 of adding a todo task, with a specific verb ('add') and resource ('todo task'). It distinguishes itself from sibling tools 'complete_task' and 'delete_task' by implying a creation operation, though it does not explicitly compare against them.

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 like 'complete_task' or 'delete_task'. It does not state use cases, exclusions, or prerequisites, leaving the agent without decision-making context.

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

complete_taskA

把指定 id 的任务标记为完成。

ParametersJSON Schema
NameRequiredDescriptionDefault
task_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.6/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full burden of disclosing behavioral traits. The description simply states the action without mentioning side effects, error handling, idempotency, or permissions. For a mutation tool, this is insufficient transparency—it does not reveal whether the operation is reversible or what happens if the task ID is invalid.

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, front-loaded sentence that conveys the core purpose without any wasted words. It is appropriately concise for a simple tool.

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

Completeness3/5

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

The tool has a simple one-parameter schema and an output schema exists, which reduces the need to explain return values. However, since there are no annotations, the description would benefit from adding behavioral details like idempotency or error conditions. It remains minimally viable but leaves gaps in operational context.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It mentions '指定 id' referencing the task_id parameter, but does not add any meaning beyond the schema's field name and type. No constraints, default behavior, or error conditions are described for the parameter.

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 '把指定 id 的任务标记为完成' clearly states the action (mark complete) on a specific resource (task identified by id). It distinguishes itself from sibling tools add_task and delete_task by specifying the completion operation.

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 provides clear context for when to use the tool: when you want to mark a task as complete. It does not explicitly mention comparisons or exclusions with sibling tools, but the action is unambiguous. No alternative guidance is given, but the usage scenario is directly implied.

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

delete_taskA

删除指定 id 的任务。

ParametersJSON Schema
NameRequiredDescriptionDefault
task_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.5/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It only says 'delete', which inherently implies destruction, but it does not mention side effects, reversibility, error behavior, or whether it is a hard or soft delete. This is a significant gap for a mutation tool.

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, clear sentence that is front-loaded and contains no redundant information. It is optimally concise.

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 (one required parameter) and the presence of an output schema, the description is nearly sufficient. It clearly identifies the action and target, but it omits details like behavior for non-existent tasks or response codes. Overall, adequate for a simple delete operation.

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

Parameters2/5

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

Schema description coverage is 0%, and the description only refers to 'specified id' without adding meaning beyond the schema's task_id field. It does not compensate for the lack of parameter detail, though the single parameter is simple and self-explanatory.

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 'Delete the task with the specified id' clearly states the verb (delete) and resource (task), and it distinguishes from sibling tools add_task and complete_task. It is specific and unambiguous.

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

Usage Guidelines3/5

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

The description implies use when deleting a task by ID, but it does not explicitly state when to use it versus add_task or complete_task. No exclusions or alternative instructions are provided.

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. 3 tool updatesv0.1.0
    • First observedadd_task
    • First observedcomplete_task
    • First observeddelete_task

TDQS

B3.4/5.0

Scored across 3 tools

Disambiguation5/5

Each tool targets a distinct action on a task: adding, completing, or deleting. There is no overlap or ambiguity between them.

Naming Consistency5/5

All tools follow the same verb_noun pattern: add_task, complete_task, delete_task. Naming is uniform and predictable.

Tool Count5/5

With only 3 tools, the set is minimal but each tool serves a clear purpose in the todo domain. The count is well-scoped and appropriate.

Completeness2/5

The set includes create, complete, and delete operations but lacks a way to list or retrieve tasks. This is a significant gap since agents cannot view existing tasks, making the tool surface incomplete for a todo workflow.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers