Skip to main content
Glama

taskGetById

Retrieve specific task details by ID to enhance task management and streamline workflows within the GonMCPtool MCP server.

Instructions

根據ID獲取特定任務

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes

Implementation Reference

  • main.ts:622-644 (registration)
    Registration of the 'taskGetById' tool including description, Zod input schema {id: z.string()}, and handler function that retrieves the task via TaskManagerTool and formats response.
    server.tool("taskGetById", "根據ID獲取特定任務", { id: z.string() }, async ({ id }) => { try { const task = await TaskManagerTool.getTaskById(id); if (!task) { return { content: [{ type: "text", text: `未找到ID為 ${id} 的任務` }] }; } return { content: [{ type: "text", text: `任務詳情:\n${JSON.stringify(task, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `獲取任務失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } } );
  • Core handler logic for retrieving a task by ID: loads tasks from JSON storage and returns the matching task or null.
    public static async getTaskById(id: string): Promise<Task | null> { const tasks = await this.readTasks(); const task = tasks.find(t => t.id === id); return task || null; }
  • Input schema validation using Zod for the task ID parameter.
    { id: z.string() },
  • Helper function to read all tasks from the JSON file './task/tasks.json', used by getTaskById.
    private static async readTasks(): Promise<Task[]> { await this.ensureTasksDirectory(); try { const tasksFile = this.getTasksFilePath(); const fileContent = fs.readFileSync(tasksFile, 'utf-8'); const data = JSON.parse(fileContent); return data.tasks || []; } catch (error) { console.error('Error reading tasks:', error); throw new Error(`讀取任務失敗: ${error instanceof Error ? error.message : '未知錯誤'}`); } }

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/GonTwVn/GonMCPtool'

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