create_collection
Create a new collection in Metabase to organize your data. Specify name, optional description, color, and parent collection ID.
Instructions
Create a new collection in Metabase.
Args: name: Name of the collection. description: Optional description. color: Optional color for the collection. parent_id: Optional parent collection ID.
Returns: The created collection object.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| description | No | ||
| color | No | ||
| parent_id | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.py:1870-1911 (handler)The create_collection tool handler: creates a new Metabase collection via POST /api/collection with optional name, description, color, and parent_id.
@mcp.tool async def create_collection( name: str, ctx: Context, description: str | None = None, color: str | None = None, parent_id: int | None = None, ) -> dict[str, Any]: """ Create a new collection in Metabase. Args: name: Name of the collection. description: Optional description. color: Optional color for the collection. parent_id: Optional parent collection ID. Returns: The created collection object. """ try: await ctx.info(f"Creating new collection '{name}'") payload = {"name": name} if description: payload["description"] = description if color: payload["color"] = color await ctx.debug(f"Collection color: {color}") if parent_id is not None: payload["parent_id"] = parent_id await ctx.debug(f"Collection parent ID: {parent_id}") result = await metabase_client.request("POST", "/collection", json=payload) await ctx.info(f"Successfully created collection with ID {result.get('id')}") return result except Exception as e: error_msg = f"Error creating collection: {e}" await ctx.error(error_msg) raise ToolError(error_msg) from e - server.py:1870-1870 (registration)Registration of create_collection as an MCP tool via the @mcp.tool decorator.
@mcp.tool - server.py:1878-1889 (schema)Docstring/input schema for create_collection defining parameters: name (required), description, color, parent_id (optional).
""" Create a new collection in Metabase. Args: name: Name of the collection. description: Optional description. color: Optional color for the collection. parent_id: Optional parent collection ID. Returns: The created collection object. """