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
| Name | Required | Description | Default |
|---|---|---|---|
| targetNodeId | No | ||
| fileData | Yes | ||
| filename | Yes | ||
| contentType | Yes | ||
| description | No | ||
| supertags | No |
Implementation Reference
- src/server/tana-mcp-server.ts:303-347 (registration)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 }; } } );
- src/server/tana-mcp-server.ts:313-346 (handler)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 }; } }
- src/types/tana-api.ts:46-51 (schema)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 }
- src/server/tana-client.ts:52-58 (helper)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]; }