Skip to main content
Glama
dhipskind253

mssql-mcp

by dhipskind253

get_procedure_definition

Retrieve the SQL definition of a stored procedure in a specified schema. Use this tool to inspect procedure logic without executing it.

Instructions

Return the SQL definition of a stored procedure. (Definitions are read-only — this server cannot EXEC procedures.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaYes
procedureYes

Implementation Reference

  • src/index.ts:142-154 (registration)
    Registration of the 'get_procedure_definition' tool on the MCP server, defining its description, input schema (schema, procedure), and handler callback.
    server.tool(
      'get_procedure_definition',
      'Return the SQL definition of a stored procedure. (Definitions are read-only — this server cannot EXEC procedures.)',
      {
        schema: z.string(),
        procedure: z.string(),
      },
      async ({ schema, procedure }) =>
        runTool(async () => {
          const def = await db.getProcedureDefinition(schema, procedure);
          return def ?? `[NOT_FOUND] Procedure ${schema}.${procedure} not found.`;
        })
    );
  • Handler callback that calls db.getProcedureDefinition(schema, procedure) and returns the result or a NOT_FOUND message.
    async ({ schema, procedure }) =>
      runTool(async () => {
        const def = await db.getProcedureDefinition(schema, procedure);
        return def ?? `[NOT_FOUND] Procedure ${schema}.${procedure} not found.`;
      })
  • Implementation of getProcedureDefinition in DbManager: queries sys.sql_modules joined with sys.procedures and sys.schemas to return the SQL definition of a stored procedure.
    async getProcedureDefinition(schema: string, proc: string): Promise<string | null> {
      const r = await (await this.getPool())
        .request()
        .input('schema', sql.NVarChar, schema)
        .input('proc', sql.NVarChar, proc).query(`
          SELECT m.definition
          FROM sys.sql_modules m
          INNER JOIN sys.procedures p ON m.object_id = p.object_id
          INNER JOIN sys.schemas s ON p.schema_id = s.schema_id
          WHERE s.name = @schema AND p.name = @proc
        `);
      return r.recordset[0]?.definition ?? null;
    }
  • Zod schema for the tool's inputs: 'schema' (string) and 'procedure' (string).
    {
      schema: z.string(),
      procedure: z.string(),
    },
Behavior4/5

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

With no annotations, the description carries full burden and proactively states the tool is read-only and that the server cannot execute procedures. This discloses behavioral traits beyond the schema, though it could mention error handling or permissions.

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 with two sentences, no filler, and front-loads the core action. Every sentence adds value, earning a top score.

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

Completeness3/5

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

The description lacks details about the return format (e.g., a string with the SQL definition) and does not address error cases or behavior when the procedure does not exist. Given no output schema, more completeness is warranted.

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

Parameters2/5

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

Despite 0% schema description coverage, the description adds no parameter-level detail beyond the parameter names. It does not explain expected formats, constraints, or examples for 'schema' and 'procedure', leaving the agent with minimal guidance.

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

Purpose5/5

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

The description uses a specific verb ('Return the SQL definition') and resource ('stored procedure'), and it clearly distinguishes from sibling tools like 'get_view_definition' by specifying 'stored procedure' and noting the server's limitation.

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

Usage Guidelines4/5

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

The description explicitly states that definitions are read-only and that the server cannot execute procedures, providing clear context for when to use this tool. However, it does not offer an alternative for when execution is needed, which would improve guidance.

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

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