Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

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

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