Skip to main content
Glama
srthkdev

DBeaver MCP Server

by srthkdev

get_database_stats

Retrieve database statistics and information using existing DBeaver connections to analyze database performance and structure.

Instructions

Get statistics and information about a database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesThe ID or name of the DBeaver connection

Implementation Reference

  • The primary MCP tool handler for get_database_stats. Validates the connection ID, retrieves the connection, calls the DBeaverClient helper, and returns the stats as JSON text content.
    private async handleGetDatabaseStats(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 stats = await this.dbeaverClient.getDatabaseStats(connection); return { content: [{ type: 'text' as const, text: JSON.stringify(stats, null, 2), }], }; }
  • Input schema validation for the get_database_stats tool, defining the required connectionId parameter.
    inputSchema: { type: 'object', properties: { connectionId: { type: 'string', description: 'The ID or name of the DBeaver connection', }, }, required: ['connectionId'], },
  • src/index.ts:391-404 (registration)
    Tool registration entry in the ListTools response, including name, description, and input schema.
    { name: 'get_database_stats', description: 'Get statistics and information about a database', inputSchema: { type: 'object', properties: { connectionId: { type: 'string', description: 'The ID or name of the DBeaver connection', }, }, required: ['connectionId'], }, },
  • Supporting method in DBeaverClient that implements the core logic: lists tables to count them and executes a version query.
    async getDatabaseStats(connection: DBeaverConnection): Promise<DatabaseStats> { const startTime = Date.now(); try { // Get table count const tables = await this.listTables(connection, undefined, true); const tableCount = tables.length; // Get server version const versionQuery = this.getTestQuery(connection.driver); const versionResult = await this.executeQuery(connection, versionQuery); const serverVersion = this.extractVersionFromResult(versionResult) || 'Unknown'; return { connectionId: connection.id, tableCount, totalSize: 'Unknown', // Would need specific queries per database type connectionTime: Date.now() - startTime, serverVersion }; } catch (error) { return { connectionId: connection.id, tableCount: 0, totalSize: 'Unknown', connectionTime: Date.now() - startTime, serverVersion: 'Unknown' }; } }
  • TypeScript interface defining the structure of the DatabaseStats return object used by the tool.
    export interface DatabaseStats { connectionId: string; tableCount: number; totalSize: string; connectionTime: number; serverVersion: string; uptime?: 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