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
| Name | Required | Description | Default |
|---|---|---|---|
| procedureName | Yes | The name of the stored procedure to retrieve |
Implementation Reference
- src/tools/schema.ts:107-118 (handler)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\`\`\``); }
- src/tools/schema.ts:32-32 (schema)Zod input schema defining the 'procedureName' parameter for the tool.{ procedureName: z.string().describe("The name of the stored procedure to retrieve") },
- src/tools/schema.ts:29-34 (registration)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) );