tasks.py•2.58 kB
from mcp.server.fastmcp import FastMCP
def create_tasks_prompts(mcp: FastMCP) -> None:
@mcp.prompt("tasks:list")
async def tasks_list_prompt() -> dict:
"""Prompt to list tasks."""
return {
"role": "user",
"content": "List all tasks with their IDs, titles, descriptions, statuses, and creation dates.",
}
@mcp.prompt("tasks:get")
async def get_task_prompt(task_id: int) -> dict:
"""Prompt to get a task by ID."""
return {
"role": "user",
"content": f"Get the details of a task by its ID: {task_id}.",
}
@mcp.prompt("tasks:add")
async def add_task_prompt(title: str, description: str = "") -> dict:
"""Prompt to add a new task."""
return {
"role": "user",
"content": f"Add a new task with the title: {title} and description: {description}.",
}
@mcp.prompt("tasks:update")
async def update_task_prompt(
task_id: int, title: str, description: str, status: int
) -> dict:
"""Prompt to update an existing task."""
parts = []
if title is not None:
parts.append(f"title: {title}")
if description is not None:
parts.append(f"description: {description}")
if status is not None:
parts.append(f"status: {status}")
fields = ", ".join(parts)
return {
"role": "user",
"content": f"Update the task with ID: {task_id} to have the following fields: {fields}.",
}
@mcp.prompt("tasks:delete")
async def delete_task_prompt(task_id: int) -> dict:
"""Prompt to delete a task by ID."""
return {"role": "user", "content": f"Delete the task with ID: {task_id}."}
@mcp.prompt("tasks:filter")
async def filter_tasks_prompt(
status: int,
title: str = "",
description: str = "",
created_at: str = "",
limit: int = 20,
) -> dict:
"""Prompt to filter tasks by status and title."""
parts = [f"status: {status}"]
if title:
parts.append(f"title contains: '{title}'")
if description:
parts.append(f"description contains: '{description}'")
if created_at:
parts.append(f"created at contains: '{created_at}'")
if limit:
parts.append(f"limit: {limit}")
criteria = ", ".join(parts)
return {
"role": "user",
"content": f"Filter tasks with the following criteria: {criteria}.",
}