Skip to main content
Glama
CW-Codewalnut

Metabase MCP Server

create_metabase_group

Create user groups in Metabase to manage permissions and organize team access to dashboards and data.

Instructions

Create a new group (role) in Metabase.

Args: name (str): Name of the group to create. ldap_dn (str, optional): LDAP Distinguished Name if applicable.

Returns: Dict[str, Any]: Created group metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
ldap_dnNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'create_metabase_group' tool. It creates a new group in Metabase by making a POST request to /api/permissions/group with the group name and optional LDAP DN. The @mcp.tool() decorator registers this as an MCP tool.
    @mcp.tool()
    async def create_metabase_group(
        name: str,
        ldap_dn: Optional[str] = None
    ) -> Dict[str, Any]:
        """
        Create a new group (role) in Metabase.
    
        Args:
            name (str): Name of the group to create.
            ldap_dn (str, optional): LDAP Distinguished Name if applicable.
    
        Returns:
            Dict[str, Any]: Created group metadata.
        """
        payload = {"name": name}
        if ldap_dn is not None:
            payload["ldap_dn"] = ldap_dn
    
        logger.info(f"Creating group '{name}'")
        return await make_metabase_request(RequestMethod.POST, "/api/permissions/group", json=payload)
  • Helper function that handles all HTTP requests to the Metabase API. It manages session initialization, error handling, response parsing, and logging. Used by create_metabase_group to make the actual POST request.
    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:
                    error_text = await response.text()
                    logger.error(f"Server error {response.status}: {error_text[:200]}")
                    raise MetabaseResponseError(response.status, f"Server Error: {error_text[:200]}", endpoint)
                
                response.raise_for_status()
                response_data = await response.json()
                
                # Ensure the response is a dictionary for FastMCP compatibility
                return ensure_dict_response(response_data)
                
            except aiohttp.ContentTypeError:
                # Handle empty responses or non-JSON responses
                content = await response.text()
                if not content:
                    return {"data": {}}
                logger.warning(f"Received non-JSON response: {content}")
                return {"data": content}
    
        except aiohttp.ClientConnectionError as e:
            logger.error(f"Connection error: {str(e)}")
            raise MetabaseConnectionError("Metabase is unreachable. Is the Metabase server running?") from e
        except aiohttp.ClientResponseError as e:
            logger.error(f"Response error: {e.status}, {e.message}, {e.request_info.url}")
            raise MetabaseResponseError(e.status, e.message, str(e.request_info.url)) from e
        except Exception as e:
            logger.error(f"Request error: {str(e)}")
            raise RuntimeError(f"Request error: {str(e)}") from e
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. While it correctly indicates this is a creation operation, it doesn't describe what happens after creation (e.g., whether the group becomes immediately active, default permissions, or if there are limitations on group names). It mentions LDAP integration but doesn't explain the implications. For a mutation tool with zero annotation coverage, this leaves significant behavioral gaps.

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 well-structured and appropriately sized. It begins with a clear purpose statement, then provides organized sections for Args and Returns with bullet-like formatting. Every sentence earns its place, with no redundant or unnecessary information. The formatting helps with readability despite being a single 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 creation tool with no annotations, 2 parameters (one optional), and an output schema exists (so return values are documented elsewhere), the description is moderately complete. It covers the basic purpose and parameters but lacks important context about permissions, error conditions, relationship to other tools, and behavioral details that would help an agent use it correctly in complex scenarios.

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

Parameters4/5

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

The description adds meaningful semantic context beyond the 0% schema description coverage. It explains that 'name' is for the group name and 'ldap_dn' is an optional LDAP Distinguished Name, clarifying what these parameters represent. However, it doesn't provide format requirements, length limits, or examples for either parameter, leaving some practical usage questions unanswered.

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 tool's purpose: 'Create a new group (role) in Metabase.' It specifies the verb ('Create') and resource ('group/role'), but doesn't explicitly differentiate it from sibling tools like 'create_metabase_user' or 'create_metabase_collection' beyond the resource type. The parenthetical '(role)' adds helpful clarification about what a 'group' represents in Metabase context.

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. It doesn't mention sibling tools like 'get_metabase_groups' (for listing existing groups) or 'delete_metabase_group' (for removal), nor does it specify prerequisites, permissions needed, or typical use cases for creating groups versus users or other resources.

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