Skip to main content
Glama
MxrxnxX

Servidor MCP de tareas

by MxrxnxX

任务MCP服务器

编程IV课外作业1项目。实现了一个模型上下文协议(MCP)服务器,用于在本地JSON文件中管理任务,并公开了一个资源、两个工具和一个提示词。

功能

  • 资源 tasks://pending:仅返回未完成的任务。

  • 工具 add_task:添加包含名称、描述和优先级(alta、media 或 baja)的任务。

  • 工具 complete_task:按ID将现有任务标记为已完成。

  • 提示词 daily_summary:使用当前状态构建模板以生成每日摘要。

该服务器使用stdio传输。主机或客户端将其作为子进程启动,MCP消息通过stdin和stdout传输。

Related MCP server: TaskTrek MCP Server

要求

  • Python 3.11或更高版本。

  • 可访问终端。

  • Claude Desktop、MCP Inspector或其他兼容的MCP客户端以进行集成。

安装

Windows(PowerShell)

cd C:\RUTA\mcp-todo-server
py -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt

macOS或Linux

cd /RUTA/mcp-todo-server
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

运行

stdio服务器等待客户端发送第一条消息;因此,直接运行时不会打印菜单或打开端口:

python server.py

使用Ctrl+C停止。

演示客户端

client_demo.py是使用官方SDK构建的兼容MCP的客户端。它通过stdio连接,发现功能并执行练习中要求的所有操作:

python client_demo.py --reset

要保存UTF-8转录:

python client_demo.py --reset --output evidence/client_demo_output.txt

--reset选项在测试前恢复两条初始记录。演示会查询资源、添加两个任务、完成一个任务、获取提示词并再次查询资源。

自动化测试

python -m pytest -q

该测试套件验证:

  1. 资源、工具和提示词的发现。

  2. 仅读取待处理任务。

  3. 任务的创建和完成。

  4. daily_summary的动态内容。

  5. 完成不存在的ID时错误处理。

MCP Inspector

安装Node.js后,可以打开官方界面:

npx @modelcontextprotocol/inspector .venv/Scripts/python.exe server.py

在macOS或Linux中,将可执行文件替换为.venv/bin/python。

Claude Desktop配置

  1. 打开claude_desktop_config.example.json。

  2. 将C:\\RUTA\\mcp-todo-server替换为项目的绝对路径。

  3. 将mcpServers条目复制到Claude Desktop的配置文件中。在Windows中通常位于: %APPDATA%\Claude\claude_desktop_config.json。

  4. 完全关闭Claude Desktop并重新打开。

示例:

{
  "mcpServers": {
    "todo-server": {
      "command": "C:\\RUTA\\mcp-todo-server\\.venv\\Scripts\\python.exe",
      "args": ["C:\\RUTA\\mcp-todo-server\\server.py"]
    }
  }
}

不要使用相对路径:主机可能从其他目录启动服务器。

结构

mcp-todo-server/
  server.py
  client_demo.py
  tasks.json
  requirements.txt
  claude_desktop_config.example.json
  tests/
    test_server.py
  diagramas/
    arquitectura_mcp_ecommerce.mmd
    flujo_consulta_inventario.mmd
  evidence/
    client_demo_output.txt
    01_inspector_connected.png
    02_add_task_result.png
    03_complete_task_result.png
    04_resource_pending.png
    05_daily_summary_prompt.png

发布到Git

git init
git add .
git commit -m "Implementar servidor MCP de tareas"
git branch -M main
git remote add origin URL_DEL_REPOSITORIO
git push -u origin main

最终仓库URL必须在提交前添加到报告中。

技术参考

Maintenance

ActivitySlowing
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    A minimal Model Context Protocol server implementation that provides tools for managing a to-do list, allowing users to create tasks, list them, and mark them as completed via JSON-RPC calls.
    -
  • F
    license
    Not graded
    quality
    B
    maintenance
    A lightweight task management MCP server that enables CRUD operations on tasks stored in a single JSON file, including listing, creating, updating progress, and setting priorities.
    200 npm
    -