使用说明
TaskTracker MCP服务器
使用构建的任务管理服务器 FastMCP 以及Python 3.14,通过 模型上下文协议(MCP).
什么是MCP?
这 模型上下文协议 是一个开放标准,允许人工智能助手(如Claude)连接到外部工具和数据源。该服务器实现了MCP,使任何兼容的AI客户端都能够通过简单、定义良好的界面管理任务。
特性
| 类别 | 名称 | 描述 |
|---|---|---|
| 工具 | add_task |
创建一个带有标题和描述的新任务 |
| 工具 | complete_task |
将任务标记为已完成 |
| 工具 | delete_task |
永久删除任务 |
| 资源 | tasks://all |
列出所有任务(待处理+已完成) |
| 资源 | task://pending |
仅列出待处理的任务 |
| 提示 | task_summary |
生成任务列表的结构化分析 |
技术栈
- python 3.14
- FastMCP 3.x-MCP服务器框架
- aiosqlite --异步SQLite持久化
- pytest --单元和集成测试
- 颈毛 --linting和格式化
- 紫外线 --包装与环境管理
项目结构
.
├── server/
│ ├── task_server.py # FastMCP instance + tool/resource/prompt registration
│ ├── db.py # Async SQLite layer (init, insert, update, delete)
│ ├── tools/
│ │ └── tools.py # Tool functions: add_tool, complete_task, delete_task
│ ├── resources/
│ │ └── resources.py # Resource functions: get_all_tasks, get_pending_tasks
│ └── tests/
│ └── test_main.py # Unit tests for tools and resources
├── client/
│ ├── test_client.py # Manual smoke-test script using FastMCP Client
│ └── tests/
│ └── test_client.py # Integration tests via FastMCP Client (anyio)
├── pyproject.toml
└── README.md
入门指南
先决条件
- Python 3.14+
uv包管理器
安装
git clone https://github.com/hlruffo/simple_mcp_server.git
cd simple_mcp_server
uv sync --all-extras --dev
运行服务器
uv run --directory server server/task_server.py
运行测试
# All tests
uv run pytest
# Server unit tests only (verbose)
uv run pytest server/tests/ -v
# Client integration tests only (verbose)
uv run pytest client/tests/ -v
# Single test
uv run pytest server/tests/test_main.py::TestAddTool::test_retorna_campos_corretos
这 客户端集成测试 (client/tests/test_client.py)通过以下方式启动一个完整的进程内FastMCP服务器 mcp_server 夹具并通过 fastmcp.Client 使用异步API @pytest.mark.anyio.
要运行 手动烟雾测试 针对实时服务器:
uv run python client/test_client.py
代码检查
# Check
uv run ruff check .
# Auto-fix
uv run ruff check . --fix
运作原理
AI Client (e.g. Claude)
│
│ MCP protocol
▼
task_server.py
┌─────────────────────────────────┐
│ Tools Resources Prompt │
│ ──────── ───────── ────── │
│ add_task tasks://all │
│ complete task://pending │
│ delete task_summary │
└──────────────┬──────────────────┘
│ async SQLite
▼
tasks.db (local)
FastMCP实例将普通Python函数注册为工具和资源——工具/资源模块本身不需要装饰器,保持了业务逻辑的干净性和可独立测试性。
添加新工具
- 在中定义一个普通函数
server/tools/tools.py - 在中注册
server/task_server.py:mcp.tool()(my_new_function) - 在中添加测试
server/tests/test_main.py
许可证
麻省理工学院
