Skip to main content
Glama
MikelA92

Metabase MCP Server

by MikelA92

execute_card_query

Execute saved Metabase card queries to retrieve data results. Use this tool to run pre-defined queries with optional parameters for filtering.

Instructions

▶️ [MODERATE RISK] Execute a saved card query and return results. Use this to get actual data from a card. May take time for complex queries. Risk: Moderate - executes queries that may be slow or resource-intensive. Does not modify data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cardIdYesThe ID of the card to execute
parametersNoQuery parameters (e.g., date filters, IDs)

Implementation Reference

  • The core handler function that implements the execute_card_query tool. It validates the cardId, constructs query parameters, makes a POST request to Metabase's /api/card/{cardId}/query endpoint, and formats the results as MCP content.
      async executeCardQuery(cardId, parameters = {}) {
        Validators.validateCardId(cardId);
        
        this.logger.debug('Executing card query', { cardId, parameters });
        
        const queryParams = new URLSearchParams();
        Object.entries(parameters).forEach(([key, value]) => {
          queryParams.append(key, value);
        });
    
        const results = await this.apiClient.makeRequest(`/api/card/${cardId}/query?${queryParams}`, {
          method: 'POST',
        });
        
        return {
          content: [
            {
              type: 'text',
              text: `Query Results for Card ${cardId}:
    ${JSON.stringify(results, null, 2)}`,
            },
          ],
        };
      }
  • The JSON schema definition for the execute_card_query tool, specifying input validation for cardId (required integer) and optional parameters object. Used for tool listing and validation.
    {
      name: 'execute_card_query',
      description: '▶️ [MODERATE RISK] Execute a saved card query and return results. Use this to get actual data from a card. May take time for complex queries. Risk: Moderate - executes queries that may be slow or resource-intensive. Does not modify data.',
      inputSchema: {
        type: 'object',
        properties: {
          cardId: {
            type: 'integer',
            description: 'The ID of the card to execute',
            minimum: 1,
          },
          parameters: {
            type: 'object',
            description: 'Query parameters (e.g., date filters, IDs)',
            additionalProperties: true,
          },
        },
        required: ['cardId'],
      },
    },
  • Registration of the execute_card_query tool in the server's executeTool switch statement, which dispatches tool calls to the appropriate handler method.
    case 'execute_card_query':
      return await this.cardHandlers.executeCardQuery(args.cardId, args.parameters);
Behavior4/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 key traits: the operation is read-only ('does not modify data'), may have performance implications ('may take time for complex queries'), and carries moderate risk due to resource intensity. However, it lacks details on error handling or response format.

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 front-loaded with the core purpose, followed by usage guidance and risk information in three concise sentences. Each sentence earns its place by adding distinct value: action, context, and behavioral transparency without redundancy.

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 complexity (moderate risk, potential slowness) and lack of annotations or output schema, the description is reasonably complete. It covers purpose, usage, and key behavioral traits, but could improve by detailing the return format or error conditions to fully compensate for the missing structured data.

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 already documents both parameters ('cardId' and 'parameters'). The description adds minimal value beyond the schema by mentioning 'query parameters (e.g., date filters, IDs)' in context, but does not provide additional syntax or usage details. Baseline 3 is appropriate as the schema does the heavy lifting.

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 ('execute a saved card query') and resource ('card'), distinguishing it from siblings like 'get_card' (which likely retrieves metadata) or 'execute_native_query' (which might run raw SQL). It specifies the outcome ('return results') and clarifies the tool's role in data retrieval.

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 provides clear context on when to use this tool ('to get actual data from a card'), but does not explicitly state when not to use it or name alternatives. It implies usage for executing saved queries rather than creating or modifying them, which helps differentiate from other tools in the list.

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/MikelA92/metabase-mcp-mab'

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