Skip to main content
Glama
bpamiri

SQL Server MCP

by bpamiri

describe_stored_proc

Retrieve parameter details for SQL Server stored procedures to understand input requirements and data types before execution.

Instructions

Get parameter information for a stored procedure.

Args:
    procedure: Procedure name, optionally with schema (e.g., 'dbo.sp_GetUser' or 'sp_GetUser')

Returns:
    Dictionary with:
    - procedure: Full procedure name (schema.name)
    - parameters: List of parameter info (name, type, direction, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
procedureYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that implements the logic for the 'describe_stored_proc' MCP tool. It parses the procedure name, queries the database for parameter information from INFORMATION_SCHEMA.PARAMETERS, formats the results, and handles errors. The @mcp.tool() decorator registers it as an MCP tool. The docstring provides input/output schema details.
    @mcp.tool()
    def describe_stored_proc(procedure: str) -> dict[str, Any]:
        """Get parameter information for a stored procedure.
    
        Args:
            procedure: Procedure name, optionally with schema (e.g., 'dbo.sp_GetUser' or 'sp_GetUser')
    
        Returns:
            Dictionary with:
            - procedure: Full procedure name (schema.name)
            - parameters: List of parameter info (name, type, direction, etc.)
        """
        try:
            manager = get_connection_manager()
    
            # Parse schema.procedure format
            if "." in procedure:
                parts = procedure.split(".", 1)
                schema = parts[0]
                proc_name = parts[1]
            else:
                schema = "dbo"
                proc_name = procedure
    
            query = """
                SELECT
                    PARAMETER_NAME as [name],
                    DATA_TYPE as [type],
                    PARAMETER_MODE as [direction],
                    CHARACTER_MAXIMUM_LENGTH as [max_length],
                    NUMERIC_PRECISION as [precision],
                    NUMERIC_SCALE as [scale],
                    ORDINAL_POSITION as [position]
                FROM INFORMATION_SCHEMA.PARAMETERS
                WHERE SPECIFIC_SCHEMA = %s
                    AND SPECIFIC_NAME = %s
                ORDER BY ORDINAL_POSITION
            """
    
            rows = manager.execute_query(query, (schema, proc_name))
    
            parameters = []
            for row in rows:
                param_info: dict[str, Any] = {
                    "name": row["name"] or "(return value)",
                    "type": row["type"],
                    "direction": row["direction"] or "IN",
                }
                if row["max_length"]:
                    param_info["max_length"] = row["max_length"]
                if row["precision"]:
                    param_info["precision"] = row["precision"]
                if row["scale"]:
                    param_info["scale"] = row["scale"]
                parameters.append(param_info)
    
            return {
                "procedure": f"{schema}.{proc_name}",
                "parameters": parameters,
            }
    
        except Exception as e:
            logger.error(f"Error describing stored procedure {procedure}: {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 clearly indicates this is a read operation ('Get') and specifies the return format, but does not mention permissions required, rate limits, error conditions, or whether it requires an active connection. It adds value beyond the schema but lacks comprehensive behavioral context.

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 perfectly structured and front-loaded: the first sentence states the purpose, followed by clearly labeled Args and Returns sections. Every sentence earns its place by providing essential information without redundancy. The formatting enhances readability without unnecessary verbosity.

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 (single parameter, read-only operation) and the presence of an output schema (which covers return values), the description is nearly complete. It explains the purpose, parameter semantics, and return structure adequately. The main gap is lack of connection/authentication context, which might be inferred from sibling tools but isn't explicitly stated.

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 fully compensate. It provides detailed semantics for the single parameter: explains it's the procedure name, shows optional schema inclusion with examples ('dbo.sp_GetUser' or 'sp_GetUser'), and clarifies the format. This adds substantial meaning beyond the bare schema.

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 specific action ('Get parameter information') and target resource ('for a stored procedure'), distinguishing it from sibling tools like list_stored_procs (which lists names) and call_stored_proc (which executes). The verb+resource combination is precise and unambiguous.

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

Usage Guidelines4/5

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

The description implies usage when parameter details are needed for a stored procedure, but does not explicitly state when to choose this over alternatives like describe_table or validate_query. It provides clear context (parameter information retrieval) but lacks explicit exclusions or comparison to siblings.

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