Skip to main content
Glama

MCP Universal DB Client

disconnect_database

Close database connections to free up resources and manage connection pooling in the MCP Universal DB Client. Use this tool to terminate specific database sessions when they are no longer needed.

Instructions

Disconnect from a database using connection ID

Input Schema

NameRequiredDescriptionDefault
connectionIDYesThe connection ID to disconnect

Input Schema (JSON Schema)

{ "properties": { "connectionID": { "description": "The connection ID to disconnect", "type": "string" } }, "required": [ "connectionID" ], "type": "object" }

Implementation Reference

  • The async handler function for the 'disconnect_database' tool. It retrieves the connection ID from input, calls deleteConnection on the DatabaseConnections instance, and returns a text content confirming the disconnection.
    async (input) => { databaseConnections.deleteConnection(input.connectionID); return { content: [ { type: "text", text: `Disconnected connection ID: ${input.connectionID}`, }, ], }; }
  • Inline input schema for the 'disconnect_database' tool, using Zod to validate the 'connectionID' string parameter.
    inputSchema: { connectionID: z.string().describe("The connection ID to disconnect"), },
  • src/index.ts:64-85 (registration)
    Registration of the 'disconnect_database' tool on the MCP server, specifying title, description, input schema, and handler function.
    mcpServer.registerTool( "disconnect_database", { title: "Disconnect Database", description: "Disconnect from a database using connection ID", inputSchema: { connectionID: z.string().describe("The connection ID to disconnect"), }, }, async (input) => { databaseConnections.deleteConnection(input.connectionID); return { content: [ { type: "text", text: `Disconnected connection ID: ${input.connectionID}`, }, ], }; } );
  • The 'deleteConnection' method in the DatabaseConnections class, which finds the connection, calls destroy() on its Kysely instance to disconnect, removes it from the internal map, and returns boolean success.
    public deleteConnection(name: string) { const conn = this.connections.get(name); if (conn) { conn.instance.destroy(); this.connections.delete(name); return true; } return false; }

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/IzumiSy/mcp-universal-db-client'

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