Skip to main content
Glama
aafsar

Task Manager MCP Server

by aafsar

get_task_stats

Retrieve comprehensive statistics about all tasks to analyze workload, track progress, and monitor task management metrics.

Instructions

Get statistics about all tasks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main execution logic for the 'get_task_stats' tool. Loads tasks from storage, computes comprehensive statistics (total, by status, priority, categories, overdue, due soon, completion rate), and returns a formatted markdown-like text response.
    export async function getTaskStats() { const storage = await loadTasks(); const tasks = storage.tasks; if (tasks.length === 0) { return { content: [ { type: "text", text: "No tasks yet. Create your first task to get started!", }, ], }; } // Calculate statistics const total = tasks.length; const byStatus = { pending: tasks.filter((t) => t.status === "pending").length, in_progress: tasks.filter((t) => t.status === "in_progress").length, completed: tasks.filter((t) => t.status === "completed").length, }; const byPriority = { high: tasks.filter((t) => t.priority === "high").length, medium: tasks.filter((t) => t.priority === "medium").length, low: tasks.filter((t) => t.priority === "low").length, }; // Category counts const categories = new Map<string, number>(); tasks.forEach((t) => { if (t.category) { categories.set(t.category, (categories.get(t.category) || 0) + 1); } }); // Check for overdue and upcoming tasks const today = new Date().toISOString().split("T")[0]!; const oneWeekFromNow = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000) .toISOString() .split("T")[0]!; const overdue = tasks.filter( (t) => t.status !== "completed" && t.dueDate && t.dueDate < today ).length; const dueSoon = tasks.filter( (t) => t.status !== "completed" && t.dueDate && t.dueDate >= today && t.dueDate <= oneWeekFromNow ).length; const completionRate = total > 0 ? ((byStatus.completed / total) * 100).toFixed(1) : "0"; // Format output let result = "πŸ“Š Task Manager Statistics\n"; result += "=".repeat(30) + "\n\n"; result += `πŸ“ˆ Total Tasks: ${total}\n`; result += `βœ… Completion Rate: ${completionRate}%\n\n`; result += "Status Breakdown:\n"; result += ` πŸ“‹ Pending: ${byStatus.pending}\n`; result += ` ⏳ In Progress: ${byStatus.in_progress}\n`; result += ` βœ… Completed: ${byStatus.completed}\n\n`; result += "Priority Breakdown:\n"; result += ` πŸ”΄ High: ${byPriority.high}\n`; result += ` 🟑 Medium: ${byPriority.medium}\n`; result += ` 🟒 Low: ${byPriority.low}\n`; if (categories.size > 0) { result += "\nCategories:\n"; Array.from(categories.entries()) .sort((a, b) => a[0].localeCompare(b[0])) .forEach(([cat, count]) => { result += ` πŸ“ ${cat}: ${count}\n`; }); } if (overdue > 0) { result += `\n⚠️ Overdue Tasks: ${overdue}\n`; } if (dueSoon > 0) { result += `πŸ“… Due Within 7 Days: ${dueSoon}\n`; } return { content: [ { type: "text", text: result, }, ], }; }
  • JSON Schema definition for the tool in the TOOLS array, specifying name, description, and empty input schema (no parameters required).
    { name: "get_task_stats", description: "Get statistics about all tasks", inputSchema: { type: "object", properties: {}, }, },
  • src/index.ts:233-234 (registration)
    Registration in the tool dispatch switch statement within the CallToolRequestSchema handler, mapping the tool name to the getTaskStats function call.
    case "get_task_stats": return await getTaskStats();
  • src/index.ts:19-19 (registration)
    Import of the getTaskStats handler function from './tools.js'.
    getTaskStats,

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