add_movie_by_id
Add a specific movie to Radarr using its TMDb ID. Provide the movie's TMDb ID to initiate the download and organization process.
Instructions
Add a specific movie to Radarr using its TMDb ID.
Args: tmdb_id: The Movie Database ID for the movie root_folder: Optional root folder path (e.g., "/storage/movies")
Returns: Result of the add operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tmdb_id | Yes | ||
| root_folder | No |
Implementation Reference
- src/arr_assistant_mcp/main.py:351-372 (handler)The MCP tool handler function for 'add_movie_by_id', decorated with @mcp.tool for registration. It initializes MediaServerAPI and delegates to the add_movie_to_radarr helper.@mcp.tool async def add_movie_by_id(tmdb_id: int, root_folder: Optional[str] = None) -> AddMediaResponse: """ Add a specific movie to Radarr using its TMDb ID. Args: tmdb_id: The Movie Database ID for the movie root_folder: Optional root folder path (e.g., "/storage/movies") Returns: Result of the add operation """ if not config: raise ValueError("Server not configured. Please set up Radarr API key.") api = MediaServerAPI(config) # Use TMDb ID as title placeholder - Radarr will fetch the real title title = f"Movie (TMDb ID: {tmdb_id})" return await api.add_movie_to_radarr(tmdb_id, title, root_folder)
- Core helper method in MediaServerAPI class that performs the HTTP POST to Radarr API to add the movie using TMDb ID, handling root folder selection and error cases.async def add_movie_to_radarr(self, tmdb_id: int, title: str, root_folder: Optional[str] = None) -> AddMediaResponse: """Add movie to Radarr""" url = f"{self.config.radarr_url}/api/v3/movie" headers = {"X-Api-Key": self.config.radarr_api_key} # Use provided title - Radarr will fetch additional details if not title: title = f"Movie (TMDb ID: {tmdb_id})" payload = { "title": title, "tmdbId": tmdb_id, "qualityProfileId": self.config.quality_profile_id, "monitored": True, "minimumAvailability": "announced", "addOptions": { "searchForMovie": True } } # Set root folder (parameter > config > auto-detect) if root_folder: payload["rootFolderPath"] = root_folder logger.info(f"Using specified root folder: {root_folder}") elif self.config.radarr_root_folder: payload["rootFolderPath"] = self.config.radarr_root_folder logger.info(f"Using configured root folder: {self.config.radarr_root_folder}") else: # Auto-detect first available root folder root_folders = await self.get_radarr_root_folders() if root_folders: payload["rootFolderPath"] = root_folders[0]["path"] logger.info(f"Using auto-detected Radarr root folder: {root_folders[0]['path']}") else: logger.warning("No Radarr root folders found - movie may fail to add") try: response = await self.client.post(url, json=payload, headers=headers) if response.status_code == 201: result = response.json() return AddMediaResponse( success=True, message=f"Successfully added '{title}' to Radarr", media_id=result.get("id") ) else: return AddMediaResponse( success=False, message=f"Failed to add movie: {response.text}" ) except Exception as e: logger.error(f"Radarr API error: {e}") return AddMediaResponse( success=False, message=f"Error communicating with Radarr: {str(e)}" )
- src/arr_assistant_mcp/main.py:43-47 (schema)Pydantic schema/model for the output response of the add_movie_by_id tool, used for validation and serialization.class AddMediaResponse(BaseModel): success: bool message: str media_id: Optional[int] = None