Skip to main content
Glama

mcp_execute_procedure

Execute SQL Server stored procedures with parameters to retrieve database results for data analysis and manipulation tasks.

Instructions

Execute a SQL Server stored procedure with parameters and return results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sp_nameYesFully qualified stored procedure name (schema.name), e.g. "api.usp_BusquedaByIdUnico_v2"
paramsNoParameters to pass to the stored procedure as key-value pairs

Implementation Reference

  • Main handler function that validates permissions, executes the SQL stored procedure using the database connection pool, handles parameters, and returns the recordset or error.
    export const mcp_execute_procedure = async (args: { sp_name: string; params?: object }): Promise<ToolResult<any[]>> => {
      const { sp_name, params } = args;
      console.log('Executing mcp_execute_procedure with:', args);
    
      // Security validation for stored procedure execution
      const permission = validateStoredProcedurePermission(sp_name);
      if (!permission.allowed) {
        return { success: false, error: permission.message || 'Stored procedure execution not allowed' };
      }
    
      try {
        const pool = getPool();
        const request = pool.request();
    
        if (params) {
          for (const [key, value] of Object.entries(params)) {
            request.input(key, value);
          }
        }
    
        const result = await request.execute(sp_name);
        return { success: true, data: result.recordset };
      } catch (error: any) {
        console.error(`Error in mcp_execute_procedure for SP ${sp_name}: ${error.message}`);
        return { success: false, error: error.message };
      }
    };
  • src/tools.ts:82-99 (registration)
    Tool registration in the MCP_MSQL_TOOLS array, defining the tool name, description, and input schema. This array is used by the MCP server for tool listing.
    {
      name: "mcp_execute_procedure",
      description: "Execute a SQL Server stored procedure with parameters and return results",
      inputSchema: {
        type: "object",
        properties: {
          sp_name: {
            type: "string",
            description: "Fully qualified stored procedure name (schema.name), e.g. \"api.usp_BusquedaByIdUnico_v2\""
          },
          params: {
            type: "object",
            description: "Parameters to pass to the stored procedure as key-value pairs"
          }
        },
        required: ["sp_name"]
      }
    },
  • JSON schema defining the input parameters for the mcp_execute_procedure tool: required sp_name string and optional params object.
    inputSchema: {
      type: "object",
      properties: {
        sp_name: {
          type: "string",
          description: "Fully qualified stored procedure name (schema.name), e.g. \"api.usp_BusquedaByIdUnico_v2\""
        },
        params: {
          type: "object",
          description: "Parameters to pass to the stored procedure as key-value pairs"
        }
      },
      required: ["sp_name"]
    }
  • src/server.ts:64-66 (registration)
    MCP server registration for ListToolsRequestSchema that returns the MCP_MSQL_TOOLS array containing the tool definition.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: MCP_MSQL_TOOLS
    }));
  • Re-export of the mcp_execute_procedure handler from dataOperations.ts, used by mcp-server.ts to provide tool handlers.
    export {
      mcp_execute_procedure, // Execute stored procedure
      mcp_execute_query       // Execute SQL query
    } from './dataOperations.js';
Behavior2/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 states the tool executes stored procedures and returns results, but lacks details on permissions required, transaction handling, error behavior, or output format. This is a significant gap for a tool that performs database operations.

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 a single, efficient sentence that front-loads the core functionality without unnecessary words. It directly communicates the tool's purpose and scope, making it easy to understand at a glance.

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

Completeness2/5

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

Given the complexity of executing stored procedures in SQL Server, the description is insufficient. With no annotations, no output schema, and incomplete behavioral details, it fails to address critical aspects like security requirements, result formatting, or error handling, leaving significant gaps for an AI agent to use it effectively.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema fully documents both parameters. The description adds minimal value beyond the schema by mentioning 'parameters and return results,' but doesn't provide additional context on parameter formatting, validation, or result structure. Baseline 3 is appropriate given the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Execute') and resource ('SQL Server stored procedure'), specifying it handles parameters and returns results. It distinguishes from generic query execution tools but doesn't explicitly differentiate from sibling 'mcp_execute_query' beyond the stored procedure focus.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'mcp_execute_query' for direct SQL queries or 'mcp_sp_structure' for examining stored procedures. The description implies usage for stored procedures but offers no context on prerequisites, limitations, or comparative use cases.

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/hendrickcastro/MCPQL'

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