add_movie_by_id
Add a movie to Radarr using its TMDb ID, specifying an optional root folder for storage. Simplifies movie management by integrating with Radarr via direct ID input.
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 |
|---|---|---|---|
| root_folder | No | ||
| tmdb_id | Yes |
Implementation Reference
- src/arr_assistant_mcp/main.py:351-372 (handler)The main handler function for the 'add_movie_by_id' MCP tool. It is registered via the @mcp.tool decorator and implements the core logic by instantiating MediaServerAPI and calling its add_movie_to_radarr method.@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)
- src/arr_assistant_mcp/main.py:43-47 (schema)Pydantic BaseModel defining the output schema for the add_movie_by_id tool response.class AddMediaResponse(BaseModel): success: bool message: str media_id: Optional[int] = None
- Supporting helper method in MediaServerAPI class that handles the HTTP POST request to Radarr's API to add the movie, including payload construction, root folder selection, and error handling.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:351-351 (registration)The @mcp.tool decorator from FastMCP that registers the add_movie_by_id function as an MCP tool.@mcp.tool