使用说明
MCP任务管理器
用于全面任务管理的模型上下文协议(MCP)服务器,部署为Cloudflare Worker。这个开源项目使AI助手能够使用Cloudflare KV的持久存储高效地规划、跟踪和管理复杂的多步骤请求。
🚀 特性
- 请求计划:将复杂的请求分解为可管理的任务
- 任务管理:创建、更新、删除和跟踪任务进度
- 审批工作流程:内置任务和请求完成审批系统
- 进度跟踪:可视化进度表和详细的任务信息
- 永久存储:使用Cloudflare KV实现可靠的数据持久性
- 无服务器架构:部署为Cloudflare Worker以实现全球可用性
- RESTful API:HTTP端点,便于与任何应用程序集成
- CORS支持:为web应用程序启用了跨源请求
📦 部署
先决条件
- Cloudflare帐户 (免费版作品)
- 牧马人CLI 安装
- Node.js 18+和npm/pnpm/yarn
- Git用于克隆存储库
快速开始
-
克隆并设置存储库
git clone https://github.com/Rudra-ravi/mcp-taskmanager.git cd mcp-taskmanager npm install -
登录Cloudflare
npx wrangler login这将打开您的浏览器以向Cloudflare进行身份验证。
-
创建KV命名空间
npx wrangler kv namespace create "TASKMANAGER_KV"从输出中复制命名空间ID。
-
更新配置 编辑
wrangler.toml并替换KV命名空间ID:[[kv_namespaces]] binding = "TASKMANAGER_KV" id = "your-new-kv-namespace-id-here" -
构建和部署
npm run build npx wrangler deploy
您的MCP任务管理器将在以下位置部署和访问:
https://mcp-taskmanager.your-subdomain.workers.dev
高级配置
自定义工作者姓名
要使用自定义名称进行部署,请更新 wrangler.toml:
name = "my-custom-taskmanager" # Change this to your preferred name
main = "worker.ts"
compatibility_date = "2024-03-12"
[build]
command = "npm run build"
[[kv_namespaces]]
binding = "TASKMANAGER_KV"
id = "your-kv-namespace-id-here"
环境变量
对于不同的环境(开发、暂存、生产):
[env.staging]
name = "mcp-taskmanager-staging"
[[env.staging.kv_namespaces]]
binding = "TASKMANAGER_KV"
id = "staging-kv-namespace-id"
[env.production]
name = "mcp-taskmanager-prod"
[[env.production.kv_namespaces]]
binding = "TASKMANAGER_KV"
id = "production-kv-namespace-id"
部署到特定环境:
npx wrangler deploy --env staging
npx wrangler deploy --env production
🔧 用法
API终点
部署的worker提供了两个主要端点:
POST /list-tools-获取可用的MCP工具POST /call-tool-执行MCP工具功能
测试您的部署
部署后,使用curl测试worker:
# Replace with your actual worker URL
WORKER_URL="https://mcp-taskmanager.your-subdomain.workers.dev"
# Test list tools
curl -X POST $WORKER_URL/list-tools \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}'
# Test creating a request
curl -X POST $WORKER_URL/call-tool \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "request_planning",
"arguments": {
"originalRequest": "Test deployment",
"tasks": [{"title": "Test task", "description": "Verify deployment works"}]
}
}
}'
可用工具
📋 核心任务管理
request_planning-注册新用户请求并计划其相关任务get_next_task-获取请求的下一个待处理任务mark_task_done-使用可选详细信息将任务标记为已完成approve_task_completion-批准已完成的任务approve_request_completion-批准整个请求的完成
⚙️ 任务操作
add_tasks_to_request-向现有请求添加新任务update_task-更新任务标题或描述(仅适用于待处理的任务)delete_task-从请求中删除任务open_task_details-获取特定任务的详细信息
📊 信息与监控
list_requests-列出所有请求及其当前状态和进度
API调用示例
列出可用工具
curl -X POST https://your-worker.your-subdomain.workers.dev/list-tools \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}'
计划新请求
curl -X POST https://your-worker.your-subdomain.workers.dev/call-tool \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "request_planning",
"arguments": {
"originalRequest": "Build a web application for task management",
"splitDetails": "Breaking down into frontend, backend, and deployment tasks",
"tasks": [
{
"title": "Setup React frontend",
"description": "Initialize React app with TypeScript and essential dependencies"
},
{
"title": "Create backend API",
"description": "Build REST API with Node.js and Express"
},
{
"title": "Deploy application",
"description": "Deploy to cloud platform with CI/CD pipeline"
}
]
}
}
}'
📊 数据模型
任务结构
interface Task {
id: string; // Unique task identifier (e.g., "task-1")
title: string; // Task title
description: string; // Detailed task description
done: boolean; // Whether task is marked as done
approved: boolean; // Whether task completion is approved
completedDetails: string; // Details provided when marking task as done
}
请求结构
interface RequestEntry {
requestId: string; // Unique request identifier (e.g., "req-1")
originalRequest: string; // Original user request description
splitDetails: string; // Details about how request was split into tasks
tasks: Task[]; // Array of tasks for this request
completed: boolean; // Whether entire request is completed
}
任务状态流
❌ Pending → ⏳ Done (awaiting approval) → ✅ Approved
任务只能在处于“待定”状态时更新。一旦标记为已完成或已批准,它们将变为只读。
🛠️ 发展
地方发展
# Install dependencies
npm install
# Build the project
npm run build
# Start local development server (with remote KV)
npx wrangler dev
# Start local development server (with local KV for testing)
npx wrangler dev --local
# Deploy to preview environment
npx wrangler deploy --env preview
测试
# Test the build
npm run build
# Test deployment (dry run - shows what would be deployed)
npx wrangler deploy --dry-run
# Run local tests
npm test # If you add tests
# Test with local KV storage
npx wrangler dev --local
调试
查看实时日志:
# Tail logs from deployed worker
npx wrangler tail
# Tail logs with filtering
npx wrangler tail --format pretty
KV数据管理
# List all keys in your KV namespace
npx wrangler kv:key list --binding TASKMANAGER_KV
# Get a specific key value
npx wrangler kv:key get "tasks" --binding TASKMANAGER_KV
# Delete all data (be careful!)
npx wrangler kv:key delete "tasks" --binding TASKMANAGER_KV
🏗️ 建筑
MCP任务管理器是作为Cloudflare Worker构建的,具有以下组件:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ AI Assistant │───▶│ Cloudflare │───▶│ Cloudflare KV │
│ (Claude, etc) │ │ Worker │ │ Storage │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────┐
│ TaskManagerServer│
│ (Business Logic) │
└──────────────────┘
组件
- TaskManagerServer类:任务管理的核心业务逻辑
- 工人接口:MCP协议通信的HTTP端点
- Cloudflare KV存储:任务和请求的持久数据存储
- MCP协议:用于AI辅助集成的标准模型上下文协议
- CORS支持:启用web应用程序集成
益处
- 全球边缘部署:通过Cloudflare网络实现全球低延迟
- 无服务器:无服务器管理,自动扩展
- 永久存储:数据在部署过程中得以保存
- 成本效益高:Cloudflare慷慨的免费套餐
- 高可用性:内置冗余和故障切换
📈 监控和日志
Cloudflare仪表板
在Cloudflare仪表板中查看日志和指标:
- 首选 Cloudflare仪表板
- 导航到工作人员和页面
- 选择您的
mcp-taskmanager工人 - 查看日志、指标和分析
实时监控
# View live logs
npx wrangler tail
# View formatted logs
npx wrangler tail --format pretty
# Filter logs by status
npx wrangler tail --status error
需监控的关键指标
- 请求量:API调用数
- 响应时间:操作延迟
- 错误率:失败的请求及其原因
- KV操作:存储读/写性能
- 内存使用:工作内存消耗
常见问题排查
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 500内部服务器错误 | 找不到KV命名空间 | 检查wrangler.toml中的KV命名空间ID |
| CORS错误 | 缺少标头 | 验证worker.ts中的CORS标头 |
| 找不到任务 | 任务/请求ID无效 | 检查ID格式和是否存在 |
| 构建失败 | TypeScript错误 | 运行 npm run build 本地优先 |
🤝 贡献
我们欢迎捐款!以下是如何开始:
开发设置
- 分叉存储库
- 克隆你的叉子:
git clone https://github.com/your-username/mcp-taskmanager.git - 创建要素分支:
git checkout -b feature/amazing-feature - 安装依赖项:
npm install - 进行更改
- 本地测试:
npx wrangler dev --local - 构建和测试:
npm run build
贡献指南
- 遵循TypeScript的最佳实践
- 为新功能添加测试
- 更新API变更文档
- 使用常规提交消息
- 提交前确保所有测试通过
拉取请求流程
- 提交您的更改:
git commit -m 'Add amazing feature' - 推到您的分支:
git push origin feature/amazing-feature - 使用以下命令打开拉取请求:
- 变更的清晰描述
- 屏幕截图/示例(如适用)
- 参考任何相关问题
贡献领域
- 🐛 Bug修复和改进
- 📚 文档增强
- ✨ 新的MCP工具和功能
- 🧪 测试覆盖率提高
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
💬 支持
获取帮助
社区资源
- MCP文件: 模型上下文协议
- Cloudflare员工文档: 了解有关Workers的更多信息
报告问题
报告错误时,请包括:
- 您的Cloudflare工作URL
- 重现问题的步骤
- 预期行为与实际行为
- 错误消息或日志
- 浏览器/客户端信息
🙏 致谢
- 与 模型上下文协议SDK
- 由...驱动 Cloudflare员工
- 专为无缝集成AI助手而设计
- 受人工智能工作流程中更好的任务管理需求的启发
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
由以下材料制成❤️ 对于AI社区
部署您自己的实例,并开始使用AI助手高效管理任务!