mysql_create_database
Creates a MySQL database with specified name, charset, and collation. Simplifies database setup for efficient management and structured data storage.
Instructions
创建数据库
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| charset | No | 字符集(可选) | utf8mb4 |
| collation | No | 排序规则(可选) | utf8mb4_unicode_ci |
| name | Yes | 数据库名称 |
Implementation Reference
- src/database.ts:99-111 (handler)Core handler function in DatabaseManager that constructs and executes the CREATE DATABASE SQL statement with optional charset and collation.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:317-328 (handler)MCP server handler method that calls DatabaseManager.createDatabase and formats the response.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/server.ts:72-83 (schema)Input schema definition for the mysql_create_database tool, including parameters name (required), charset, and collation.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:239-240 (registration)Switch case registration that routes mysql_create_database calls to the handleCreateDatabase method.case 'mysql_create_database': return await this.handleCreateDatabase(args as any);