Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
idYesOpaque result id returned by search

Implementation Reference

  • 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);
    }
  • 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}'`);
    }
  • 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"],
      },
    },
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, and the description does not disclose any behavioral traits beyond the basic fetch operation. No mention of side effects, permissions, or read-only nature.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences with no wasted words. The purpose and parameter usage are front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple fetch tool with one parameter and no output schema, the description sufficiently explains its purpose and integration with the search tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description repeats the schema's info ('opaque item id') without adding further detail or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Fetch a specific item returned by search', using a specific verb and resource. It distinguishes itself from sibling search tools that return lists.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description says it 'Accepts an opaque item id from the search tool', implying it should be used after a search. No exclusion clauses but clear usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/aplaceforallmystuff/mcp-arr'

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