Skip to main content
Glama
gavxm
by gavxm

anilist_whoami

Read-only

Verify your AniList authentication and confirm which account is connected. Use this tool to debug token issues or check your setup.

Instructions

Check which AniList account is authenticated and verify the token works. Use when the user wants to confirm their setup or debug auth issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The execute handler for the anilist_whoami tool. Checks for ANILIST_TOKEN, queries the AniList Viewer API to get authenticated user info (name, ID, score format, profile URL), and compares it with ANILIST_USERNAME env var.
    execute: async () => {
      if (!process.env.ANILIST_TOKEN) {
        const lines = [
          "ANILIST_TOKEN is not set.",
          "Set it to enable authenticated features (write operations, score format detection).",
          "Get a token at: https://anilist.co/settings/developer",
        ];
        const envUser = process.env.ANILIST_USERNAME;
        if (envUser) {
          lines.push(
            "",
            `ANILIST_USERNAME is set to "${envUser}" (read-only mode).`,
          );
        }
        return lines.join("\n");
      }
    
      try {
        const data = await anilistClient.query<ViewerResponse>(
          VIEWER_QUERY,
          {},
          { cache: "stats" },
        );
    
        if (!data.Viewer) {
          return throwToolError(
            new Error("No viewer data returned"),
            "checking authentication",
          );
        }
        const v = data.Viewer;
        const lines = [
          `Authenticated as: ${v.name}`,
          `AniList ID: ${v.id}`,
          `Score format: ${v.mediaListOptions.scoreFormat}`,
          `Profile: ${v.siteUrl}`,
        ];
    
        // Check if Anilist username matches
        const envUser = process.env.ANILIST_USERNAME;
        if (envUser) {
          const match = envUser.toLowerCase() === v.name.toLowerCase();
          lines.push(
            "",
            match
              ? `ANILIST_USERNAME "${envUser}" matches authenticated user.`
              : `ANILIST_USERNAME "${envUser}" does not match authenticated user "${v.name}".`,
          );
        } else {
          lines.push(
            "",
            "ANILIST_USERNAME is not set. Tools will require a username argument.",
          );
        }
    
        return lines.join("\n");
      } catch (error) {
        return throwToolError(error, "checking authentication");
      }
    },
  • Empty input schema (z.object({})) for anilist_whoami, as it requires no parameters.
    parameters: z.object({}),
  • Registration via registerInfoTools() which calls server.addTool() to register anilist_whoami on the FastMCP server.
    export function registerInfoTools(server: FastMCP): void {
      // === Who Am I ===
    
      server.addTool({
        name: "anilist_whoami",
        description:
          "Check which AniList account is authenticated and verify the token works. " +
          "Use when the user wants to confirm their setup or debug auth issues.",
        parameters: z.object({}),
        annotations: {
          title: "Who Am I",
          readOnlyHint: true,
          destructiveHint: false,
          openWorldHint: true,
        },
        execute: async () => {
          if (!process.env.ANILIST_TOKEN) {
            const lines = [
              "ANILIST_TOKEN is not set.",
              "Set it to enable authenticated features (write operations, score format detection).",
              "Get a token at: https://anilist.co/settings/developer",
            ];
            const envUser = process.env.ANILIST_USERNAME;
            if (envUser) {
              lines.push(
                "",
                `ANILIST_USERNAME is set to "${envUser}" (read-only mode).`,
              );
            }
            return lines.join("\n");
          }
    
          try {
            const data = await anilistClient.query<ViewerResponse>(
              VIEWER_QUERY,
              {},
              { cache: "stats" },
            );
    
            if (!data.Viewer) {
              return throwToolError(
                new Error("No viewer data returned"),
                "checking authentication",
              );
            }
            const v = data.Viewer;
            const lines = [
              `Authenticated as: ${v.name}`,
              `AniList ID: ${v.id}`,
              `Score format: ${v.mediaListOptions.scoreFormat}`,
              `Profile: ${v.siteUrl}`,
            ];
    
            // Check if Anilist username matches
            const envUser = process.env.ANILIST_USERNAME;
            if (envUser) {
              const match = envUser.toLowerCase() === v.name.toLowerCase();
              lines.push(
                "",
                match
                  ? `ANILIST_USERNAME "${envUser}" matches authenticated user.`
                  : `ANILIST_USERNAME "${envUser}" does not match authenticated user "${v.name}".`,
              );
            } else {
              lines.push(
                "",
                "ANILIST_USERNAME is not set. Tools will require a username argument.",
              );
            }
    
            return lines.join("\n");
          } catch (error) {
            return throwToolError(error, "checking authentication");
          }
        },
      });
  • VIEWER_QUERY - the GraphQL query used by the handler to fetch viewer data (id, name, avatar, siteUrl, mediaListOptions.scoreFormat).
    export const VIEWER_QUERY = `
      query Viewer {
        Viewer {
          id
          name
          avatar { medium }
          siteUrl
          mediaListOptions {
            scoreFormat
          }
        }
      }
    `;
  • ViewerResponse TypeScript interface defining the shape of the API response from the Viewer query.
    export interface ViewerResponse {
      Viewer: {
        id: number;
        name: string;
        avatar: { medium: string | null };
        siteUrl: string;
        mediaListOptions: {
          scoreFormat: ScoreFormat;
        };
      };
    }
Behavior4/5

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

Annotations already declare readOnlyHint=true. Description adds that it verifies token validity and identifies authenticated account, which is useful behavioral context beyond annotations.

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 sentences, front-loaded with action, no wasted words. Efficient and clear.

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

Completeness4/5

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

Description is sufficient for a no-parameter tool with no output schema. It explains purpose and usage. Could mention what the response contains, but not critical for selection.

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

Parameters4/5

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

No parameters; schema coverage is 100%. Description adds no param info as none needed. Baseline 4 as per rule for 0 parameters.

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?

Description explicitly states the tool checks which AniList account is authenticated and verifies the token, distinguishing it from sibling tools that handle data queries or modifications.

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?

Clearly states to use when confirming setup or debugging auth issues, providing direct context for when to invoke this tool.

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/gavxm/ani-mcp'

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