Skip to main content
Glama

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
NameRequiredDescriptionDefault
file_pathYesPath to the file to upload
storage_pathNoOptional path in NocoDB storage

Implementation Reference

  • 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, }; } },
  • 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"], },
  • 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, ];

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/andrewlwn77/nocodb-mcp'

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