mysql_disconnect
Terminate active MySQL database connections to free up server resources and ensure proper session management when database operations are complete.
Instructions
断开 MySQL 数据库连接
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "mysql_disconnect"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:55-62 (registration)Registration of the 'mysql_disconnect' tool in the ListTools response, including name, description, and empty input schema.
{ name: 'mysql_disconnect', description: '断开 MySQL 数据库连接', inputSchema: { type: 'object', properties: {}, }, }, - src/server.ts:291-302 (handler)The main 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/database.ts:40-46 (helper)The DatabaseManager.disconnect() helper method that ends the MySQL connection pool.
async disconnect(): Promise<void> { if (this.pool) { await this.pool.end(); this.pool = null; console.log('已断开 MySQL 连接'); } }