mysql_disconnect
Terminate the active connection to a MySQL database managed by the MCP MySQL Server, freeing resources and ending the session.
Instructions
Disconnect from the MySQL database
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/index.ts:493-516 (handler)The handler function for the mysql_disconnect tool. It ends the MySQL connection pool if active, clears the config, and returns a success message. If no connection, returns a no-op message.private async handleDisconnect() { if (this.pool) { await this.pool.end(); this.pool = null; this.config = null; return { content: [ { type: "text", text: "Successfully disconnected from MySQL database", }, ], }; } else { return { content: [ { type: "text", text: "No active MySQL connection to disconnect", }, ], }; } }
- src/index.ts:232-239 (registration)Tool registration in the ListTools handler, defining name, description, and input schema (empty object).{ name: "mysql_disconnect", description: "Disconnect from the MySQL database", inputSchema: { type: "object", properties: {}, }, },
- src/index.ts:263-264 (registration)Dispatch in the CallTool switch statement that calls the handleDisconnect method for mysql_disconnect.case "mysql_disconnect": return await this.handleDisconnect();
- src/index.ts:235-238 (schema)Input schema for mysql_disconnect tool: empty object (no parameters required).inputSchema: { type: "object", properties: {}, },
- src/index.ts:60-65 (helper)Helper method to end the connection pool, similar logic used in handleDisconnect.private async cleanup(): Promise<void> { if (this.pool) { await this.pool.end(); this.pool = null; } }