Skip to main content
Glama

create_table

Execute SQL CREATE TABLE queries to define new database tables in MySQL, enabling structured data storage and organization.

Instructions

Creates a new table in the MySQL database.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL CREATE TABLE query to execute.

Implementation Reference

  • The handler function for the 'create_table' tool. Validates input, checks if it's a CREATE TABLE query, executes it on the MySQL pool, and returns success or error response.
    private async handleCreateTable(request: any, transactionId: string) {
      if (!isValidSqlQueryArgs(request.params.arguments)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid SQL query arguments.'
        );
      }
    
      const query = request.params.arguments.query;
      
      if (!isCreateTableQuery(query)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Only CREATE TABLE queries are allowed with create_table tool.'
        );
      }
    
      console.error(`[${transactionId}] Executing CREATE TABLE query: ${query}`);
      
      try {
        const [result] = await this.pool.query(query);
        console.error(`[${transactionId}] Table created successfully`);
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                success: true,
                message: 'Table created successfully',
                result
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        console.error(`[${transactionId}] Query error:`, error);
        if (error instanceof Error) {
          return {
            content: [
              {
                type: 'text',
                text: `MySQL error: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
    }
  • Input schema for the 'create_table' tool, defining the expected 'query' parameter.
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'The SQL CREATE TABLE query to execute.',
        },
      },
      required: ['query'],
    },
  • src/index.ts:108-121 (registration)
    Registration of the 'create_table' tool in the ListTools response, including name, description, and schema.
    {
      name: 'create_table',
      description: 'Creates a new table in the MySQL database.',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'The SQL CREATE TABLE query to execute.',
          },
        },
        required: ['query'],
      },
    },
  • Helper function used to validate if the provided query starts with 'CREATE TABLE'.
    const isCreateTableQuery = (query: string): boolean => 
      query.trim().toLowerCase().startsWith('create table');
  • src/index.ts:189-190 (registration)
    Switch case in CallToolRequestHandler that routes 'create_table' calls to the handler function.
    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. It states the tool creates a table, implying a write operation, but doesn't mention critical aspects like whether it requires specific permissions, if it's idempotent, what happens on errors, or any rate limits. This leaves significant gaps in understanding the tool's behavior.

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 a single, clear sentence that efficiently conveys the core purpose without unnecessary words. It's front-loaded and wastes no space, making it easy for an agent to parse quickly.

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 tool that performs a database write operation with no annotations and no output schema, the description is insufficient. It doesn't address behavioral traits like error handling, permissions, or return values, leaving the agent with incomplete context for safe and effective use.

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?

The schema description coverage is 100%, with the single parameter 'query' documented as 'The SQL CREATE TABLE query to execute.' The description doesn't add any meaningful semantics beyond this, such as SQL syntax examples or constraints, so it meets the baseline for adequate but not enhanced 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 ('creates') and resource ('new table in the MySQL database'), making the purpose immediately understandable. However, it doesn't distinguish this tool from sibling tools like 'execute_sql' or 'run_sql_query' which might also create tables, missing the opportunity to clarify its specific role in the toolset.

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?

No guidance is provided on when to use this tool versus alternatives like 'execute_sql' or 'run_sql_query', which could potentially handle similar tasks. The description lacks context about prerequisites, such as database permissions or connection requirements, leaving the agent to infer usage scenarios.

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/michael7736/mysql-mcp-server'

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