Skip to main content
Glama
alittleyellowkevin

MySQL MCP Server

create_table

Create new tables in MySQL databases by executing SQL CREATE TABLE statements to structure and organize data storage.

Instructions

在 MySQL 数据库中创建新表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes要执行的 SQL CREATE TABLE 语句

Implementation Reference

  • The main handler function for the 'create_table' tool. It validates the input arguments, checks if the query is a CREATE TABLE statement, executes the query on the MySQL pool, and returns the result or error response.
    private async handleCreateTable(request: any, transactionId: string) {
      if (!isValidSqlQueryArgs(request.params.arguments)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'SQL 查询参数无效。'
        );
      }
    
      const query = request.params.arguments.query;
    
      if (!isCreateTableQuery(query)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'create_table 工具仅允许 CREATE TABLE 查询。'
        );
      }
    
      console.error(`[${transactionId}] 执行 CREATE TABLE 查询: ${query}`);
    
      try {
        const [result] = await this.pool.query(query);
        console.error(`[${transactionId}] 表创建成功`);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                success: true,
                message: '表创建成功',
                result
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        console.error(`[${transactionId}] 查询出错:`, error);
        if (error instanceof Error) {
          return {
            content: [
              {
                type: 'text',
                text: `MySQL 错误: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
    }
  • Input schema definition for the 'create_table' tool, specifying the 'query' parameter as a required string for the CREATE TABLE SQL statement.
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: '要执行的 SQL CREATE TABLE 语句',
          },
        },
        required: ['query'],
      },
    },
  • src/index.ts:117-129 (registration)
    Registration of the 'create_table' tool in the ListTools response, including name, description, and input schema.
      name: 'create_table',
      description: '在 MySQL 数据库中创建新表',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: '要执行的 SQL CREATE TABLE 语句',
          },
        },
        required: ['query'],
      },
    },
  • Helper function to validate if the SQL query is a CREATE TABLE statement, used in the handler.
    const isCreateTableQuery = (query: string): boolean =>
      query.trim().toLowerCase().startsWith('create table');
  • src/index.ts:198-199 (registration)
    Dispatch/handling registration in the CallToolRequestSchema switch statement for the 'create_table' tool.
    case 'create_table':
      return this.handleCreateTable(request, transactionId);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While '创建新表' (create new table) implies a write/mutation operation, the description doesn't disclose permissions needed, whether the operation is reversible, potential side effects, error conditions, or what happens on success/failure. For a database mutation tool with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single sentence in Chinese that directly states the tool's purpose. There's zero waste or unnecessary elaboration. It's appropriately sized for a simple tool with one parameter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a database mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after table creation, what gets returned, error handling, or behavioral constraints. Given the complexity of database operations and the lack of structured metadata, the description should provide more complete context about the tool's behavior and outcomes.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single 'query' parameter as '要执行的 SQL CREATE TABLE 语句' (SQL CREATE TABLE statement to execute). The description doesn't add any additional parameter semantics beyond what's in the schema. With high schema coverage, baseline 3 is appropriate when the description doesn't enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('创建新表' - create new table) and resource ('在 MySQL 数据库中' - in MySQL database), providing specific verb+resource. However, it doesn't distinguish this from sibling tools like 'execute_sql' or 'run_sql_query' which could also potentially create tables, so it doesn't fully differentiate from alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'execute_sql' or 'run_sql_query'. There's no mention of prerequisites, when-not-to-use scenarios, or explicit alternatives. The agent must infer usage context from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alittleyellowkevin/Mysql-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server