mysql_disconnect
Disconnect a client from a MySQL database, ensuring safe termination of active sessions and releasing resources for efficient database management.
Instructions
断开 MySQL 数据库连接
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:291-302 (handler)The handler function for the mysql_disconnect tool, which delegates to DatabaseManager.disconnect() and returns a success message.private async handleDisconnect(): Promise<any> { await this.dbManager.disconnect(); return { content: [ { type: 'text', text: '已断开 MySQL 连接', }, ], }; }
- src/server.ts:55-62 (registration)Registration of the mysql_disconnect tool in the ListTools response, including its schema (empty input object).{ name: 'mysql_disconnect', description: '断开 MySQL 数据库连接', inputSchema: { type: 'object', properties: {}, }, },
- src/database.ts:40-46 (helper)The DatabaseManager.disconnect() helper method that actually ends the MySQL connection pool.async disconnect(): Promise<void> { if (this.pool) { await this.pool.end(); this.pool = null; console.log('已断开 MySQL 连接'); } }