disconnect_database
Terminate the active database connection to release resources and manage connections effectively.
Instructions
Disconnect from the current database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:515-536 (handler)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: {}, }, },
- index.js:225-226 (helper)Dispatches calls to the 'disconnect_database' tool handler within the CallToolRequestSchema request handler's switch statement.case 'disconnect_database': return await this.disconnectDatabase();
- index.js:275-275 (helper)Called from connectDatabase to disconnect prior connections before establishing a new one.await this.disconnectDatabase();
- index.js:544-544 (helper)Called on SIGINT to cleanly disconnect before shutting down the server.await this.disconnectDatabase();