Skip to main content
Glama
MikelA92
by MikelA92

get_card

Retrieve a Metabase card by ID to view its SQL query and analyze how the question is constructed for data analysis purposes.

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 handler function that implements the 'get_card' tool logic. Fetches card details from Metabase API, extracts SQL query or query builder structure, and returns formatted information including ID, name, description, database, 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}`, }, ], }; }
  • Tool definition including name, description, and input schema requiring 'cardId' as integer.
    { 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'], }, },
  • Registration of the 'get_card' tool in the MCP server's executeTool switch statement, dispatching to cardHandlers.getCard.
    case 'get_card': return await this.cardHandlers.getCard(args.cardId); case 'list_cards':

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