Skip to main content
Glama
EvilPhatBoi

MSSQL MCP Server

by EvilPhatBoi

create_table

Create new tables in Microsoft SQL Server databases by defining column names, data types, and constraints for structured data storage.

Instructions

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

Input Schema

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

Implementation Reference

  • The main execution logic for the create_table tool: validates input, builds SQL CREATE TABLE query from columns, executes it via mssql, returns success/error response.
      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}`
          };
        }
      }
    }
  • JSON schema defining input 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:109-113 (registration)
    Registers createTableTool instance in the list of available tools for ListToolsRequest (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:129-130 (registration)
    Switch case in CallToolRequestHandler that invokes createTableTool.run() when 'create_table' is called.
    case createTableTool.name:
      result = await createTableTool.run(args);
  • src/index.ts:86-86 (registration)
    Instantiation of the CreateTableTool class for use in the MCP server.
    const createTableTool = new CreateTableTool();
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 this is a creation operation, implying a write/mutation, but doesn't mention critical aspects like required permissions, whether it's idempotent (e.g., fails if table exists), side effects on the database, or error handling. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 front-loads the core action and resource. There's no wasted verbiage or redundancy, making it easy to parse quickly while conveying the essential purpose.

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 mutation tool with no annotations and no output schema, the description is incomplete. It doesn't address behavioral traits (e.g., permissions, idempotency), return values, or error cases. Given the complexity of database operations and lack of structured safety hints, more context is needed to guide 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?

Schema description coverage is 100%, so the input schema fully documents both parameters (tableName and columns) with clear descriptions and examples. The description adds minimal value beyond stating the tool uses 'specified columns', which is already implied by the schema. This meets the baseline for high schema coverage.

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 'drop_table', which would require mentioning this is for table structure creation rather than index creation or data insertion.

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 'create_index' for indexes, 'insert_data' for adding data, or 'drop_table' for removal. The description lacks context about prerequisites (e.g., database permissions) or typical scenarios for table creation, leaving the agent to infer usage from the 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/EvilPhatBoi/McpSqlServer'

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