mysql_create_database
Create a new MySQL database with specified name, character set, and collation settings for organizing and storing data.
Instructions
创建数据库
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | 数据库名称 | |
| charset | No | 字符集(可选) | utf8mb4 |
| collation | No | 排序规则(可选) | utf8mb4_unicode_ci |
Implementation Reference
- src/server.ts:71-83 (registration)Registers the 'mysql_create_database' tool in the listTools response, including its description and input schema.{ name: 'mysql_create_database', description: '创建数据库', inputSchema: { type: 'object', properties: { name: { type: 'string', description: '数据库名称' }, charset: { type: 'string', description: '字符集(可选)', default: 'utf8mb4' }, collation: { type: 'string', description: '排序规则(可选)', default: 'utf8mb4_unicode_ci' }, }, required: ['name'], }, },
- src/server.ts:317-328 (handler)MCP server handler method that calls DatabaseManager.createDatabase and returns success message.private async handleCreateDatabase(args: { name: string; charset?: string; collation?: string }): Promise<any> { await this.dbManager.createDatabase(args.name, args.charset, args.collation); return { content: [ { type: 'text', text: `成功创建数据库: ${args.name}`, }, ], }; }
- src/database.ts:99-111 (handler)Core implementation that constructs and executes the CREATE DATABASE SQL statement using the query method.async createDatabase(name: string, charset?: string, collation?: string): Promise<void> { let sql = `CREATE DATABASE \`${name}\``; if (charset) { sql += ` CHARACTER SET ${charset}`; } if (collation) { sql += ` COLLATE ${collation}`; } await this.query(sql); }
- src/server.ts:239-240 (registration)Dispatch case in CallToolRequest handler that routes to the mysql_create_database handler.case 'mysql_create_database': return await this.handleCreateDatabase(args as any);