tag_assets
Apply a tag to multiple assets to bulk-categorize photos. Use this to tag all vacation photos at once.
Instructions
Apply a tag to multiple assets at once. Use this to bulk-categorize photos (e.g. tag all vacation photos). Side effect: adds tag association to assets.
Args:
tag_id: The tag UUID to apply (from list_tags or create_tag).
asset_ids: List of asset UUIDs to tag. Must not be empty.
Returns: JSON with tag_id, count tagged, and per-asset results.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tag_id | Yes | ||
| asset_ids | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- MCP tool handler for tag_assets — applies a tag to multiple assets, delegates to ImmichClient.tag_assets() for the HTTP request.
@mcp.tool() async def tag_assets(ctx: Context, tag_id: str, asset_ids: list[str]) -> str: """Apply a tag to multiple assets at once. Use this to bulk-categorize photos (e.g. tag all vacation photos). Side effect: adds tag association to assets. Args: tag_id: The tag UUID to apply (from list_tags or create_tag). asset_ids: List of asset UUIDs to tag. Must not be empty. Returns: JSON with tag_id, count tagged, and per-asset results. """ if not asset_ids: return json.dumps({"error": "asset_ids cannot be empty."}) try: result = await _client(ctx).tag_assets(tag_id, asset_ids) return json.dumps({"tag_id": tag_id, "tagged": len(asset_ids), "result": result}, default=str) except httpx.HTTPStatusError as e: return json.dumps({"error": f"Immich API error: {e.response.status_code}", "detail": e.response.text[:200]}) - src/immich_mcp_server/server.py:1205-1206 (registration)The @mcp.tool() decorator registers 'tag_assets' as an MCP tool on the FastMCP server instance.
@mcp.tool() async def tag_assets(ctx: Context, tag_id: str, asset_ids: list[str]) -> str: - ImmichClient.tag_assets() — helper method that sends a PUT request to /tags/{tag_id}/assets with the asset IDs, performing the actual Immich API call to tag assets.
async def tag_assets(self, tag_id: str, asset_ids: list[str]) -> list[dict]: """Add a tag to multiple assets.""" return await self._request( "PUT", f"/tags/{tag_id}/assets", json={"ids": asset_ids} )