Skip to main content
Glama
cwilby

SQL Server MCP

by cwilby

get-stored-procedure

Retrieve a specific stored procedure by its name from a Microsoft SQL Server database using the SQL Server MCP, enabling streamlined database interactions for AI assistants.

Instructions

Get a specific stored procedure by name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
procedureNameYesThe name of the stored procedure to retrieve

Implementation Reference

  • Handler function that queries the database for a specific stored procedure by name and returns its details including definition.
    async getStoredProcedure({ procedureName }: { procedureName: string }) {
        const procedure = await database.query(`
            SELECT ROUTINE_NAME, ROUTINE_TYPE, ROUTINE_DEFINITION
            FROM INFORMATION_SCHEMA.ROUTINES
            WHERE ROUTINE_NAME = ?
        `, [procedureName]);
    
        if (!procedure.length) return this.toResult(`Stored procedure with name: ${procedureName} not found.`);
    
        const proc = procedure[0];
        return this.toResult(`Stored Procedure: ${proc.ROUTINE_NAME}\nType: ${proc.ROUTINE_TYPE}\nDefinition:\n\`\`\`sql\n${proc.ROUTINE_DEFINITION}\n\`\`\``);
    }
  • Zod input schema defining the 'procedureName' parameter for the tool.
    { procedureName: z.string().describe("The name of the stored procedure to retrieve") },
  • Registration of the 'get-stored-procedure' tool with MCP server, including name, description, schema, and handler binding.
    server.tool(
        "get-stored-procedure",
        "Get a specific stored procedure by name",
        { procedureName: z.string().describe("The name of the stored procedure to retrieve") },
        tools.getStoredProcedure.bind(tools)
    );
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 action ('Get') but doesn't describe whether this is a read-only operation, what permissions are required, how errors are handled (e.g., if the procedure doesn't exist), or the format of the returned data. This leaves significant gaps for an agent to understand 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, efficient sentence that directly states the tool's purpose without any redundant information. It is front-loaded and appropriately sized for a simple retrieval tool, with every word contributing to clarity.

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 lack of annotations and output schema, the description is incomplete for a tool that retrieves database objects. It doesn't explain what information is returned (e.g., procedure definition, metadata), error conditions, or dependencies on other tools like 'start-transaction'. For a tool with no structured behavioral data, this leaves the agent under-informed.

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 input schema has 100% description coverage, with the parameter 'procedureName' clearly documented. The description adds minimal value beyond the schema by implying the parameter is used to identify a specific stored procedure, but it doesn't provide additional context like naming conventions or examples. 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 verb ('Get') and resource ('a specific stored procedure by name'), making the purpose unambiguous. It distinguishes this from the sibling 'get-stored-procedures' (plural) by specifying retrieval of a single procedure. However, it doesn't fully differentiate from 'get-table' or 'query' in terms of resource type specificity.

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 like 'get-stored-procedures' (for listing all procedures) or 'query' (for executing SQL). It lacks context about prerequisites, such as needing an existing stored procedure name, or exclusions for when other tools might be more appropriate.

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

Related 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/cwilby/mcp-node-mssql'

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