data
Perform PostgreSQL database operations including insert, update, delete, and bulk data management with validation for table modifications.
Instructions
Data operations: insert, update, delete, bulk operations with validation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action: insert (single row), update (modify rows), delete (remove rows), bulk_insert (multiple rows), bulk_update (batch update), truncate (empty table) | |
| tableName | Yes | Table name (required for all actions) | |
| schemaName | No | Schema name (default: public) | public |
| data | No | Data object for insert/update (key-value pairs) | |
| rows | No | Array of data objects for bulk operations | |
| where | No | WHERE conditions for update/delete operations | |
| options | No | Operation options |
Implementation Reference
- src/index.ts:1071-1079 (handler)Handler function that processes calls to the 'data' tool. Currently implemented as a placeholder returning a message that data operations are not yet implemented.private async handleData(args: any) { // Placeholder for data operations return { content: [{ type: 'text', text: JSON.stringify({ message: 'Data operations not yet implemented' }, null, 2) }] };
- src/index.ts:237-282 (schema)Input schema definition for the 'data' tool, specifying parameters for various data manipulation actions (insert, update, delete, bulk operations, truncate).{ name: 'data', description: 'Data operations: insert, update, delete, bulk operations with validation', inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['insert', 'update', 'delete', 'bulk_insert', 'bulk_update', 'truncate'], description: 'Action: insert (single row), update (modify rows), delete (remove rows), bulk_insert (multiple rows), bulk_update (batch update), truncate (empty table)' }, tableName: { type: 'string', description: 'Table name (required for all actions)' }, schemaName: { type: 'string', description: 'Schema name (default: public)', default: 'public' }, data: { type: 'object', description: 'Data object for insert/update (key-value pairs)' }, rows: { type: 'array', items: { type: 'object' }, description: 'Array of data objects for bulk operations' }, where: { type: 'object', description: 'WHERE conditions for update/delete operations' }, options: { type: 'object', properties: { onConflict: { type: 'string', description: 'ON CONFLICT action (DO NOTHING, DO UPDATE)' }, returning: { type: 'array', items: { type: 'string' }, description: 'Columns to return' }, validate: { type: 'boolean', default: true, description: 'Validate data before operation' } }, description: 'Operation options' } }, required: ['action', 'tableName'] } },
- src/index.ts:634-636 (registration)Registration of tool list handler that returns the toolDefinitions array, which includes the 'data' tool schema.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: toolDefinitions, }));
- src/index.ts:655-656 (registration)Dispatch/registration of the 'data' tool handler in the CallToolRequestSchema switch statement.case 'data': return await this.handleData(args);