update_record
Modify existing records within a specified resource by providing the resource URI, record ID, and updated data. Ensures accurate and efficient record management within the MCP Template server.
Instructions
Update a record in a resource
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | New record data | |
| recordId | Yes | ID of the record to update | |
| resourceUri | Yes | URI of the resource |
Implementation Reference
- src/core/MCPServer.ts:223-229 (handler)The handler for the 'update_record' tool. Validates input using UpdateRecordArgsSchema and calls this.dataService.updateRecord to perform the update.case 'update_record': { return await safeExecute(toolName, async () => { const args = validateInput(UpdateRecordArgsSchema, request.params.arguments); const record = await this.dataService.updateRecord(args.resourceUri, args.recordId, args.data); return record; }); }
- src/core/MCPServer.ts:154-157 (registration)Registration of the 'update_record' tool in the list_tools handler, including name, description, and input schema reference.name: 'update_record', description: 'Update a record in a resource', inputSchema: getInputSchema(UpdateRecordArgsSchema), },
- src/types/index.ts:87-91 (schema)Zod schema defining the input arguments for the update_record tool: resourceUri, recordId, and data.export const UpdateRecordArgsSchema = z.object({ resourceUri: z.string().describe('URI of the resource'), recordId: z.string().describe('ID of the record to update'), data: z.record(z.unknown()).describe('New record data'), });
- Implementation of the updateRecord method in the InMemoryDataService, which is called by the tool handler to perform the actual record update in memory.public async updateRecord( uri: string, id: string, data: Record<string, unknown> ): Promise<Record<string, unknown>> { this.validateResource(uri); const resourceData = this.data.get(uri)!; const existingRecord = resourceData.get(id); if (!existingRecord) { throw new Error(`Record not found: ${id}`); } const updatedRecord = { ...existingRecord, ...data, id, // Ensure ID doesn't change updatedAt: new Date().toISOString() }; resourceData.set(id, updatedRecord); return updatedRecord; }