taskGetAll
Retrieve a complete list of tasks using the TypeScript-based MCP server tool designed for managing AI interactions with code files, translations, and project builds.
Instructions
獲取所有任務列表
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.ts:606-618 (handler)The inline asynchronous handler function that executes the core logic of the 'taskGetAll' tool. It retrieves all tasks using TaskManagerTool.getAllTasks(), formats them as JSON in a text response, and handles errors.async () => { try { const tasks = await TaskManagerTool.getAllTasks(); return { content: [{ type: "text", text: `獲取到 ${tasks.length} 個任務:\n${JSON.stringify(tasks, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `獲取任務失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } }
- main.ts:603-619 (registration)Registration of the 'taskGetAll' MCP tool on the server, specifying the tool name, Chinese description, empty input schema ({}), and the inline handler function.server.tool("taskGetAll", "獲取所有任務列表", {}, async () => { try { const tasks = await TaskManagerTool.getAllTasks(); return { content: [{ type: "text", text: `獲取到 ${tasks.length} 個任務:\n${JSON.stringify(tasks, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `獲取任務失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } } );
- tools/taskManagerTool.ts:133-135 (helper)The TaskManagerTool.getAllTasks() static method, which is called by the tool handler. It delegates to the private readTasks() method to load all tasks.public static async getAllTasks(): Promise<Task[]> { return await this.readTasks(); }
- tools/taskManagerTool.ts:47-59 (helper)Private helper method readTasks() used by getAllTasks(). Ensures the tasks directory exists and reads/parses the tasks.json file to return the array of tasks.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 : '未知錯誤'}`); } }
- main.ts:605-605 (schema)Empty input schema object for the taskGetAll tool, indicating no input parameters are required.{},