list_nodes
Retrieve nodes from Workflowy, showing child nodes for a specified parent or root nodes when no parent is provided.
Instructions
List nodes in Workflowy. If a parentId is provided, it lists the child nodes of that parent. If omitted, it lists the root nodes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parentId | No | ID of the parent node to list children from. If omitted, returns root nodes. |
Implementation Reference
- src/tools/workflowy.ts:10-28 (handler)The main handler function for the 'list_nodes' tool. It fetches either root nodes or child nodes of a given parentId using the workflowyClient and returns the JSON stringified result or an error message.handler: async ({ parentId, username, password }: { parentId?: string, username?: string, password?: string }) => { try { const items = !!parentId ? await workflowyClient.getChildItems(parentId, username, password) : await workflowyClient.getRootItems(username, password); return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error listing nodes: ${error.message}` }] }; }
- src/tools/workflowy.ts:7-9 (schema)Input schema definition for the 'list_nodes' tool using Zod, defining the optional parentId parameter.inputSchema: { parentId: z.string().optional().describe("ID of the parent node to list children from. If omitted, returns root nodes.") },
- src/tools/index.ts:12-22 (registration)The registerTools function that iterates over toolRegistry (which includes list_nodes via spread from workflowyTools) and registers each tool with the MCP server using server.addTool.export function registerTools(server: FastMCP): void { Object.entries(toolRegistry).forEach(([name, tool]) => { server.addTool({ name, description: tool.description, parameters: z.object(tool.inputSchema), annotations: tool.annotations, execute: tool.handler }); }); }
- src/workflowy/client.ts:32-37 (helper)Helper method in WorkflowyClient to retrieve root nodes, called by list_nodes handler when no parentId is provided.async getRootItems(username?: string, password?: string) { const { wf, client } = await this.createAuthenticatedClient(username, password); const doc = await wf.getDocument(); client.getTreeData() return doc.root.toJson(); }
- src/workflowy/client.ts:42-50 (helper)Helper method in WorkflowyClient to retrieve child items of a parent node, called by list_nodes handler when parentId is provided.async getChildItems(parentId: string, username?: string, password?: string) { const {wf, client } = await this.createAuthenticatedClient(username, password); let doc = await wf.getDocument(); const parent = doc.root.items.find(item => item.id === parentId); if (!parent) { throw new Error(`Parent node with ID ${parentId} not found.`); } return parent.items.map(item => item.toJson()); }