get_attachment_info
Retrieve file attachment details from a specific record in a NocoDB database, including metadata and file information for managing document storage.
Instructions
Get information about file attachments in a record
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| base_id | Yes | The ID of the base/project | |
| table_name | Yes | The name of the table | |
| record_id | Yes | The ID of the record | |
| attachment_field | Yes | The name of the attachment field |
Implementation Reference
- src/tools/attachment.ts:230-265 (handler)The handler function executes the tool logic: retrieves the record using NocoDB client, extracts attachments from the specified field, handles JSON parsing if needed, and returns the list of attachments with count, field, and record ID.handler: async ( client: NocoDBClient, args: { base_id: string; table_name: string; record_id: string; attachment_field: string; }, ) => { const record = await client.getRecord( args.base_id, args.table_name, args.record_id, ); const attachments = record[args.attachment_field]; if (!attachments) { return { attachments: [], message: "No attachments found in the specified field", }; } // Parse attachment data if it's a JSON string const attachmentData = typeof attachments === "string" ? JSON.parse(attachments) : attachments; return { attachments: Array.isArray(attachmentData) ? attachmentData : [attachmentData], count: Array.isArray(attachmentData) ? attachmentData.length : 1, field: args.attachment_field, record_id: args.record_id, }; },
- src/tools/attachment.ts:208-229 (schema)Input schema defining the required parameters: base_id, table_name, record_id, and attachment_field for retrieving attachment information.inputSchema: { type: "object", properties: { base_id: { type: "string", description: "The ID of the base/project", }, table_name: { type: "string", description: "The name of the table", }, record_id: { type: "string", description: "The ID of the record", }, attachment_field: { type: "string", description: "The name of the attachment field", }, }, required: ["base_id", "table_name", "record_id", "attachment_field"], },
- src/tools/attachment.ts:205-266 (registration)The complete tool object for 'get_attachment_info' defined within the exported attachmentTools array, which is later included in the MCP server's tool list.{ name: "get_attachment_info", description: "Get information about file attachments in a record", inputSchema: { type: "object", properties: { base_id: { type: "string", description: "The ID of the base/project", }, table_name: { type: "string", description: "The name of the table", }, record_id: { type: "string", description: "The ID of the record", }, attachment_field: { type: "string", description: "The name of the attachment field", }, }, required: ["base_id", "table_name", "record_id", "attachment_field"], }, handler: async ( client: NocoDBClient, args: { base_id: string; table_name: string; record_id: string; attachment_field: string; }, ) => { const record = await client.getRecord( args.base_id, args.table_name, args.record_id, ); const attachments = record[args.attachment_field]; if (!attachments) { return { attachments: [], message: "No attachments found in the specified field", }; } // Parse attachment data if it's a JSON string const attachmentData = typeof attachments === "string" ? JSON.parse(attachments) : attachments; return { attachments: Array.isArray(attachmentData) ? attachmentData : [attachmentData], count: Array.isArray(attachmentData) ? attachmentData.length : 1, field: args.attachment_field, record_id: args.record_id, }; }, },
- src/index.ts:55-63 (registration)Registration of all tools, including attachmentTools (which contains get_attachment_info), into the allTools array used by the MCP server's ListTools and CallTool request handlers.const allTools = [ ...databaseTools, ...tableTools, ...recordTools, ...viewTools, ...queryTools, ...attachmentTools, ];