fetch
Retrieve a specific media item using its search result ID. Works with TV shows, movies, music, and books from *arr applications.
Instructions
Fetch a specific item returned by search. Accepts an opaque item id from the search tool.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Opaque result id returned by search |
Implementation Reference
- src/index.ts:1147-1151 (handler)The tool handler for 'fetch' - extracts the 'id' argument and calls fetchSearchEntry() to retrieve the item details.
case "fetch": { const id = (args as { id: string }).id; const result = await fetchSearchEntry(id); return jsonText(result); } - src/index.ts:1006-1081 (helper)Helper function that resolves an opaque search result ID by parsing its colon-delimited format and fetching the full details from the appropriate source (TRaSH profile or *arr service).
async function fetchSearchEntry(id: string): Promise<unknown> { const [kind, service, subtype, rawId] = id.split(":"); if (kind === "trash-profile" && (service === "radarr" || service === "sonarr")) { const profile = await trashClient.getProfile(service, rawId); if (!profile) { throw new Error(`TRaSH profile '${rawId}' not found for ${service}`); } return { id, title: `${profile.name} (${service})`, url: buildResourceUrl(`trash/profile/${service}/${encodeURIComponent(profile.name)}`), service, type: "trash_profile", data: { name: profile.name, description: profile.trash_description?.replace(/<br>/g, "\n"), upgradeAllowed: profile.upgradeAllowed, cutoff: profile.cutoff, minFormatScore: profile.minFormatScore, cutoffFormatScore: profile.cutoffFormatScore, language: profile.language, qualities: profile.items, customFormats: Object.entries(profile.formatItems || {}).map(([name, trashId]) => ({ name, trash_id: trashId, })), }, }; } if (kind !== "arr") { throw new Error(`Unsupported fetch id '${id}'`); } if (service === "sonarr" && subtype === "series" && clients.sonarr) { const tvdbId = Number(rawId); const matches = (await clients.sonarr.searchSeries(rawId)).filter((item) => item.tvdbId === tvdbId); return { id, title: matches[0]?.title || rawId, url: buildResourceUrl(`arr/sonarr/series/${rawId}`), service, type: subtype, data: matches.slice(0, 10), }; } if (service === "radarr" && subtype === "movie" && clients.radarr) { const tmdbId = Number(rawId); const matches = (await clients.radarr.searchMovies(rawId)).filter((item) => item.tmdbId === tmdbId); return { id, title: matches[0]?.title || rawId, url: buildResourceUrl(`arr/radarr/movie/${rawId}`), service, type: subtype, data: matches.slice(0, 10), }; } if (service === "lidarr" && subtype === "artist" && clients.lidarr) { const matches = (await clients.lidarr.searchArtists(rawId)).filter((item) => item.foreignArtistId === rawId); return { id, title: matches[0]?.artistName || matches[0]?.title || rawId, url: buildResourceUrl(`arr/lidarr/artist/${rawId}`), service, type: subtype, data: matches.slice(0, 10), }; } throw new Error(`Unsupported or unavailable fetch target '${id}'`); } - src/index.ts:112-125 (schema)The schema/registration for the 'fetch' tool, defining its input as a required string 'id'.
{ name: "fetch", description: "Fetch a specific item returned by search. Accepts an opaque item id from the search tool.", inputSchema: { type: "object" as const, properties: { id: { type: "string", description: "Opaque result id returned by search", }, }, required: ["id"], }, }, - src/index.ts:112-125 (registration)The 'fetch' tool is registered in the TOOLS array that is returned by ListToolsRequestSchema handler.
{ name: "fetch", description: "Fetch a specific item returned by search. Accepts an opaque item id from the search tool.", inputSchema: { type: "object" as const, properties: { id: { type: "string", description: "Opaque result id returned by search", }, }, required: ["id"], }, },