get_task_result
Retrieve final results from completed AI tasks using the task ID, enabling access to processed outcomes in complex workflows.
Instructions
Get the final result of a completed task.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes | The task ID returned from run_task |
Implementation Reference
- src/serve.ts:706-734 (handler)Handler function that executes the get_task_result tool. Retrieves the task using TaskManager.getTask and returns the output if the task is completed, failed, or cancelled.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', }, ], }; }
- src/serve.ts:194-214 (schema)Input schema and metadata definition for the get_task_result tool.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 get_task_result in the list of available tools returned by ListToolsRequestSchema handler.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; });
- src/utils/task-manager.ts:261-263 (helper)TaskManager.getTask method used by the handler to retrieve task information.public getTask(taskId: string): TaskInfo | undefined { return this.tasks.get(taskId); }