todo-mcp-server
A simple MCP server for managing a todo list — add tasks, list tasks, and mark tasks complete. Built with the Python MCP SDK (FastMCP) as a hands-on learning project.
README
Todo MCP Server
A robust, persistent task management server built on the Model Context Protocol (MCP) using Python and FastMCP.
Overview
The Todo MCP Server provides language models and AI agents with a persistent, stateful task management interface. Built using the official Python MCP SDK (FastMCP), it exposes tools that allow AI assistants to create, track, filter, and complete tasks directly within their workflow.
State is persisted locally to structured JSON storage (tasks.json), ensuring task data survives server restarts, client reconnections, and multi-turn agent sessions. Communication follows the MCP specification using JSON-RPC 2.0 over standard input/output (stdio).
Architecture & Data Flow
+-------------------------------------------------------------------+
| MCP Host / AI Client |
| (Claude Desktop, Cursor, Antigravity) |
+-------------------------------------------------------------------+
|
JSON-RPC 2.0 over stdin / stdout
v
+-------------------------------------------------------------------+
| Todo MCP Server |
| |
| +-----------------------------------------------------------+ |
| | FastMCP Engine | |
| | - Protocol negotiation & schema reflection | |
| | - Tool dispatch & argument validation (Pydantic/Typing) | |
| +-----------------------------------------------------------+ |
| | |
| +-----------------------------+-----------------------------+ |
| | | | |
| v v v |
| [ add_task ] [ list_tasks ] [ complete_task ]
| | | | |
| +-----------------------------+-----------------------------+ |
| | |
| v |
| +-----------------------------------------------------------+ |
| | Storage Controller | |
| | - Atomic read/write operations | |
| | - Schema serialization with ISO 8601 UTC timestamps | |
| +-----------------------------------------------------------+ |
+-------------------------------------------------------------------+
|
v
+-------------------------------------------------------------------+
| Local Storage: tasks.json |
+-------------------------------------------------------------------+
Tools Reference
The server exposes three distinct tools for full task lifecycle management.
1. add_task
Creates a new task item and appends it to persistent storage.
- Description: Add a new task to the todo list.
- Parameters:
title(string, required): Description of the task. Length must be between 1 and 200 characters.priority(string, optional): Urgency level. Accepted values:"low","medium","high". Default:"medium".
- Validation Rules:
- Empty or whitespace-only strings are rejected.
- Titles exceeding 200 characters return an error.
- Non-conforming priority values fail schema validation.
Example Request:
{
"title": "Implement integration test suite",
"priority": "high"
}
Example Response:
Task added!
ID: 1
Title: Implement integration test suite
Priority: high
Status: pending
2. list_tasks
Retrieves saved tasks with optional filtering by completion status.
- Description: List tasks from the todo list with optional status filtering.
- Parameters:
status(string, optional): Filter criteria. Accepted values:"all","pending","done". Default:"all".
- Formatting: Returns a formatted ASCII table summarizing task IDs, status indicators, priority levels, and titles.
Example Request:
{
"status": "pending"
}
Example Response:
Tasks (pending) — 2 found:
ID Status Priority Title
———— ————————— ———————— ————————————————————————————————————————
1 pending high Implement integration test suite
2 pending medium Update project documentation
3. complete_task
Marks an existing task as completed by its unique integer identifier.
- Description: Mark a task as done by its numeric ID.
- Parameters:
task_id(integer, required): The unique numeric identifier assigned to the task.
- Behavior:
- Updates the task status to
"done". - Sets the
completed_atfield to the current ISO 8601 UTC timestamp. - Idempotent: If the task is already completed, the tool notifies the client without corrupting timestamps.
- If the ID does not exist, an error response is returned with the list of currently valid IDs.
- Updates the task status to
Example Request:
{
"task_id": 1
}
Example Response:
Task 1 completed!
Title: Implement integration test suite
Completed at: 2026-08-20T09:46:17.466797+00:00
Tool Summary Table
| Tool | Purpose | Parameters | Return Type |
|---|---|---|---|
add_task |
Create a new task | title (str, required)<br>priority ("low" | "medium" | "high", default: "medium") |
string (Confirmation details) |
list_tasks |
Query stored tasks | status ("all" | "pending" | "done", default: "all") |
string (Formatted table) |
complete_task |
Mark a task as completed | task_id (int, required) |
string (Completion status & timestamp) |
Data Model & Persistence
Task records are serialized as UTF-8 encoded JSON arrays. By default, records are stored in tasks.json in the current working directory. The storage file path can be customized via the TODO_FILE environment variable.
Schema Definition
[
{
"id": 1,
"title": "Implement integration test suite",
"priority": "high",
"status": "done",
"created_at": "2026-08-20T09:46:17.362387+00:00",
"completed_at": "2026-08-20T09:46:17.466797+00:00"
},
{
"id": 2,
"title": "Update project documentation",
"priority": "medium",
"status": "pending",
"created_at": "2026-08-20T09:46:17.384689+00:00",
"completed_at": null
}
]
Field Specifications
id(integer): Auto-incrementing positive integer identifier.title(string): Task description string (1-200 chars).priority(string): Urgency classification ("low","medium","high").status(string): Lifecycle stage ("pending"or"done").created_at(string): ISO 8601 formatted UTC timestamp recorded at creation.completed_at(string | null): ISO 8601 formatted UTC timestamp recorded upon completion.
Requirements
- Python: Version 3.10 or higher
- Dependencies:
mcp[cli]>=1.28,<2
Installation & Setup
1. Clone the Repository
git clone https://github.com/moazhassan751/mcp-todo-server.git
cd mcp-todo-server
2. Create a Virtual Environment
# Linux/macOS
python3 -m venv .venv
source .venv/bin/activate
# Windows
python -m venv .venv
.venv\Scripts\activate
3. Install Dependencies
pip install -r requirements.txt
Execution Modes
Standard Execution (stdio)
Run the server directly for production or MCP host integration:
python server.py
Developer Inspection (MCP Inspector)
The MCP Inspector provides an interactive browser-based interface to test tools, inspect schemas, and simulate requests:
mcp dev server.py
The inspector will launch and provide a local interface URL (typically http://localhost:6274).
Client Integration Guide
To connect the Todo MCP Server to your preferred AI environment, configure the server in your client's MCP configuration file.
Claude Desktop
Edit your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"todo-server": {
"command": "python",
"args": ["/absolute/path/to/mcp-todo-server/server.py"]
}
}
}
Cursor
Add to .cursor/mcp.json in your project or global directory:
{
"mcpServers": {
"todo-server": {
"command": "python",
"args": ["/absolute/path/to/mcp-todo-server/server.py"]
}
}
}
Antigravity IDE
Add to .agents/mcp_config.json in your workspace:
{
"mcpServers": {
"todo-server": {
"command": "python",
"args": ["/absolute/path/to/mcp-todo-server/server.py"]
}
}
}
Testing & Verification
The repository includes comprehensive automated test scripts:
Standard Test Suite
Tests basic tool calls, parameter validations, and output formatting:
python test_server.py
Multi-Session Audit Test
Simulates separate client connections, restarts the server process across sessions, and validates that persistent storage correctly retains state:
python audit_test.py
Project Structure
mcp-todo-server/
├── server.py # Core MCP server definition and tool implementations
├── test_server.py # Automated stdio protocol unit tests
├── audit_test.py # Multi-session persistence and edge-case verification
├── requirements.txt # Package dependencies
├── .gitignore # Version control ignore definitions
└── README.md # Technical documentation and integration reference
License
This project is open source and available under the MIT License.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。