计划和实施MCP
计划、审查、运行!\ 为任何LLM带来Cursor的规划能力。
特性
- 基于会话的架构 --每个代理都有一个具有唯一NanoID的隔离工作区
- 草稿本 --基于文档的笔记和推理轨迹工作记忆
- 任务清单 --用于任务跟踪的原子CRUD操作
- X-User-ID安全 --适用于多用户环境的可选标头绑定(兼容LibreChat)
- TONL/JSON编码 --令牌高效响应格式(减少30-60%)
- 存储后端 --内存(默认)或Redis用于分布式部署
- TTL清理 --自动会话过期
快速入门(Docker)
使用Redis持久化运行的最快方法:
docker compose up -d这将从GHCR中提取公共映像,并使用Redis启动MCP服务器。
终点:
- MCP:
http://localhost:3000/mcp - 健康:
http://localhost:3000/health
发展
本地开发
npm install
npm run devRedis开发
在本地开发时使用Docker for Redis:
# Start Redis only
docker compose up -d redis
# Run server locally connecting to Redis
STORAGE_TYPE=redis npm run devDocker开发构建
使用Docker在本地构建和运行:
# Build local image
docker build -t mcp-scratchpad-todo .
# Run with docker-compose.dev.yml (builds from source)
docker compose -f docker-compose.dev.yml up -d配置
创建一个 .env 文件或设置环境变量:
| 变量 | 默认值 | 描述 |
|---|---|---|
PORT | 3000 | 服务器端口 |
HOST | localhost | 服务器主机(使用 0.0.0.0 Docker) |
STORAGE_TYPE | memory | memory 或 redis |
SESSION_TTL_HOURS | 24 | 自动清理前的会话生存期 |
RESPONSE_FORMAT | json | json 或 tonl (令牌优化) |
NANOID_LENGTH | 21 | 会话ID长度 |
REDIS_HOST | localhost | Redis主机(当 STORAGE_TYPE=redis) |
REDIS_PORT | 6379 | Redis端口 |
REDIS_PASSWORD | -- | Redis密码(可选) |
可用工具
| 工具 | 说明 |
|---|---|
init_session | 创建新会话,返回 session_id |
read_scratchpad | 阅读草稿栏内容 |
write_scratchpad | 替换草稿栏内容 |
add_todo | 添加带有标题、描述和标签的待办事项 |
list_todos | 列出待办事项(筛选器: all, pending, done) |
update_todo | 更新待办事项状态(pending, done) |
delete_todo | 按ID删除待办事项 |
所有工具都需要 session_id (除 init_session).
示例:结构化研究代理
You do web research for a User.
**CRITICAL:**
At start of an interaction:
1. init_session
2. write startup todos
Never stop with execution until all todos are done.
**Todos:**
1. Clarify requirements with user → write specs to scratchpad
2. Perform research based on specs
3. perform youtube search about talk shows and discussed points on the research topic
4. get 3 transcripts of the discussions to get detailed talking points
5. Output results in agreed format and sources. include talking points from the people in the talkshow
**Scratchpad:** Store user requirements, track search relevance, draft output before presenting. Review scratchpad before final delivery to ensure alignment with original specs.
You are now being connected with a user.集成
克劳德代码
添加到 ~/.claude/settings.json:
{
"mcpServers": {
"scratchpad-todo": {
"type": "url",
"url": "http://localhost:3000/mcp"
}
}
}Librechat
添加到 librechat.yaml:
mcp:
scratchpad-todo:
url: http://localhost:3000/mcp
headers:
X-User-ID: "{{LIBRECHAT_USER_ID}}"光标
添加到 .cursor/mcp.json:
{
"mcpServers": {
"scratchpad-todo": {
"url": "http://localhost:3000/mcp"
}
}
}X-User-ID安全
对于多用户环境,请通过 X-User-ID 将会话绑定到用户的header:
- 会话已创建 和
X-User-ID要求所有后续请求使用相同的标头 - 会话已创建 没有 它没有标头验证(向后兼容)
TONL格式
TONL(令牌优化表示法语言)将令牌使用量减少了30-60%。启用 RESPONSE_FORMAT=tonl.
TONL中的待办事项列表示例:
[2]{id, title, status, tags}
abc123 Task 1 done [backend]
def456 Task 2 pending []存储后端
| 后端 | 最适合 | 笔记 |
|---|---|---|
| 记忆 | 开发,单实例 | 重启时数据丢失 |
| 瑞迪斯 | 生产,多实例 | 持久,原生TTL |
测试
npm test # Run tests
npm run test:watch # Watch mode归因
灵感来自 计划和行动 纸张 和 Cursor的计划模式
许可证
麻省理工学院
