get_task_result
Retrieve the status and output of animated video generation tasks from the Ghibli Video MCP Server using task IDs and API authentication.
Instructions
Get task result
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | Task ID | |
| api_key | Yes | API key for authentication |
Implementation Reference
- src/index.ts:178-201 (handler)MCP CallToolRequest handler case for 'get_task_result': validates taskId and api_key, calls GhibliClient.getTaskResult, returns JSON stringified result or error.
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 ListToolsResponse: defines name, description, and input schema requiring taskId and api_key.
{ 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.getTaskResult implementation: GET request to /api/video/result?task_id={taskId} with API key, returns task result data.
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 TaskResult, used as return type for getTaskResult.
export type TaskResult = { status: 'pending' | 'completed' | 'failed'; result?: string; error?: string; };