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)
    );
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