Skip to main content
Glama
omniwaifu

arr-assistant-mcp

by omniwaifu

add_show_by_tvdb_id

Add a TV show to Sonarr using its TVDB ID. Specify the show's title and optional root folder for organized storage. Simplifies show management with direct integration.

Instructions

Add a specific TV show to Sonarr using its TVDB ID.

Args: tvdb_id: The TV Database ID for the show title: The title of the show root_folder: Optional root folder path (e.g., "/storage/anime")

Returns: Result of the add operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
root_folderNo
titleYes
tvdb_idYes

Implementation Reference

  • The main handler function for the 'add_show_by_tvdb_id' MCP tool. Decorated with @mcp.tool for automatic registration. Validates config and delegates to MediaServerAPI.add_series_to_sonarr.
    @mcp.tool async def add_show_by_tvdb_id(tvdb_id: int, title: str, root_folder: Optional[str] = None) -> AddMediaResponse: """ Add a specific TV show to Sonarr using its TVDB ID. Args: tvdb_id: The TV Database ID for the show title: The title of the show root_folder: Optional root folder path (e.g., "/storage/anime") Returns: Result of the add operation """ if not config: raise ValueError("Server not configured. Please set up Sonarr API key.") api = MediaServerAPI(config) return await api.add_series_to_sonarr(tvdb_id, title, root_folder)
  • Pydantic BaseModel defining the return type/schema for the tool's response, used across add operations.
    class AddMediaResponse(BaseModel): success: bool message: str media_id: Optional[int] = None
  • The @mcp.tool decorator registers the function as an MCP tool.
    @mcp.tool
  • Supporting method in MediaServerAPI class that implements the core logic of adding a TV series to Sonarr via its REST API using TVDB ID, handling root folder selection and error cases.
    async def add_series_to_sonarr(self, tvdb_id: int, title: str, root_folder: Optional[str] = None) -> AddMediaResponse: """Add TV series to Sonarr using TVDB ID""" url = f"{self.config.sonarr_url}/api/v3/series" headers = {"X-Api-Key": self.config.sonarr_api_key} payload = { "title": title, "tvdbId": tvdb_id, "qualityProfileId": self.config.quality_profile_id, "monitored": True, "seasonFolder": True, "addOptions": { "searchForMissingEpisodes": 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.sonarr_root_folder: payload["rootFolderPath"] = self.config.sonarr_root_folder logger.info(f"Using configured root folder: {self.config.sonarr_root_folder}") else: # Auto-detect first available root folder root_folders = await self.get_sonarr_root_folders() if root_folders: payload["rootFolderPath"] = root_folders[0]["path"] logger.info(f"Using auto-detected Sonarr root folder: {root_folders[0]['path']}") else: logger.warning("No Sonarr root folders found - series 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 Sonarr", media_id=result.get("id") ) else: return AddMediaResponse( success=False, message=f"Failed to add series: {response.text}" ) except Exception as e: logger.error(f"Sonarr API error: {e}") return AddMediaResponse( success=False, message=f"Error communicating with Sonarr: {str(e)}" )

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/omniwaifu/arr-assistant-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server