AgentSkillsCN

todo-ai-mcp-agent

利用自然语言通过 MCP 工具实现 AI 驱动的待办事项管理。适用于构建对话式待办事项代理、实现自然语言任务管理、设计用于待办事项应用的 AI 助手,或创建基于 MCP 的工具集成时使用。涵盖意图理解、安全调用工具,以及无状态代理的设计。

SKILL.md
--- frontmatter
name: todo-ai-mcp-agent
description: Enable AI-driven Todo management using natural language via MCP tools. Use when building conversational todo agents, implementing natural language task management, designing AI assistants for todo apps, or creating MCP-based tool integrations. Covers intent interpretation, safe tool invocation, and stateless agent design.

Todo AI MCP Agent

Build AI agents that manage todos through natural language while maintaining safety and reliability.

Core Principles

  1. No hallucinated actions - Only act on data from MCP tool results
  2. Database-backed memory - Never cache state; always fetch fresh
  3. Clear tool invocation - Every action maps to explicit MCP tool call
  4. Stateless server - Session context only; no persistent agent state

Agent Flow

code
User Input
    │
    ▼
┌─────────────────┐
│ Parse Intent    │ ← "Add buy milk" → intent: create, title: "buy milk"
└─────────────────┘
    │
    ▼
┌─────────────────┐
│ Validate/Clarify│ ← Ambiguous? Ask user
└─────────────────┘
    │
    ▼
┌─────────────────┐
│ Invoke MCP Tool │ ← todos.create({title: "buy milk"})
└─────────────────┘
    │
    ▼
┌─────────────────┐
│ Format Response │ ← "Created 'buy milk'"
└─────────────────┘

Intent to Tool Mapping

User SaysIntentMCP Tool Call
"Add buy groceries"createtodos.create({title: "buy groceries"})
"Show my tasks"listtodos.list({})
"Mark task 3 as done"completetodos.update({id: 3, status: "completed"})
"Delete the milk task"deletetodos.list({search: "milk"})todos.delete({id: X})
"What's urgent?"filtertodos.list({priority: "high"})

MCP Tools

todos.list

json
{
  "status": "pending|completed|archived",
  "priority": "low|medium|high",
  "search": "text to match",
  "limit": 20
}

todos.create

json
{
  "title": "required string",
  "description": "optional",
  "priority": "low|medium|high",
  "due_date": "ISO 8601 datetime"
}

todos.update

json
{
  "id": "required integer",
  "title": "optional new title",
  "status": "pending|completed|archived",
  "priority": "low|medium|high"
}

todos.delete

json
{
  "id": "required integer"
}

Safety Rules

Never Invent Data

python
# WRONG - Making up todos
"You have: buy milk, call mom"  # Hallucinated!

# RIGHT - Use tool result
result = await mcp.call_tool("todos.list", {})
response = format_todos(result)  # From actual data

Always Verify Before Acting

python
# WRONG - Assuming ID
await mcp.call_tool("todos.delete", {"id": 1})

# RIGHT - Search first
todos = await mcp.call_tool("todos.list", {"search": "milk"})
if len(todos) == 1:
    await mcp.call_tool("todos.delete", {"id": todos[0]["id"]})
elif len(todos) > 1:
    ask_user_to_clarify(todos)
else:
    report_not_found()

Confirm Destructive Actions

python
NEEDS_CONFIRMATION = ["delete", "bulk_delete", "clear_all"]

if action in NEEDS_CONFIRMATION:
    return f"Delete '{todo.title}'? This cannot be undone. (yes/no)"

Handling Ambiguity

Reference Resolution

User SaysResolution Strategy
"the first one"Use last listed todos, get index 0
"it" / "that"Use last referenced todo from context
"the grocery one"Search, if 1 match use it, else clarify
"all of them"Confirm bulk action first

Clarification Pattern

python
if matches == 0:
    "I couldn't find a todo matching 'X'. Show your list?"
elif matches > 1:
    "Found {n} todos matching 'X'. Which one?\n{list}"
else:
    proceed_with_action()

Response Patterns

Successful Actions

code
Created: "Created 'buy milk'"
Listed:  "You have 3 todos:\n- buy milk\n- call mom\n- finish report"
Updated: "Marked 'buy milk' as complete"
Deleted: "Deleted 'buy milk'"

Errors

code
Not found:  "I couldn't find that todo. Would you like to see your list?"
Validation: "Title can't be empty. What should I call this todo?"
Conflict:   "That todo was just modified. Current status: completed"

Session Context (Non-Persistent)

python
class SessionContext:
    last_listed_todos: list[Todo]  # For "the first one"
    last_referenced_todo: Todo     # For "it" / "that"
    pending_confirmation: Action   # Awaiting yes/no

# Lives only in session memory
# NOT stored in database
# Expires with conversation

Multi-Action Handling

User: "Add buy milk and complete the groceries task"

python
# Parse multiple intents
intents = [
    {"action": "create", "title": "buy milk"},
    {"action": "complete", "search": "groceries"},
]

# Execute sequentially
results = []
for intent in intents:
    result = await execute_intent(intent)
    results.append(result)

# Compose response
"Created 'buy milk' and completed 'groceries'"

References