data
Execute PostgreSQL database operations including insert, update, delete, and bulk actions with data validation for efficient table management.
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) | |
| data | No | Data object for insert/update (key-value pairs) | |
| options | No | Operation options | |
| rows | No | Array of data objects for bulk operations | |
| schemaName | No | Schema name (default: public) | public |
| tableName | Yes | Table name (required for all actions) | |
| where | No | WHERE conditions for update/delete operations |
Implementation Reference
- src/index.ts:1072-1080 (handler)The handler function that executes the 'data' tool logic. Currently implemented as a placeholder returning a not-implemented message.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)The JSON schema definition for the 'data' tool input, specifying parameters for data manipulation actions.{ 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:633-637 (registration)Tool list registration handler that returns all tool definitions, including 'data'.// Register tool definitions this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: toolDefinitions, }));
- src/index.ts:656-656 (registration)Dispatch registration in the CallToolRequestSchema handler switch statement for the 'data' tool.return await this.handleData(args);