Skip to main content
Glama
aafsar

Task Manager MCP Server

by aafsar

list_tasks

Retrieve tasks from the Task Manager MCP Server with filters for status, priority, and category to organize and track workflow.

Instructions

List tasks with optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusNoFilter by statusall
priorityNoFilter by priorityall
categoryNoFilter by category

Implementation Reference

  • The handler function that executes the list_tasks tool logic: validates input, loads and filters tasks, sorts them, formats output with summary, and returns MCP content.
    export async function listTasks(args: unknown) {
      // Validate input
      const validated = ListTasksSchema.parse(args || {});
    
      // Load tasks
      const storage = await loadTasks();
      let tasks = [...storage.tasks];
    
      // Apply filters
      if (validated.status !== "all") {
        tasks = tasks.filter((t) => t.status === validated.status);
      }
      if (validated.priority !== "all") {
        tasks = tasks.filter((t) => t.priority === validated.priority);
      }
      if (validated.category) {
        tasks = tasks.filter(
          (t) => t.category?.toLowerCase() === validated.category?.toLowerCase()
        );
      }
    
      if (tasks.length === 0) {
        return {
          content: [
            {
              type: "text",
              text: "No tasks found matching the criteria.",
            },
          ],
        };
      }
    
      // Sort by priority and due date
      const priorityOrder: Record<Priority, number> = {
        high: 0,
        medium: 1,
        low: 2,
      };
    
      tasks.sort((a, b) => {
        const priorityDiff = priorityOrder[a.priority] - priorityOrder[b.priority];
        if (priorityDiff !== 0) return priorityDiff;
    
        const aDate = a.dueDate || "9999-99-99";
        const bDate = b.dueDate || "9999-99-99";
        return aDate.localeCompare(bDate);
      });
    
      // Format output
      let result = `šŸ“‹ Found ${tasks.length} task(s):\n\n`;
      tasks.forEach((task) => {
        result += formatTask(task) + "\n";
      });
    
      // Add summary
      const pending = storage.tasks.filter((t) => t.status === "pending").length;
      const inProgress = storage.tasks.filter(
        (t) => t.status === "in_progress"
      ).length;
      const completed = storage.tasks.filter((t) => t.status === "completed").length;
    
      result += `\nšŸ“Š Summary: ${pending} pending | ${inProgress} in progress | ${completed} completed`;
    
      return {
        content: [
          {
            type: "text",
            text: result,
          },
        ],
      };
    }
  • Zod schema used for input validation in the listTasks handler.
    export const ListTasksSchema = z.object({
      status: z
        .enum(["pending", "in_progress", "completed", "all"])
        .default("all"),
      priority: z.enum(["low", "medium", "high", "all"]).default("all"),
      category: z.string().optional(),
    });
  • src/index.ts:59-83 (registration)
    Tool registration in the TOOLS array returned by listTools, including name, description, and inputSchema.
    {
      name: "list_tasks",
      description: "List tasks with optional filters",
      inputSchema: {
        type: "object",
        properties: {
          status: {
            type: "string",
            enum: ["pending", "in_progress", "completed", "all"],
            default: "all",
            description: "Filter by status",
          },
          priority: {
            type: "string",
            enum: ["low", "medium", "high", "all"],
            default: "all",
            description: "Filter by priority",
          },
          category: {
            type: "string",
            description: "Filter by category",
          },
        },
      },
    },
  • src/index.ts:218-219 (registration)
    Dispatch to the listTasks handler in the CallToolRequest switch statement.
    case "list_tasks":
      return await listTasks(args);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aafsar/task-manager-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server