Skip to main content
Glama
bpamiri

SQL Server MCP

by bpamiri

list_stored_procs

Discover and filter stored procedures in SQL Server databases by schema or name pattern to analyze database structure and manage procedures effectively.

Instructions

List available stored procedures in the database.

Args:
    schema: Filter by schema name (e.g., 'dbo')
    pattern: Filter by name pattern using SQL LIKE syntax (e.g., 'sp_%', '%User%')

Returns:
    Dictionary with:
    - procedures: List of procedure info (schema, name, created, modified)
    - count: Number of procedures found

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaNo
patternNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'list_stored_procs' tool, decorated with @mcp.tool() which serves as its registration. It queries the INFORMATION_SCHEMA.ROUTINES view to list stored procedures, optionally filtered by schema and LIKE pattern, and formats the results into a structured dictionary.
    @mcp.tool()
    def list_stored_procs(
        schema: str | None = None,
        pattern: str | None = None,
    ) -> dict[str, Any]:
        """List available stored procedures in the database.
    
        Args:
            schema: Filter by schema name (e.g., 'dbo')
            pattern: Filter by name pattern using SQL LIKE syntax (e.g., 'sp_%', '%User%')
    
        Returns:
            Dictionary with:
            - procedures: List of procedure info (schema, name, created, modified)
            - count: Number of procedures found
        """
        try:
            manager = get_connection_manager()
    
            query = """
                SELECT
                    ROUTINE_SCHEMA as [schema],
                    ROUTINE_NAME as [name],
                    CREATED as [created],
                    LAST_ALTERED as [modified]
                FROM INFORMATION_SCHEMA.ROUTINES
                WHERE ROUTINE_TYPE = 'PROCEDURE'
                    AND ROUTINE_CATALOG = DB_NAME()
            """
    
            params: list[Any] = []
    
            if schema:
                query += " AND ROUTINE_SCHEMA = %s"
                params.append(schema)
    
            if pattern:
                query += " AND ROUTINE_NAME LIKE %s"
                params.append(pattern)
    
            query += " ORDER BY ROUTINE_SCHEMA, ROUTINE_NAME"
    
            rows = manager.execute_query(query, tuple(params) if params else None)
    
            procedures = [
                {
                    "schema": row["schema"],
                    "name": row["name"],
                    "created": row["created"].isoformat() if row["created"] else None,
                    "modified": row["modified"].isoformat() if row["modified"] else None,
                }
                for row in rows
            ]
    
            return {
                "procedures": procedures,
                "count": len(procedures),
            }
    
        except Exception as e:
            logger.error(f"Error listing stored procedures: {e}")
            return {"error": str(e)}
Behavior3/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 effectively describes the tool as a read-only listing operation (implied by 'List'), specifies filtering capabilities, and details the return structure. However, it misses behavioral aspects like potential performance impacts, authentication requirements, or error handling. It adds value beyond the schema but doesn't fully cover all behavioral traits.

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 appropriately sized and well-structured, with a clear purpose statement followed by dedicated 'Args' and 'Returns' sections. Each sentence earns its place by providing essential information without redundancy. It is front-loaded with the main purpose and efficiently organized for quick comprehension.

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

Completeness4/5

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

Given the tool's moderate complexity (2 parameters, no annotations, but with an output schema), the description is largely complete. It covers the purpose, parameters, and return values in detail. The output schema existence means the description doesn't need to explain return values, which it does anyway, adding clarity. However, it could improve by addressing usage context relative to siblings or behavioral nuances like error cases.

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

Parameters5/5

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

The schema description coverage is 0%, so the description must compensate fully. It does this excellently by explaining both parameters ('schema' and 'pattern') with clear semantics, examples (e.g., 'dbo', 'sp_%'), and usage context (filtering by schema name and SQL LIKE syntax). This adds significant meaning beyond the bare schema, making the parameters understandable and actionable.

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 clearly states the tool's purpose with a specific verb ('List') and resource ('available stored procedures in the database'). It distinguishes itself from siblings like 'describe_stored_proc' (which provides details on a specific procedure) and 'list_tables' (which lists tables instead of procedures). The description is precise and unambiguous about what the tool does.

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

Usage Guidelines3/5

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

The description implies usage through the parameter explanations (e.g., filtering by schema or pattern), but it does not explicitly state when to use this tool versus alternatives. For example, it doesn't clarify if this should be used before 'describe_stored_proc' or how it differs from 'list_tables' in terms of database object types. The guidance is functional but lacks explicit context or exclusions.

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

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