Skip to main content
Glama
TranChiHuu

MCP SQL Server

by TranChiHuu

disconnect_database

Terminate the active database connection to release resources and manage connections effectively.

Instructions

Disconnect from the current database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function for the 'disconnect_database' tool. It terminates any active PostgreSQL or MySQL database connections/pools, clears the current configuration, and returns a success message.
    async disconnectDatabase() {
      if (this.postgresPool) {
        await this.postgresPool.end();
        this.postgresPool = null;
      }
    
      if (this.mysqlConnection) {
        await this.mysqlConnection.end();
        this.mysqlConnection = null;
      }
    
      this.currentConfig = null;
    
      return {
        content: [
          {
            type: 'text',
            text: 'Disconnected from database',
          },
        ],
      };
    }
  • index.js:197-204 (registration)
    Registers the 'disconnect_database' tool in the MCP ListTools response, providing name, description, and input schema (empty object since no parameters required).
    {
      name: 'disconnect_database',
      description: 'Disconnect from the current database',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • Dispatches calls to the 'disconnect_database' tool handler within the CallToolRequestSchema request handler's switch statement.
    case 'disconnect_database':
      return await this.disconnectDatabase();
  • Called from connectDatabase to disconnect prior connections before establishing a new one.
    await this.disconnectDatabase();
  • Called on SIGINT to cleanly disconnect before shutting down the server.
    await this.disconnectDatabase();

Tool Definition Quality

Score is being calculated. Check back soon.

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/TranChiHuu/postgres-mysql-mcp-server'

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