Skip to main content
Glama

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
NameRequiredDescriptionDefault
task_idYesThe task ID returned from run_task

Implementation Reference

  • 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', }, ], }; }
  • 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; });
  • TaskManager.getTask method used by the handler to retrieve task information.
    public getTask(taskId: string): TaskInfo | undefined { return this.tasks.get(taskId); }

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