Skip to main content
Glama
EvilPhatBoi

MSSQL MCP Server

by EvilPhatBoi

create_index

Create database indexes on MSSQL table columns to improve query performance and enforce data uniqueness.

Instructions

Creates an index on a specified column or columns in an MSSQL Database table

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaNameNoName of the schema containing the table
tableNameYesName of the table to create index on
indexNameYesName for the new index
columnsYesArray of column names to include in the index
isUniqueNoWhether the index should enforce uniqueness (default: false)
isClusteredNoWhether the index should be clustered (default: false)

Implementation Reference

  • The async run method implements the core logic of the create_index tool: constructs and executes a CREATE INDEX SQL query on the specified table columns with optional unique and clustered modifiers.
    async run(params: any) {
      try {
        const { schemaName, tableName, indexName, columns, isUnique = false, isClustered = false } = params;
    
        let indexType = isClustered ? "CLUSTERED" : "NONCLUSTERED";
        if (isUnique) {
          indexType = `UNIQUE ${indexType}`;
        }
        const columnNames = columns.join(", ");
    
        const request = new sql.Request();
        const query = `CREATE ${indexType} INDEX ${indexName} ON ${schemaName}.${tableName} (${columnNames})`;
        await request.query(query);
        
        return {
          success: true,
          message: `Index [${indexName}] created successfully on table [${schemaName}.${tableName}]`,
          details: {
            schemaName,
            tableName,
            indexName,
            columnNames,
            isUnique,
            isClustered
          }
        };
      } catch (error) {
        console.error("Error creating index:", error);
        return {
          success: false,
          message: `Failed to create index: ${error}`,
        };
      }
    }
  • Input schema defining the parameters for the create_index tool: schemaName, tableName, indexName, columns (required array), isUnique, isClustered.
    inputSchema = {
      type: "object",
      properties: {
        schemaName: { type: "string", description: "Name of the schema containing the table" },
        tableName: { type: "string", description: "Name of the table to create index on" },
        indexName: { type: "string", description: "Name for the new index" },
        columns: { 
          type: "array", 
          items: { type: "string" },
          description: "Array of column names to include in the index" 
        },
        isUnique: { 
          type: "boolean", 
          description: "Whether the index should enforce uniqueness (default: false)",
          default: false
        },
        isClustered: { 
          type: "boolean", 
          description: "Whether the index should be clustered (default: false)",
          default: false
        },
      },
      required: ["tableName", "indexName", "columns"],
    } as any;
  • src/index.ts:110-112 (registration)
    Registers createIndexTool in the list of available tools for the ListToolsRequestSchema handler (included in non-readonly mode).
    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:132-133 (registration)
    Registers the dispatch to createIndexTool.run() in the switch statement of the CallToolRequestSchema handler.
    case createIndexTool.name:
      result = await createIndexTool.run(args);
  • src/index.ts:87-87 (registration)
    Instantiates the CreateIndexTool instance used throughout the server.
    const createIndexTool = new CreateIndexTool();
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 an index' implies a write operation, it doesn't specify whether this requires admin permissions, if it's reversible (e.g., via drop_table), potential performance impacts during creation, or error conditions. For a database 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. Every word earns its place without redundancy or fluff, 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?

Given the complexity of a database index creation tool with no annotations and no output schema, the description is insufficient. It lacks details on behavioral traits (e.g., permissions, side effects), usage context, and expected outcomes. For a mutation tool in a set of database operations, this leaves critical gaps for an agent to operate safely and effectively.

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%, with all 6 parameters well-documented in the input schema (e.g., tableName, columns, isUnique). The description adds no additional parameter semantics beyond implying column specification, so it meets the baseline of 3 where the schema does the heavy lifting without compensating for any gaps.

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 an index') and the resource ('on a specified column or columns in an MSSQL Database table'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this tool from its siblings (e.g., create_table, drop_table) beyond the general domain of database operations, which prevents a perfect score.

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., table must exist), performance implications, or when to choose indexing over other operations like query optimization. With siblings like create_table and update_data, this lack of context leaves the agent without clear usage boundaries.

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