Skip to main content
Glama
MikelA92

Metabase MCP Server

by MikelA92

get_card

Retrieve Metabase card details and SQL queries by ID to analyze question construction and understand underlying data logic.

Instructions

🔍 [SAFE] Get a Metabase card/question by ID, including its SQL query. Use this when you need to see the SQL behind a specific question or analyze how a card is built. Risk: None - read-only operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cardIdYesThe ID of the card/question to retrieve

Implementation Reference

  • The core handler function for the 'get_card' tool. Fetches card details from Metabase API, extracts SQL query or query builder structure, and returns formatted card information including metadata and query details.
      async getCard(cardId) {
        Validators.validateCardId(cardId);
        
        this.logger.debug('Getting card', { cardId });
        const card = await this.apiClient.makeRequest(`/api/card/${cardId}`);
        
        const sqlQuery = card.dataset_query?.native?.query || 'No native SQL query found';
        const queryBuilder = card.dataset_query?.query ? JSON.stringify(card.dataset_query.query, null, 2) : null;
        
        const cardInfo = {
          id: card.id,
          name: card.name,
          description: card.description,
          sqlQuery: sqlQuery,
          databaseId: card.dataset_query?.database,
          queryType: card.dataset_query?.type,
          createdAt: card.created_at,
          updatedAt: card.updated_at,
        };
    
        let queryDetails = '';
        if (card.dataset_query?.type === 'native') {
          queryDetails = `SQL Query:\n${sqlQuery}`;
        } else if (card.dataset_query?.type === 'query' && queryBuilder) {
          queryDetails = `Query Builder Structure:\n${queryBuilder}`;
        } else {
          queryDetails = 'No query information available';
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `Card Information:
    ID: ${cardInfo.id}
    Name: ${cardInfo.name}
    Description: ${cardInfo.description || 'No description'}
    Database ID: ${cardInfo.databaseId}
    Query Type: ${cardInfo.queryType}
    Created: ${cardInfo.createdAt}
    Updated: ${cardInfo.updatedAt}
    
    ${queryDetails}`,
            },
          ],
        };
      }
  • The tool definition including name, description, and input schema (JSON Schema) for validating 'get_card' tool calls.
    {
      name: 'get_card',
      description: '🔍 [SAFE] Get a Metabase card/question by ID, including its SQL query. Use this when you need to see the SQL behind a specific question or analyze how a card is built. Risk: None - read-only operation.',
      inputSchema: {
        type: 'object',
        properties: {
          cardId: {
            type: 'integer',
            description: 'The ID of the card/question to retrieve',
            minimum: 1,
          },
        },
        required: ['cardId'],
      },
    },
  • The registration/dispatch in the MCP server's executeTool switch statement that routes 'get_card' calls to the CardHandlers.getCard method.
    case 'get_card':
      return await this.cardHandlers.getCard(args.cardId);
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by explicitly stating 'read-only operation' and 'Risk: None'. It also discloses that it returns the SQL query, which is valuable behavioral context. It doesn't mention potential errors (e.g., invalid ID), rate limits, or authentication needs, keeping it from a perfect score.

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 disclosure. Every sentence earns its place: first states what it does, second when to use it, third safety profile. No wasted words, emoji adds visual cue without distraction.

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?

For a single-parameter read tool with no output schema, the description provides good context: purpose, usage, safety. It could mention what exactly is returned (beyond 'including its SQL query') or error cases, but given the simplicity and lack of output schema, it's mostly complete.

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 fully documents the single 'cardId' parameter. The description doesn't add any additional parameter semantics beyond what's in the schema (e.g., format examples, ID sourcing). Baseline 3 is appropriate when 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 ('Get a Metabase card/question by ID'), resource ('card/question'), and scope ('including its SQL query'). It distinguishes this tool from siblings like 'list_cards' (which lists multiple cards) and 'execute_card_query' (which runs the query rather than retrieving metadata).

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool ('when you need to see the SQL behind a specific question or analyze how a card is built'). It also distinguishes it from alternatives by specifying it's for retrieving a single card by ID (unlike 'list_cards' for multiple cards) and for getting metadata/SQL (unlike 'execute_card_query' for running queries).

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