add_review_record
Create new review records for custom categories like coffee, whisky, or wine with flexible field definitions and support for local or cloud storage.
Instructions
Add a new review record to a type
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| typeName | Yes | Name of the review type | |
| data | Yes | Review data matching the type schema |
Input Schema (JSON Schema)
{
"properties": {
"data": {
"description": "Review data matching the type schema",
"type": "object"
},
"typeName": {
"description": "Name of the review type",
"type": "string"
}
},
"required": [
"typeName",
"data"
],
"type": "object"
}
Implementation Reference
- src/tools/add-record.ts:29-69 (handler)The core handler function for the add_review_record tool. It validates the type name and data against the schema, generates a unique ID and timestamp for the new record, appends it to the type's records in storage, and returns a success result with the record ID.export async function addRecord( storage: StorageProvider, params: AddRecordParams ): Promise<AddRecordResult> { // Validate type name const typeName = validateTypeName(params.typeName); // Check if type exists const exists = await storage.typeExists(typeName); if (!exists) { throw new Error(`Review type "${typeName}" does not exist`); } // Read existing type data const typeData = await storage.readType(typeName); // Validate record against schema validateRecordAgainstSchema(params.data, typeData.schema); // Create new record const recordId = generateId(); const newRecord: ReviewRecord = { id: recordId, data: params.data as Record<string, string | number | boolean>, createdAt: getCurrentTimestamp(), }; // Add record to type typeData.records.push(newRecord); typeData.updatedAt = getCurrentTimestamp(); // Save updated type data await storage.writeType(typeName, typeData); return { success: true, typeName, recordId, message: `Record added to "${typeName}" with ID: ${recordId}`, }; }
- src/index.ts:107-125 (schema)MCP tool schema definition for add_review_record, including input schema specifying typeName and data object.{ name: "add_review_record", description: "Add a new review record to a type", inputSchema: { type: "object", properties: { typeName: { type: "string", description: "Name of the review type", }, data: { type: "object", description: "Review data matching the type schema", }, }, required: ["typeName", "data"], }, }, ];
- src/index.ts:220-234 (registration)Registration of the add_review_record handler in the tool dispatch switch statement, which extracts parameters, performs basic validation, calls the addRecord function, and formats the response.case "add_review_record": { const params = args as { typeName: string; data: Record<string, unknown> }; if (!params?.typeName || !params?.data) { throw new Error("typeName and data are required"); } const result = await addRecord(storage, params); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
- src/tools/add-record.ts:14-17 (schema)TypeScript interface defining the input parameters for the addRecord handler, matching the MCP schema.export interface AddRecordParams { typeName: string; data: Record<string, unknown>; }
- src/index.ts:19-19 (registration)Import statement registering the addRecord handler function from its module.import { addRecord } from "./tools/add-record.js";