list_collections
List all Metabase collections accessible to the current user with optional filters for archived status, namespace, and personal collections.
Instructions
List all collections in Metabase that the current user has read permissions for.
Args: archived: If true, return only archived collections. exclude_other_user_collections: If true, hide other users' personal collections. namespace: Filter collections by namespace (e.g. "snippets" for snippet folders). personal_only: If true, return only personal collections (where personal_owner_id is not null).
Returns: Dictionary containing all collections with their metadata.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| archived | No | ||
| exclude_other_user_collections | No | ||
| namespace | No | ||
| personal_only | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.py:1825-1867 (handler)The 'list_collections' tool handler function. Decorated with @mcp.tool, it calls the Metabase API GET /collection with optional query parameters (archived, exclude_other_user_collections, namespace, personal_only) and returns a dictionary of collections.
@mcp.tool async def list_collections( ctx: Context, archived: bool = False, exclude_other_user_collections: bool = False, namespace: str | None = None, personal_only: bool = False, ) -> dict[str, Any]: """ List all collections in Metabase that the current user has read permissions for. Args: archived: If true, return only archived collections. exclude_other_user_collections: If true, hide other users' personal collections. namespace: Filter collections by namespace (e.g. "snippets" for snippet folders). personal_only: If true, return only personal collections (where personal_owner_id is not null). Returns: Dictionary containing all collections with their metadata. """ try: await ctx.info("Fetching list of collections") query_params: dict[str, Any] = {} if archived: query_params["archived"] = "true" if exclude_other_user_collections: query_params["exclude-other-user-collections"] = "true" if namespace is not None: query_params["namespace"] = namespace if personal_only: query_params["personal-only"] = "true" result = await metabase_client.request("GET", "/collection", params=query_params or None) if isinstance(result, list): collection_count = len(result) await ctx.info(f"Successfully retrieved {collection_count} collections") return {"data": result, "total": collection_count} collection_count = len(result.get("data", [])) await ctx.info(f"Successfully retrieved {collection_count} collections") return result except Exception as e: error_msg = f"Error listing collections: {e}" await ctx.error(error_msg) raise ToolError(error_msg) from e - server.py:1825-1826 (registration)The @mcp.tool decorator on the list_collections function registers this tool with the FastMCP server.
@mcp.tool async def list_collections(