Skip to main content
Glama
vini-cius

SQL Server MCP Service

by vini-cius

list_procedures

Retrieve all stored procedures from a SQL Server database. Filter results by schema name to identify available database procedures for execution or analysis.

Instructions

Lists all stored procedures in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaNameNoSchema name to filter procedures

Implementation Reference

  • Core handler function that executes the SQL query to list stored procedures from INFORMATION_SCHEMA.ROUTINES, optionally filtered by schemaName, and returns formatted JSON result or error.
    export async function listProcedures( db: DatabaseConnection, schemaName?: string ): Promise<CallToolResult> { try { const pool = db.getPool() let query = ` SELECT ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE, CREATED, LAST_ALTERED FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' `.trim() const request = pool.request() if (schemaName) { query += ' AND ROUTINE_SCHEMA = @schemaName' request.input('schemaName', schemaName) } query += ' ORDER BY ROUTINE_SCHEMA, ROUTINE_NAME' const result = await request.query(query) return { content: [ { type: 'text', text: JSON.stringify( { procedures: result.recordset, count: result.recordset.length, }, null, 2 ), }, ], } } catch (error) { return { content: [ { type: 'text', text: `Erro: ${error instanceof Error ? error.message : 'Erro desconhecido'}`, }, ], isError: true, } } }
  • Zod input schema for list_procedures tool, defining optional schemaName parameter.
    export const listProceduresInput = z.object({ schemaName: z .string() .optional() .describe('Schema name to filter procedures'), })
  • Tool registration in toolsList() function, providing name, description, and JSON schema for the MCP tools list response.
    { name: 'list_procedures', description: 'Lists all stored procedures in the database', inputSchema: zodToJsonSchema(listProceduresInput), },
  • Registers the thin wrapper handler for 'list_procedures' in the SqlServerMCPService's toolHandlers Map, which parses args and delegates to the core listProcedures function.
    handlers.set('list_procedures', async (database, args) => { const { schemaName } = args as ListProceduresInput return await listProcedures(database, schemaName) })

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/vini-cius/mcp-sqlserver'

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