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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the tool retrieves statistics and information, lacking details on permissions required, rate limits, response format, or whether it's a read-only operation (though implied by 'get'). This leaves significant gaps for a tool that likely interacts with databases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It is front-loaded with the core purpose ('Get statistics and information about a database'), making it easy to scan and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of database operations and the lack of annotations and output schema, the description is insufficient. It doesn't explain what specific statistics are retrieved, the format of the information, or potential side effects. For a tool that likely returns structured data, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the single parameter 'connectionId' documented as 'The ID or name of the DBeaver connection'. The description adds no additional meaning beyond this, such as explaining what statistics are returned or how the connection is used. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get statistics and information') and resource ('about a database'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'get_connection_info' or 'get_table_schema' that also retrieve database-related information, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_connection_info' or 'list_tables', nor does it mention prerequisites or context for usage. It merely states what the tool does without indicating appropriate scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/omnisql-mcp'

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