test_connection
Verify connectivity to DBeaver database connections by testing if the specified connection can be established successfully.
Instructions
Test connectivity to a DBeaver connection
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connectionId | Yes | The ID or name of the DBeaver connection to test |
Implementation Reference
- src/index.ts:900-916 (handler)Primary handler function for the 'test_connection' tool. It sanitizes the connection ID, retrieves the connection configuration, tests the connection via dbeaverClient, and returns the test result as JSON.private async handleTestConnection(args: { connectionId: string }) { const connectionId = sanitizeConnectionId(args.connectionId); const connection = await this.configParser.getConnection(connectionId); if (!connection) { throw new McpError(ErrorCode.InvalidParams, `Connection not found: ${connectionId}`); } const testResult = await this.dbeaverClient.testConnection(connection); return { content: [{ type: 'text' as const, text: JSON.stringify(testResult, null, 2), }], }; }
- src/index.ts:377-390 (registration)Tool registration in the listTools response, defining the name, description, and input schema for 'test_connection'.{ name: 'test_connection', description: 'Test connectivity to a DBeaver connection', inputSchema: { type: 'object', properties: { connectionId: { type: 'string', description: 'The ID or name of the DBeaver connection to test', }, }, required: ['connectionId'], }, },
- src/index.ts:535-536 (handler)Dispatch case in the CallToolRequestHandler that routes 'test_connection' calls to the handleTestConnection method.case 'test_connection': return await this.handleTestConnection(args as { connectionId: string });
- src/dbeaver-client.ts:41-63 (helper)Core helper method in DBeaverClient that performs the actual connection test by executing a database-specific test query and returning success/error details.async testConnection(connection: DBeaverConnection): Promise<ConnectionTest> { const startTime = Date.now(); try { // Simple test query based on database type const testQuery = this.getTestQuery(connection.driver); const result = await this.executeQuery(connection, testQuery); return { connectionId: connection.id, success: true, responseTime: Date.now() - startTime, databaseVersion: this.extractVersionFromResult(result) }; } catch (error) { return { connectionId: connection.id, success: false, error: error instanceof Error ? error.message : String(error), responseTime: Date.now() - startTime }; } }