create_node_structure
Add structured nodes to Tana workspaces by defining properties like name, description, supertags, and data types for organized content creation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| targetNodeId | No | ||
| node | Yes |
Implementation Reference
- src/server/tana-mcp-server.ts:433-458 (handler)The core handler function for the 'create_node_structure' tool. It receives targetNodeId and node structure, casts the node to TanaNode type, calls tanaClient.createNode to create the structure in Tana, and returns the result as JSON or error message.async ({ targetNodeId, node }) => { try { // Cast to TanaNode to satisfy the type system const result = await this.tanaClient.createNode(targetNodeId, node as any); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ], isError: false }; } catch (error) { return { content: [ { type: 'text', text: `Error creating node structure: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/server/tana-mcp-server.ts:27-44 (schema)Recursive Zod schema (NodeSchema) defining the input structure for complex nested nodes. Supports name, description, supertags, children, specific dataTypes, field nodes, and properties for references, booleans, files, etc. Used as the 'node' parameter in the tool.const NodeSchema = z.lazy(() => z.object({ name: z.string().optional(), description: z.string().optional(), supertags: z.array(SupertagSchema).optional(), children: z.array(z.any()).optional(), // Will be validated by implementation // Fields for specific node types dataType: z.enum(['plain', 'reference', 'date', 'url', 'boolean', 'file']).optional(), id: z.string().optional(), // For reference nodes value: z.boolean().optional(), // For boolean nodes file: z.string().optional(), // For file nodes (base64) filename: z.string().optional(), // For file nodes contentType: z.string().optional(), // For file nodes // Field node properties type: z.literal('field').optional(), attributeId: z.string().optional() }) );
- src/server/tana-mcp-server.ts:427-459 (registration)Registers the 'create_node_structure' tool with the MCP server inside the registerTools() method, specifying the tool name, input schema (targetNodeId and NodeSchema), and the handler function.this.server.tool( 'create_node_structure', { targetNodeId: z.string().optional(), node: NodeSchema }, async ({ targetNodeId, node }) => { try { // Cast to TanaNode to satisfy the type system const result = await this.tanaClient.createNode(targetNodeId, node as any); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ], isError: false }; } catch (error) { return { content: [ { type: 'text', text: `Error creating node structure: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
- src/server/tana-mcp-server.ts:21-25 (schema)Zod schema for supertags (SupertagSchema), used within NodeSchema for node supertags. Includes id and optional fields record.const SupertagSchema = z.object({ id: z.string(), fields: z.record(z.string()).optional() });