Skip to main content
Glama
srthkdev

DBeaver MCP Server

by srthkdev

write_query

Execute INSERT, UPDATE, or DELETE queries on DBeaver database connections to modify data across 200+ database types without additional configuration.

Instructions

Execute INSERT, UPDATE, or DELETE queries on a specific DBeaver connection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesThe ID or name of the DBeaver connection to use
queryYesThe SQL query to execute (INSERT, UPDATE, DELETE)

Implementation Reference

  • Main handler function that validates the query (ensures it's INSERT/UPDATE/DELETE, not SELECT), sanitizes connection ID, fetches the connection, executes the query using DBeaver client, and returns a JSON response with execution details including affected rows.
    private async handleWriteQuery(args: { connectionId: string; query: string }) { const connectionId = sanitizeConnectionId(args.connectionId); const query = args.query.trim(); // Validate query type const lowerQuery = query.toLowerCase(); if (lowerQuery.startsWith('select')) { throw new McpError(ErrorCode.InvalidParams, 'Use execute_query for SELECT operations'); } if (!(lowerQuery.startsWith('insert') || lowerQuery.startsWith('update') || lowerQuery.startsWith('delete'))) { throw new McpError(ErrorCode.InvalidParams, 'Only INSERT, UPDATE, or DELETE operations are allowed with write_query'); } // Additional validation const validationError = validateQuery(query); if (validationError) { throw new McpError(ErrorCode.InvalidParams, validationError); } const connection = await this.configParser.getConnection(connectionId); if (!connection) { throw new McpError(ErrorCode.InvalidParams, `Connection not found: ${connectionId}`); } const result = await this.dbeaverClient.executeQuery(connection, query); const response = { query: query, connection: connection.name, executionTime: result.executionTime, affectedRows: result.rowCount, success: true }; return { content: [{ type: 'text' as const, text: JSON.stringify(response, null, 2), }], }; }
  • Input schema definition for the write_query tool in the list of tools, defining required parameters: connectionId (string) and query (string), with descriptions.
    { name: 'write_query', description: 'Execute INSERT, UPDATE, or DELETE queries on a specific DBeaver connection', inputSchema: { type: 'object', properties: { connectionId: { type: 'string', description: 'The ID or name of the DBeaver connection to use', }, query: { type: 'string', description: 'The SQL query to execute (INSERT, UPDATE, DELETE)', }, }, required: ['connectionId', 'query'], }, },
  • src/index.ts:494-498 (registration)
    Switch case in CallToolRequest handler that routes 'write_query' calls to the handleWriteQuery method, casting arguments to the expected type.
    case 'write_query': return await this.handleWriteQuery(args as { connectionId: string; query: string; });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/srthkdev/dbeaver-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server