create_record
Generate a new record in a specified resource by providing the resource URI and required data. Streamline data management within MCP servers using structured inputs.
Instructions
Create a new record in a resource
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Record data to create | |
| resourceUri | Yes | URI of the resource |
Implementation Reference
- src/core/MCPServer.ts:215-221 (handler)Handler implementation for the 'create_record' tool. Validates input using CreateRecordArgsSchema and delegates creation to the data service.case 'create_record': { return await safeExecute(toolName, async () => { const args = validateInput(CreateRecordArgsSchema, request.params.arguments); const record = await this.dataService.createRecord(args.resourceUri, args.data); return record; }); }
- src/core/MCPServer.ts:148-152 (registration)Registration of the 'create_record' tool in the list_tools handler, including name, description, and input schema reference.{ name: 'create_record', description: 'Create a new record in a resource', inputSchema: getInputSchema(CreateRecordArgsSchema), },
- src/types/index.ts:82-85 (schema)Zod schema defining the input arguments for the create_record tool: resourceUri and data.export const CreateRecordArgsSchema = z.object({ resourceUri: z.string().describe('URI of the resource'), data: z.record(z.unknown()).describe('Record data to create'), });
- Example concrete implementation of createRecord method in InMemoryDataService, which the tool handler calls via dataService.public async createRecord( uri: string, data: Record<string, unknown> ): Promise<Record<string, unknown>> { this.validateResource(uri); const id = data.id as string || uuidv4(); const timestamp = new Date().toISOString(); const record = { id, ...data, createdAt: timestamp, updatedAt: timestamp }; this.data.get(uri)!.set(id, record); return record; }
- src/types/index.ts:36-36 (schema)Type signature for createRecord method in IDataService interface, defining the contract called by the tool handler.createRecord(_uri: string, _data: { [key: string]: unknown }): Promise<{ [key: string]: unknown }>;