upload_attachment
Upload files to NocoDB storage for database attachments. Specify file path and optional storage location to manage file attachments within your database.
Instructions
Upload a file attachment to NocoDB storage
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Path to the file to upload | |
| storage_path | No | Optional path in NocoDB storage |
Implementation Reference
- src/tools/attachment.ts:24-58 (handler)The handler function for the 'upload_attachment' tool. It verifies the file exists, gets its stats and name, uploads it using the NocoDB client, and returns success details or error information.handler: async ( client: NocoDBClient, args: { file_path: string; storage_path?: string; }, ) => { // Check if file exists if (!fs.existsSync(args.file_path)) { throw new Error(`File not found: ${args.file_path}`); } const stats = fs.statSync(args.file_path); const fileName = path.basename(args.file_path); try { const result = await client.uploadFile( args.file_path, args.storage_path, ); return { success: true, file_name: fileName, file_size: stats.size, upload_result: result, message: "File uploaded successfully", }; } catch (error: any) { return { success: false, error: error.message, file_path: args.file_path, }; } },
- src/tools/attachment.ts:10-23 (schema)Input schema defining the parameters for the 'upload_attachment' tool: required 'file_path' and optional 'storage_path'.inputSchema: { type: "object", properties: { file_path: { type: "string", description: "Path to the file to upload", }, storage_path: { type: "string", description: "Optional path in NocoDB storage", }, }, required: ["file_path"], },
- src/tools/attachment.ts:7-59 (registration)The 'upload_attachment' tool is defined as an object in the attachmentTools array, including name, description, inputSchema, and handler.{ name: "upload_attachment", description: "Upload a file attachment to NocoDB storage", inputSchema: { type: "object", properties: { file_path: { type: "string", description: "Path to the file to upload", }, storage_path: { type: "string", description: "Optional path in NocoDB storage", }, }, required: ["file_path"], }, handler: async ( client: NocoDBClient, args: { file_path: string; storage_path?: string; }, ) => { // Check if file exists if (!fs.existsSync(args.file_path)) { throw new Error(`File not found: ${args.file_path}`); } const stats = fs.statSync(args.file_path); const fileName = path.basename(args.file_path); try { const result = await client.uploadFile( args.file_path, args.storage_path, ); return { success: true, file_name: fileName, file_size: stats.size, upload_result: result, message: "File uploaded successfully", }; } catch (error: any) { return { success: false, error: error.message, file_path: args.file_path, }; } }, },
- src/index.ts:55-62 (registration)The attachmentTools (containing 'upload_attachment') are combined into the allTools array, which is used by the MCP server to list and execute tools.const allTools = [ ...databaseTools, ...tableTools, ...recordTools, ...viewTools, ...queryTools, ...attachmentTools, ];