get_task_result
Retrieve the result of a specific task by providing the task ID and API key. Used within the Ghibli Video MCP Server to track the progress and outcome of image-to-animation conversions.
Instructions
Get task result
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | Yes | API key for authentication | |
| taskId | Yes | Task ID |
Implementation Reference
- src/index.ts:178-201 (handler)The handler for the 'get_task_result' MCP tool. Validates taskId and api_key parameters, invokes GhibliClient.getTaskResult, and formats the response as MCP content.case "get_task_result": { const taskId = String(request.params.arguments?.taskId); const apiKey = String(request.params.arguments?.api_key); if (!taskId) { throw new Error("Task ID cannot be empty"); } if (!apiKey) { throw new Error("API key cannot be empty"); } try { const result = await ghibliClient.getTaskResult(taskId, apiKey); return { content: [{ type: "text", text: `Task result: ${JSON.stringify(result)}` }] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; throw new Error(`Get task result failed: ${errorMessage}`); } }
- src/index.ts:94-111 (registration)Tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema for 'get_task_result'.{ name: "get_task_result", description: "Get task result", inputSchema: { type: "object", properties: { taskId: { type: "string", description: "Task ID" }, api_key: { type: "string", description: "API key for authentication" } }, required: ["taskId", "api_key"] } }
- src/ghibli.ts:149-172 (helper)GhibliClient helper method that performs the HTTP GET request to retrieve the task result from the external API.async getTaskResult(taskId: string, apiKey: string): Promise<TaskResult> { // 打印请求信息 const url = `${this.baseUrl}/api/video/result?task_id=${taskId}`; process.stderr.write(`\n[Request] GET ${url}\n`); process.stderr.write(`[Headers] ${JSON.stringify(this.getHeaders(apiKey), null, 2)}\n`); const response = await fetch(url, { method: 'GET', headers: this.getHeaders(apiKey) }); // 打印响应状态 process.stderr.write(`[Response] Status: ${response.status} ${response.statusText}\n`); if (!response.ok) { const error = `API request failed: ${response.statusText}`; process.stderr.write(`[Error] ${error}\n`); throw new Error(error); } const result = await response.json(); process.stderr.write(`[Response Data] ${JSON.stringify(result, null, 2)}\n`); return result.data; }
- src/ghibli.ts:175-179 (schema)TypeScript type definition for the TaskResult object returned by the getTaskResult method.export type TaskResult = { status: 'pending' | 'completed' | 'failed'; result?: string; error?: string; };