Skip to main content
Glama
melihbirim

PostgreSQL MCP Server

by melihbirim

disconnect_database

Terminates the active connection to a PostgreSQL database, ensuring secure disengagement for read-only AI assistant interactions managed by the Postgre MCP Server.

Instructions

Disconnect from the current PostgreSQL database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:445-484 (registration)
    Registers the 'disconnect_database' tool with server.tool. Includes empty input schema, description, and an inline async handler that disconnects the PostgreSQL database by calling dbClient.end() if connected, handling success, no-connection, and error cases.
    server.tool(
      "disconnect_database",
      "Disconnect from the current PostgreSQL database",
      {},
      async () => {
        try {
          if (dbClient) {
            await dbClient.end();
            dbClient = null;
            return {
              content: [
                {
                  type: "text",
                  text: "Successfully disconnected from database.",
                },
              ],
            };
          } else {
            return {
              content: [
                {
                  type: "text",
                  text: "No active database connection to disconnect.",
                },
              ],
            };
          }
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : "Unknown error";
          return {
            content: [
              {
                type: "text",
                text: `Error disconnecting from database: ${errorMessage}`,
              },
            ],
          };
        }
      }
    );
  • Inline handler function for disconnect_database tool. Checks if dbClient exists, ends the connection, sets to null, and returns appropriate text response. Handles no connection and errors gracefully.
    async () => {
      try {
        if (dbClient) {
          await dbClient.end();
          dbClient = null;
          return {
            content: [
              {
                type: "text",
                text: "Successfully disconnected from database.",
              },
            ],
          };
        } else {
          return {
            content: [
              {
                type: "text",
                text: "No active database connection to disconnect.",
              },
            ],
          };
        }
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : "Unknown error";
        return {
          content: [
            {
              type: "text",
              text: `Error disconnecting from database: ${errorMessage}`,
            },
          ],
        };
      }
    }
  • Empty input schema object, indicating the tool takes no input parameters.
    {},
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Disconnect' implies a state-changing operation, it doesn't specify whether this is reversible, what cleanup occurs, whether it affects other operations, or what happens on success/failure. The description is too minimal for a tool that likely has important side effects.

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 that communicates the essential action without any wasted words. It's perfectly front-loaded with the core purpose and doesn't include unnecessary elaboration. Every word earns its place in this minimal but complete statement.

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?

For a tool that performs a state-changing operation (disconnecting from a database) with no annotations and no output schema, the description is inadequate. It doesn't explain what 'disconnect' entails, what gets cleaned up, whether this affects subsequent operations, what the response looks like, or error conditions. Given the complexity of database connection management, more context is needed.

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 tool has zero parameters with 100% schema description coverage, so the schema already fully documents the parameter situation. The description appropriately doesn't waste space discussing nonexistent parameters, maintaining focus on the tool's purpose. A baseline of 4 is appropriate for zero-parameter tools.

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 ('Disconnect from') and target resource ('the current PostgreSQL database'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this tool from its siblings like 'connect_database' beyond the obvious opposite action, missing an opportunity to clarify the relationship between connection management tools.

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 or what prerequisites might be needed. It doesn't mention whether a database connection must be active first, what happens if no connection exists, or how this relates to sibling tools like 'connect_database' in a workflow.

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

Related 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/melihbirim/pg-mcp'

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