Skip to main content
Glama

create_table

Create new tables in MSSQL databases by defining table names and column specifications with SQL types and constraints.

Instructions

Creates a new table in the MSSQL Database with the specified columns.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
columnsYesArray of column definitions (e.g., [{ name: 'id', type: 'INT PRIMARY KEY' }, ...])
tableNameYesName of the table to create

Implementation Reference

  • The `run` method executes the tool: validates input, builds CREATE TABLE query from tableName and columns, executes it via mssql, returns success/error.
    async run(params: any) {
      try {
        const { tableName, columns } = params;
        if (!Array.isArray(columns) || columns.length === 0) {
          throw new Error("'columns' must be a non-empty array");
        }
        const columnDefs = columns.map((col: any) => `[${col.name}] ${col.type}`).join(", ");
        const query = `CREATE TABLE [${tableName}] (${columnDefs})`;
        await new sql.Request().query(query);
        return {
          success: true,
          message: `Table '${tableName}' created successfully.`
        };
      } catch (error) {
        console.error("Error creating table:", error);
        return {
          success: false,
          message: `Failed to create table: ${error}`
        };
      }
    }
  • Input schema defining required parameters: `tableName` (string) and `columns` (array of {name, type} objects).
    inputSchema = {
      type: "object",
      properties: {
        tableName: { type: "string", description: "Name of the table to create" },
        columns: {
          type: "array",
          description: "Array of column definitions (e.g., [{ name: 'id', type: 'INT PRIMARY KEY' }, ...])",
          items: {
            type: "object",
            properties: {
              name: { type: "string", description: "Column name" },
              type: { type: "string", description: "SQL type and constraints (e.g., 'INT PRIMARY KEY', 'NVARCHAR(255) NOT NULL')" }
            },
            required: ["name", "type"]
          }
        }
      },
      required: ["tableName", "columns"],
    } as any;
  • src/index.ts:115-119 (registration)
    In ListToolsRequestHandler, `createTableTool` is added to the list of available tools (in non-readonly mode).
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: isReadOnly
        ? [listTableTool, readDataTool, describeTableTool] // todo: add searchDataTool to the list of tools available in readonly mode once implemented
        : [insertDataTool, readDataTool, describeTableTool, updateDataTool, createTableTool, createIndexTool, dropTableTool, listTableTool], // add all new tools here
    }));
  • src/index.ts:135-137 (registration)
    In CallToolRequestHandler switch statement, dispatches to `createTableTool.run(args)` when name matches.
    case createTableTool.name:
      result = await createTableTool.run(args);
      break;
  • src/index.ts:92-92 (registration)
    Instantiation of the CreateTableTool instance used throughout the server.
    const createTableTool = new CreateTableTool();
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Creates' implies a write operation, it doesn't specify critical details like whether this requires admin permissions, if it's idempotent, what happens on conflicts, or error handling. For a database mutation tool, this leaves significant gaps in understanding its 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, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy 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?

Given the complexity of a database table creation tool with no annotations and no output schema, the description is insufficient. It lacks details on permissions, error cases, return values, or how it interacts with sibling tools, 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 description mentions 'specified columns' which aligns with the 'columns' parameter, but adds no additional meaning beyond what the schema provides. With 100% schema description coverage, the schema already documents both parameters thoroughly, so the description meets the baseline without enhancing 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 MSSQL Database'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'create_index' or 'insert_data', which would require more specific context about when to create a table versus other operations.

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. It doesn't mention prerequisites (e.g., database permissions), when not to use it (e.g., if a table already exists), or refer to sibling tools like 'drop_table' for cleanup or 'list_table' for checking existing tables.

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/Nirmal123K/mssql-mcp'

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