Skip to main content
Glama
tim-mcdonnell

Tana MCP Server

create_field_node

Add custom fields to existing Tana nodes to organize and enrich data with structured attributes like text, dates, URLs, files, and references.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetNodeIdNo
attributeIdYes
childrenNo

Implementation Reference

  • Handler function that constructs a field node with type 'field', attributeId, and optional children, then calls tanaClient.createNode to execute the tool logic.
    async ({ targetNodeId, attributeId, children }) => {
      try {
        // Properly type the field node according to TanaFieldNode interface
        const fieldNode = {
          type: 'field' as const, // Use 'as const' to ensure type is "field"
          attributeId,
          children
        };
    
        // Cast to TanaNode to satisfy the type system
        const result = await this.tanaClient.createNode(targetNodeId, fieldNode as any);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2)
            }
          ],
          isError: false
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error creating field node: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
  • Zod input schema for the create_field_node tool parameters.
    {
      targetNodeId: z.string().optional(),
      attributeId: z.string(),
      children: z.array(NodeSchema).optional()
    },
  • Recursive Zod schema definition for Tana nodes, referenced in create_field_node input schema for children.
    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()
      })
    );
  • Registration of the create_field_node tool on the McpServer instance.
    this.server.tool(
      'create_field_node',
      {
        targetNodeId: z.string().optional(),
        attributeId: z.string(),
        children: z.array(NodeSchema).optional()
      },
      async ({ targetNodeId, attributeId, children }) => {
        try {
          // Properly type the field node according to TanaFieldNode interface
          const fieldNode = {
            type: 'field' as const, // Use 'as const' to ensure type is "field"
            attributeId,
            children
          };
    
          // Cast to TanaNode to satisfy the type system
          const result = await this.tanaClient.createNode(targetNodeId, fieldNode as any);
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(result, null, 2)
              }
            ],
            isError: false
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error creating field node: ${error instanceof Error ? error.message : String(error)}`
              }
            ],
            isError: true
          };
        }
      }
    );

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/tim-mcdonnell/tana-mcp'

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