get_anime
Retrieve detailed anime information using the AniList ID through the AniList MCP server. Simplify accessing accurate data for any anime.
Instructions
Get detailed information about an anime by its AniList ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The AniList ID of the anime |
Implementation Reference
- tools/media.ts:34-64 (handler)The core handler function for the 'get_anime' tool. It takes one or more AniList anime IDs, fetches the media details using the AniList client, optionally filters the response to essential fields, formats as JSON, and returns as text content. Handles single ID or array, and errors gracefully.async ({ ids, fullData }) => { try { const idArray = Array.isArray(ids) ? ids : [ids]; const results = await Promise.all( idArray.map((id) => anilist.media.anime(id)), ); // Filter results unless fullData is explicitly requested const filteredResults = fullData ? results : filterMedia(results); // Return single object if single ID was provided, array if multiple const res = Array.isArray(ids) ? filteredResults : (filteredResults as FilteredMediaEntry[])[0]; return { content: [ { type: "text", text: JSON.stringify(res, null, 2), }, ], }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }, );
- tools/media.ts:17-28 (schema)Input schema for the 'get_anime' tool defined using Zod. Supports single anime ID (number) or array of IDs, and optional boolean fullData flag to bypass filtering.{ ids: z .union([z.number(), z.array(z.number())]) .describe("The AniList ID or array of IDs of the anime"), fullData: z .boolean() .optional() .default(false) .describe( "Set to true to get full unfiltered data (may be very large). Default is false to return only essential fields.", ), },
- tools/media.ts:15-64 (registration)Direct registration of the 'get_anime' tool on the MCP server within registerMediaTools. Includes tool name, description, input schema, metadata hints (read-only, open-world), and inline handler function."get_anime", "Get detailed information about anime by AniList ID(s)", { ids: z .union([z.number(), z.array(z.number())]) .describe("The AniList ID or array of IDs of the anime"), fullData: z .boolean() .optional() .default(false) .describe( "Set to true to get full unfiltered data (may be very large). Default is false to return only essential fields.", ), }, { title: "Get Anime Details", readOnlyHint: true, openWorldHint: true, }, async ({ ids, fullData }) => { try { const idArray = Array.isArray(ids) ? ids : [ids]; const results = await Promise.all( idArray.map((id) => anilist.media.anime(id)), ); // Filter results unless fullData is explicitly requested const filteredResults = fullData ? results : filterMedia(results); // Return single object if single ID was provided, array if multiple const res = Array.isArray(ids) ? filteredResults : (filteredResults as FilteredMediaEntry[])[0]; return { content: [ { type: "text", text: JSON.stringify(res, null, 2), }, ], }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }, );
- tools/index.ts:34-34 (registration)Invocation of registerMediaTools in the central registerAllTools function, which registers the 'get_anime' tool among other media tools.registerMediaTools(server, anilist, config);
- utils/mediaFilter.ts:217-225 (helper)Helper function used in the 'get_anime' handler to filter large AniList media responses down to essential fields, reducing payload size. Supports single entry or array.export function filterMedia( media: AnimeEntry | MangaEntry | AnimeEntry[] | MangaEntry[], ): FilteredMediaEntry | FilteredMediaEntry[] { if (Array.isArray(media)) { return media.map((m) => filterSingleMedia(m)); } return filterSingleMedia(media); }