Skip to main content
Glama

create_file_node

Create a file node in Tana by specifying file data, filename, and content type to organize documents within workspaces.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetNodeIdNo
fileDataYes
filenameYes
contentTypeYes
descriptionNo
supertagsNo

Implementation Reference

  • Registration of the 'create_file_node' tool, including Zod input schema, inline handler function that builds TanaFileNode and calls TanaClient.createNode.
    this.server.tool( 'create_file_node', { targetNodeId: z.string().optional(), fileData: z.string(), // base64 encoded file data filename: z.string(), contentType: z.string(), description: z.string().optional(), supertags: z.array(SupertagSchema).optional() }, async ({ targetNodeId, fileData, filename, contentType, description, supertags }) => { try { const node: TanaFileNode = { dataType: 'file', file: fileData, filename, contentType, description, supertags }; const result = await this.tanaClient.createNode(targetNodeId, node); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ], isError: false }; } catch (error) { return { content: [ { type: 'text', text: `Error creating file node: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
  • The handler function that implements the core logic of create_file_node: constructs the file node object and invokes the Tana API via client.
    async ({ targetNodeId, fileData, filename, contentType, description, supertags }) => { try { const node: TanaFileNode = { dataType: 'file', file: fileData, filename, contentType, description, supertags }; const result = await this.tanaClient.createNode(targetNodeId, node); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ], isError: false }; } catch (error) { return { content: [ { type: 'text', text: `Error creating file node: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
  • Type definition for TanaFileNode interface, defining the structure expected by the Tana API for file nodes.
    export interface TanaFileNode extends TanaBaseNode { dataType: 'file'; file: string; // base64 encoded file data filename: string; contentType: string; // MIME type }
  • TanaClient.createNode helper method invoked by the tool handler to wrap the multi-node createNodes call for single node creation.
    async createNode(targetNodeId: string | undefined, node: TanaNode): Promise<TanaNodeResponse> { const nodes = await this.createNodes(targetNodeId, [node]); if (nodes.length === 0) { throw new Error('Failed to create node'); } return nodes[0]; }

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