mysql_create_table
Create tables in MySQL databases using SQL statements. This tool enables structured data storage by defining table schemas with columns, data types, and constraints.
Instructions
创建表
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | 创建表的 SQL 语句 |
Implementation Reference
- src/server.ts:369-380 (handler)The main handler function for the 'mysql_create_table' tool. It receives the SQL from arguments and delegates to DatabaseManager.createTable to execute it, then returns a success message.private async handleCreateTable(args: { sql: string }): Promise<any> { await this.dbManager.createTable(args.sql); return { content: [ { type: 'text', text: '成功创建表', }, ], }; }
- src/server.ts:120-126 (schema)Input schema definition for the mysql_create_table tool, specifying that it requires a 'sql' string parameter.inputSchema: { type: 'object', properties: { sql: { type: 'string', description: '创建表的 SQL 语句' }, }, required: ['sql'], },
- src/server.ts:247-248 (registration)Registration in the CallToolRequestSchema switch statement that routes calls to mysql_create_table to the handleCreateTable method.case 'mysql_create_table': return await this.handleCreateTable(args as any);
- src/server.ts:117-127 (registration)Tool registration in the ListToolsRequestSchema response, defining the tool's name, description, and input schema.{ name: 'mysql_create_table', description: '创建表', inputSchema: { type: 'object', properties: { sql: { type: 'string', description: '创建表的 SQL 语句' }, }, required: ['sql'], }, },
- src/database.ts:175-177 (helper)Helper method in DatabaseManager that executes the provided CREATE TABLE SQL using the query method.async createTable(sql: string): Promise<void> { await this.query(sql); }