Skip to main content
Glama

task_get

Retrieve a complete task record with all subtasks, notes, comments, and dependencies for detailed project tracking in structured databases.

Instructions

Get a single task with full details including all subtasks, related notes, comments, and dependencies.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesTask ID

Implementation Reference

  • The handler function that executes the logic for fetching a task and its related data (subtasks, notes, comments, dependencies).
    function handleTaskGet(args: Record<string, unknown>) {
      const db = getDb();
      const id = args.id as number;
    
      const task = db
        .prepare(
          `SELECT t.*, e.name as epic_name
           FROM tasks t
           JOIN epics e ON e.id = t.epic_id
           WHERE t.id = ?`
        )
        .get(id);
    
      if (!task) throw new Error(`Task ${id} not found`);
    
      const subtasks = db
        .prepare('SELECT * FROM subtasks WHERE task_id = ? ORDER BY sort_order, created_at')
        .all(id);
    
      const notes = db
        .prepare(
          `SELECT * FROM notes
           WHERE related_entity_type = 'task' AND related_entity_id = ?
           ORDER BY created_at DESC`
        )
        .all(id);
    
      const comments = db
        .prepare('SELECT * FROM comments WHERE task_id = ? ORDER BY created_at ASC')
        .all(id);
    
      // Dependencies: what this task depends on
      const dependsOn = db
        .prepare(
          `SELECT t.id, t.title, t.status FROM task_dependencies d
           JOIN tasks t ON t.id = d.depends_on_task_id
           WHERE d.task_id = ?`
        )
        .all(id);
    
      // Dependents: what tasks depend on this task
      const dependents = db
        .prepare(
          `SELECT t.id, t.title, t.status FROM task_dependencies d
           JOIN tasks t ON t.id = d.task_id
           WHERE d.depends_on_task_id = ?`
        )
        .all(id);
    
      return { ...(task as object), subtasks, notes, comments, depends_on: dependsOn, dependents };
    }
    
    function handleTaskUpdate(args: Record<string, unknown>) {
      const db = getDb();
      const id = args.id as number;
    
      const oldRow = db.prepare('SELECT * FROM tasks WHERE id = ?').get(id) as Record<string, unknown> | undefined;
      if (!oldRow) throw new Error(`Task ${id} not found`);
  • The input schema definition for the task_get tool.
    inputSchema: {
      type: 'object',
      properties: {
        id: { type: 'integer', description: 'Task ID' },
      },
      required: ['id'],
    },
  • The registration of the task_get tool handler within the tool mapping.
    task_get: handleTaskGet,

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/spranab/saga-mcp'

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