Skip to main content
Glama

anilist-mcp

MIT License
112
54
  • Apple
  • Linux
people.ts6.1 kB
import { z } from "zod"; import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import type AniList from "@yuna0x0/anilist-node"; import type { ConfigSchema } from "../utils/schemas.js"; import { requireAuth } from "../utils/auth.js"; export function registerPeopleTools( server: McpServer, anilist: AniList, config: z.infer<typeof ConfigSchema>, ) { // anilist.people.character() server.tool( "get_character", "Get information about a character by their AniList ID or name", { id: z .union([z.number(), z.string()]) .describe("The AniList ID of the character"), }, { title: "Get Character Info", readOnlyHint: true, openWorldHint: true, }, async ({ id }) => { try { const character = await anilist.people.character(id); return { content: [ { type: "text", text: JSON.stringify(character, null, 2), }, ], }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }, ); // anilist.people.favouriteChar() server.tool( "favourite_character", "[Requires Login] Favourite or unfavourite a character by its ID", { id: z .number() .describe("The AniList ID of the character to favourite/unfavourite"), }, { title: "Favourite/Unfavourite Character", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true, }, async ({ id }) => { try { const auth = requireAuth(config.anilistToken); if (!auth.isAuthorized) { return auth.errorResponse; } const result = await anilist.people.favouriteChar(id); return { content: [ { type: "text", text: result ? `Successfully added character with ID ${id} to favourites.` : `Character with ID ${id} was removed from favourites or operation failed.`, }, ], }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }, ); // anilist.people.favouriteStaff() server.tool( "favourite_staff", "[Requires Login] Favourite or unfavourite a staff member by their ID", { id: z .number() .describe( "The AniList ID of the staff member to favourite/unfavourite", ), }, { title: "Favourite/Unfavourite Staff Member", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true, }, async ({ id }) => { try { const auth = requireAuth(config.anilistToken); if (!auth.isAuthorized) { return auth.errorResponse; } const result = await anilist.people.favouriteStaff(id); return { content: [ { type: "text", text: result ? `Successfully added staff member with ID ${id} to favourites.` : `Staff member with ID ${id} was removed from favourites or operation failed.`, }, ], }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }, ); // anilist.people.getBirthdayCharacters() server.tool( "get_todays_birthday_characters", "Get all characters whose birthday is today", { page: z .number() .optional() .default(1) .describe("What page in the search to target"), }, { title: "Get Today's Birthday Characters", readOnlyHint: true, openWorldHint: true, }, async ({ page }) => { try { const characters = await anilist.people.getBirthdayCharacters(page); return { content: [ { type: "text", text: JSON.stringify(characters, null, 2), }, ], }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }, ); // anilist.people.getBirthdayStaff() server.tool( "get_todays_birthday_staff", "Get all staff members whose birthday is today", { page: z .number() .optional() .default(1) .describe("What page in the search to target"), }, { title: "Get Today's Birthday Staff Members", readOnlyHint: true, openWorldHint: true, }, async ({ page }) => { try { const staffMembers = await anilist.people.getBirthdayStaff(page); return { content: [ { type: "text", text: JSON.stringify(staffMembers, null, 2), }, ], }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }, ); // anilist.people.staff() server.tool( "get_staff", "Get information about staff member by their AniList ID or name", { id: z .union([z.number(), z.string()]) .describe("The AniList ID or name of the staff member"), }, { title: "Get Staff Member Info", readOnlyHint: true, openWorldHint: true, }, async ({ id }) => { try { const staff = await anilist.people.staff(id); return { content: [ { type: "text", text: JSON.stringify(staff, null, 2), }, ], }; } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }, ); }

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/yuna0x0/anilist-mcp'

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