Skip to main content
Glama

get_database_info

Retrieve PostgreSQL database version, connection details, and configuration settings for monitoring and troubleshooting database instances.

Instructions

Get database and connection information.

Returns:
    Database version, connection info, and settings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'get_database_info'. This is the entrypoint registered via @mcp.tool() that fetches and returns database information by delegating to the PostgresClient.
    @mcp.tool()
    @handle_db_error
    def get_database_info() -> dict:
        """Get database and connection information.
        
        Returns:
            Database version, connection info, and settings
        """
        client = get_client()
        return client.get_database_info()
  • Core implementation of database info retrieval in PostgresClient class. Executes SQL queries to gather version, connection details, and settings.
    def get_database_info(self) -> dict[str, Any]:
        """Get database and connection information.
        
        Returns:
            Dict with database info
        """
        with self.get_cursor() as cursor:
            cursor.execute("SELECT version()")
            version_row = cursor.fetchone()
            
            cursor.execute("""
                SELECT 
                    current_database() AS database,
                    current_user AS user,
                    inet_server_addr() AS host,
                    inet_server_port() AS port,
                    pg_encoding_to_char(encoding) AS encoding,
                    current_setting('TimeZone') AS timezone,
                    current_setting('max_connections')::int AS max_connections
                FROM pg_database
                WHERE datname = current_database()
            """)
            info_row = cursor.fetchone()
            
            cursor.execute("SELECT count(*) AS current_connections FROM pg_stat_activity")
            conn_row = cursor.fetchone()
            
            result = dict(info_row) if info_row else {}
            result["version"] = version_row["version"] if version_row else ""
            result["current_connections"] = conn_row["current_connections"] if conn_row else 0
            
            return result
  • The @mcp.tool() decorator registers the get_database_info function as an MCP tool.
    @mcp.tool()
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It states that the tool returns 'Database version, connection info, and settings', which gives some behavioral insight into the output. However, it doesn't disclose critical traits like whether this is a read-only operation, potential performance impacts, authentication needs, or error handling, leaving gaps for a tool that likely accesses system-level data.

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

Conciseness4/5

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

The description is concise and well-structured, with two sentences that efficiently state the purpose and return values. It's front-loaded with the main action and avoids unnecessary details. However, it could be slightly more polished by integrating the return information into a single sentence, but overall, it's efficient with minimal waste.

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

Completeness3/5

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

Given the tool's complexity (likely low, as it retrieves static info) and the lack of annotations and output schema, the description is minimally adequate. It explains what the tool does and what it returns, but for a database tool that might involve sensitive or system-level data, it should ideally mention safety, permissions, or data format to be more complete. Without an output schema, the return description helps, but more context would improve completeness.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so the schema fully documents the lack of inputs. The description doesn't add parameter details, which is appropriate here. A baseline of 4 is given for zero parameters, as there's no need to compensate for missing information, and the description doesn't introduce confusion.

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 tool's purpose with a specific verb ('Get') and resource ('database and connection information'), making it easy to understand what it does. However, it doesn't explicitly differentiate this from sibling tools like 'list_schemas' or 'table_stats', which might also provide database-related information, so it doesn't reach the highest 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. With many sibling tools available for database operations, there's no indication of whether this is for general metadata, specific configurations, or how it compares to tools like 'list_schemas' or 'query'. This lack of context leaves the agent to guess based on the name alone.

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/JaviMaligno/postgres-mcp'

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