Skip to main content
Glama
108yen

task-orchestrator-mcp

by 108yen

getTask

Retrieve a specific task by its ID from the task orchestration server to view details or manage workflow.

Instructions

Get a task by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesTask ID

Implementation Reference

  • src/tools.ts:117-159 (registration)
    Registration of the MCP 'getTask' tool using server.registerTool. Defines the tool name, description, input schema requiring a task ID string, and a handler function that calls the underlying getTask implementation, formats the response as JSON, and handles errors.
    // Register getTask tool
    server.registerTool(
      "getTask",
      {
        description: "Get a task by its ID",
        inputSchema: {
          id: z.string().describe("Task ID"),
        },
      },
      (args) => {
        try {
          const task = getTask(args.id)
          return {
            content: [
              {
                text: JSON.stringify({ task }, null, 2),
                type: "text",
              },
            ],
          }
        } catch (error) {
          return {
            content: [
              {
                text: JSON.stringify(
                  {
                    error: {
                      code: "TASK_NOT_FOUND",
                      message:
                        error instanceof Error ? error.message : "Unknown error",
                    },
                  },
                  null,
                  2,
                ),
                type: "text",
              },
            ],
            isError: true,
          }
        }
      },
    )
  • Core handler function for retrieving a task by ID. Validates input, loads all tasks from storage, searches recursively using findTaskById, throws appropriate errors if invalid ID or not found, returns the Task object.
    export function getTask(id: string): Task {
      if (!id || typeof id !== "string") {
        throw new Error(ERROR_MESSAGES.INVALID_TASK_ID)
      }
    
      const tasks = readTasks()
      const task = findTaskById(tasks, id)
    
      if (!task) {
        throw new Error(ERROR_MESSAGES.TASK_NOT_FOUND(id))
      }
    
      return task
    }
  • Input schema definition for the getTask tool using Zod: requires 'id' as a string with description.
    {
      description: "Get a task by its ID",
      inputSchema: {
        id: z.string().describe("Task ID"),
      },
    },
  • Recursive helper function to find a task by ID in the nested task hierarchy.
    export function findTaskById(tasks: Task[], id: string): Task | undefined {
      for (const task of tasks) {
        if (task.id === id) {
          return task
        }
        const found = findTaskById(task.tasks, id)
        if (found) {
          return found
        }
      }
      return undefined
    }

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/108yen/task-orchestrator-mcp'

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