Skip to main content
Glama
CW-Codewalnut

Metabase MCP Server

delete_metabase_card

Remove unwanted or outdated cards from your Metabase BI platform to maintain organized dashboards and reports.

Instructions

Delete a card from Metabase.

Args: card_id (int): ID of the card to delete.

Returns: Dict[str, Any]: Deletion confirmation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
card_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for delete_metabase_card tool. It's decorated with @mcp.tool() to register it as an MCP tool. The async function takes a card_id parameter and calls make_metabase_request with RequestMethod.DELETE to delete the card from Metabase via the /api/card/{card_id} endpoint.
    @mcp.tool()
    async def delete_metabase_card(card_id: int) -> Dict[str, Any]:
        """
        Delete a card from Metabase.
    
        Args:
            card_id (int): ID of the card to delete.
    
        Returns:
            Dict[str, Any]: Deletion confirmation.
        """
        logger.info(f"Deleting card {card_id}")
        return await make_metabase_request(RequestMethod.DELETE, f"/api/card/{card_id}")
  • Helper function make_metabase_request that executes HTTP requests to the Metabase API. It handles request construction, error handling, and response parsing. Used by delete_metabase_card to make the actual DELETE request to Metabase.
    async def make_metabase_request(
        method: RequestMethod,
        endpoint: str,
        data: Optional[Dict[str, Any] | bytes] = None,
        params: Optional[Dict[str, Any]] = None,
        json: Any = None,
        headers: Optional[Dict[str, str]] = None,
    ) -> Dict[str, Any]:
        """
        Make a request to the Metabase API.
        
        Args:
            method: HTTP method to use (GET, POST, PUT, DELETE)
            endpoint: API endpoint path
            data: Request data (for form data)
            params: URL parameters
            json: JSON request body
            headers: Additional headers
            
        Returns:
            Dict[str, Any]: Response data
            
        Raises:
            MetabaseConnectionError: When the Metabase server is unreachable
            MetabaseResponseError: When Metabase returns a non-2xx status code
            RuntimeError: For other errors
        """
        
        if not METABASE_URL or not METABASE_API_KEY:
            raise RuntimeError("METABASE_URL or METABASE_API_KEY environment variable is not set. Metabase API requests will fail.")
    
        if session is None:
            raise RuntimeError("HTTP session is not initialized. Ensure app_lifespan was called.")
    
        try:
            request_headers = headers or {}
            
            logger.debug(f"Making {method.name} request to {METABASE_URL}{endpoint}")
            
            # Log request payload for debugging (omit sensitive info)
            if json and logger.level <= logging.DEBUG:
                sanitized_json = {**json}
                if 'password' in sanitized_json:
                    sanitized_json['password'] = '********'
                logger.debug(f"Request payload: {sanitized_json}")
                
            response = await session.request(
                method=method.name,
                url=endpoint,
                timeout=aiohttp.ClientTimeout(total=30),
                headers=request_headers,
                data=data,
                params=params,
                json=json,
            )
    
            try:
                # Handle 500 errors with more detailed info
                if response.status >= 500:
  • Creation of the FastMCP server instance named 'metabase' with a lifespan manager. This is the MCP server that all @mcp.tool() decorated functions are registered with, including delete_metabase_card.
    mcp = FastMCP("metabase", lifespan=app_lifespan)
  • RequestMethod enum defining HTTP methods (GET, POST, PUT, DELETE). Used by delete_metabase_card to specify RequestMethod.DELETE when calling make_metabase_request. Provides type-safe HTTP method constants.
    from enum import Enum, auto
    
    class RequestMethod(Enum):
        GET = auto()
        POST = auto()
        PUT = auto()
        DELETE = auto()
    
        def __str__(self):
            return self.name
Behavior2/5

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

No annotations are provided, so the description carries full burden. While 'Delete' implies a destructive mutation, the description doesn't disclose critical behavioral traits: whether deletion is permanent or reversible, what permissions are required, whether it affects dependent resources, or any rate limits. The 'Returns' section mentions a confirmation but doesn't describe its structure or meaning.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with three sentences: purpose, args, and returns. It's front-loaded with the main action. The structure is clear but could be more efficient by integrating the parameter explanation into a single cohesive paragraph.

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

Completeness3/5

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

Given that this is a destructive mutation tool with no annotations and an output schema exists (though not shown), the description is minimally complete. It covers the basic purpose and parameter, but lacks important context about behavioral implications, error conditions, and usage guidelines that would be crucial for safe operation.

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?

The description adds the parameter 'card_id' with type 'int' and explanation 'ID of the card to delete', which provides basic semantics. However, with 0% schema description coverage and only 1 parameter, this is adequate but minimal. It doesn't explain where to find the card ID, format constraints, or validation rules.

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 'Delete a card from Metabase' which is a specific verb+resource combination. It distinguishes this from sibling tools like 'create_metabase_card' or 'update_metabase_card' by specifying the destructive delete operation. However, it doesn't explicitly differentiate from other delete operations like 'delete_metabase_dashboard' beyond the resource type.

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?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of prerequisites (e.g., needing the card ID), when not to use it (e.g., for soft deletion), or what happens after deletion. With multiple sibling delete tools, explicit differentiation would be helpful.

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/CW-Codewalnut/metabase-mcp-server'

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