update_record
Modify specific fields in a database record by providing the base ID, table name, record ID, and updated data values.
Instructions
Update a single 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 to update | |
| data | Yes | The fields to update |
Implementation Reference
- src/tools/record.ts:225-244 (handler)The handler function for the 'update_record' MCP tool. It invokes the NocoDB client's updateRecord method with the provided base_id, table_name, record_id, and data, then returns the updated record along with a success message.handler: async ( client: NocoDBClient, args: { base_id: string; table_name: string; record_id: string; data: any; }, ) => { const record = await client.updateRecord( args.base_id, args.table_name, args.record_id, args.data, ); return { record, message: "Record updated successfully", }; },
- src/tools/record.ts:202-224 (schema)The input schema defining the parameters for the 'update_record' tool: base_id (string), table_name (string), record_id (string), and data (object). All are required.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 to update", }, data: { type: "object", description: "The fields to update", additionalProperties: true, }, }, required: ["base_id", "table_name", "record_id", "data"], },
- src/index.ts:55-62 (registration)Registers the 'update_record' tool by including the recordTools array (which defines update_record) into the allTools array. This allTools is used in MCP handlers for listing tools (ListToolsRequestSchema) and executing them (CallToolRequestSchema).const allTools = [ ...databaseTools, ...tableTools, ...recordTools, ...viewTools, ...queryTools, ...attachmentTools, ];
- src/nocodb-api.ts:243-273 (helper)The NocoDBClient.updateRecord helper method called by the tool handler. It resolves the table ID and primary key field, then performs a PATCH request to the NocoDB API to update the specified record.async updateRecord( baseId: string, tableName: string, recordId: string, data: NocoDBRecord, ): Promise<NocoDBRecord> { // First get table ID from table name const tables = await this.listTables(baseId); const table = tables.find( (t) => t.table_name === tableName || t.title === tableName, ); if (!table) { throw new NocoDBError(`Table ${tableName} not found`); } // Get the primary key field name (usually ID but can vary) const columns = await this.listColumns(table.id); const pkColumn = columns.find((col) => col.pk) || columns.find((col) => col.title === "ID"); const pkField = pkColumn?.title || "ID"; const response = await this.client.patch( `/api/v2/tables/${table.id}/records`, { [pkField]: recordId, ...data, }, ); return response.data; }