create_node
Add new nodes to organize information in WorkFlowy. This tool helps structure your outlines and lists by creating additional items.
Instructions
Create a new node
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/workflowy.ts:80-99 (handler)The MCP tool handler function for 'create_node'. It calls workflowyClient.createNode and formats the response.handler: async ({ parentId, name, description, username, password }: { parentId: string, name: string, description?: string, username?: string, password?: string }, client: typeof workflowyClient) => { try { await workflowyClient.createNode(parentId, name, description, username, password); return { content: [{ type: "text", text: `Successfully created node "${name}" under parent ${parentId}` }] }; } catch (error: any) { return { content: [{ type: "text", text: `Error creating node: ${error.message}` }] }; } }
- src/workflowy/client.ts:78-95 (helper)The helper method in WorkflowyClient that implements the actual node creation logic using the Workflowy library.async createNode(parentId: string, name: string, description?: string, username?: string, password?: string) { const { wf } = await this.createAuthenticatedClient(username, password); const 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.`); } const newNode = await parent.createItem(); newNode.setName(name); if (description) { newNode.setNote(description); } if (doc.isDirty()) { // Saves the changes if there are any await doc.save(); } }
- src/tools/index.ts:12-21 (registration)The registration function that adds all tools from toolRegistry (including create_node) to the MCP server.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/tools/index.ts:6-9 (registration)Central tool registry that includes workflowyTools containing the create_node tool definition.export const toolRegistry: Record<string, any> = { ...workflowyTools, // Add more tool categories here };
- src/index.ts:14-14 (registration)Invocation of registerTools to register all tools on the MCP server startup.registerTools(server);