Skip to main content
Glama

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
NameRequiredDescriptionDefault
parentIdNoID of the parent node to list children from. If omitted, returns root nodes.

Implementation Reference

  • 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}` }] }; }
  • 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.") },
  • 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 }); }); }
  • 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(); }
  • 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()); }

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/danield137/mcp-workflowy'

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