Skip to main content
Glama

get_task_result

Retrieve the final output of a completed AI task by providing its task ID. Designed for managing asynchronous workflows on the MCP Task server.

Instructions

Get the final result of a completed task.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYesThe task ID returned from run_task

Implementation Reference

  • The main handler logic for the 'get_task_result' tool. It validates the task_id, retrieves the task using TaskManager.getTask(), checks if it's completed/failed/cancelled, and returns the task.output.
    case 'get_task_result': { if (!args.task_id) { throw new Error('task_id is required'); } const task = taskManager.getTask(args.task_id); if (!task) { throw new Error(`Task ${args.task_id} not found`); } if ( task.status !== 'completed' && task.status !== 'failed' && task.status !== 'cancelled' ) { throw new Error( `Task ${args.task_id} is not complete. Status: ${task.status}` ); } return { content: [ { type: 'text', text: task.output || 'No output available', }, ], }; }
  • The Tool schema definition including name, description, annotations, and inputSchema for 'get_task_result'.
    const GET_TASK_RESULT_TOOL: Tool = { name: 'get_task_result', description: 'Get the final result of a completed task.', annotations: { title: 'Get Task Result', readOnlyHint: true, // Only reads completed task result destructiveHint: false, // Doesn't modify or destroy data idempotentHint: false, // task_id returns result each time openWorldHint: false, // Only queries local task state }, inputSchema: { type: 'object', properties: { task_id: { type: 'string', description: 'The task ID returned from run_task', }, }, required: ['task_id'], }, };
  • src/serve.ts:558-579 (registration)
    Registration of the tool via the ListToolsRequestSchema handler, which returns the list of available tools including 'get_task_result'.
    server.setRequestHandler(ListToolsRequestSchema, async () => { if (process.env.MCP_MODE !== 'true') { logger.debug('Received ListTools request'); } const response = { tools: [ RUN_TASK_TOOL, CHECK_TASK_STATUS_TOOL, GET_TASK_RESULT_TOOL, CANCEL_TASK_TOOL, WAIT_FOR_TASK_TOOL, LIST_TASKS_TOOL, ], }; if (process.env.MCP_MODE !== 'true') { logger.debug( 'Returning tools:', response.tools.map(t => t.name) ); } return response; });
  • Core helper method TaskManager.getTask() used by the handler to retrieve task information by ID.
    public getTask(taskId: string): TaskInfo | undefined { return this.tasks.get(taskId); }

Other Tools

Related Tools

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/just-every/mcp-task'

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