Skip to main content
Glama

get_user_activity

Retrieve user activities from AniList by specifying the user ID, page number, and entries per page for streamlined activity tracking.

Instructions

Fetch activities from a user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoThe page number to display
perPageNoHow many entries to display on one page (max 25)
userYesThe user's AniList ID

Implementation Reference

  • The handler function that implements the core logic of the 'get_user_activity' tool by fetching activities for a given user using the AniList API and returning them as JSON or an error response.
    async ({ user, page, perPage }) => {
      try {
        const activities = await anilist.activity.getUserActivity(
          user,
          page,
          perPage,
        );
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(activities, null, 2),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [{ type: "text", text: `Error: ${error.message}` }],
          isError: true,
        };
      }
    },
  • The Zod input schema defining the parameters for the 'get_user_activity' tool: user (AniList ID), page (optional, default 1), perPage (optional, default 25, max 25).
    {
      user: z.number().describe("The user's AniList ID"),
      page: z
        .number()
        .optional()
        .default(1)
        .describe("The page number to display"),
      perPage: z
        .number()
        .optional()
        .default(25)
        .describe("How many entries to display on one page (max 25)"),
    },
  • The complete registration of the 'get_user_activity' tool within the registerActivityTools function using server.tool, including name, description, input schema, metadata hints, and handler.
    // anilist.activity.getUserActivity()
    server.tool(
      "get_user_activity",
      "Fetch activities from a user",
      {
        user: z.number().describe("The user's AniList ID"),
        page: z
          .number()
          .optional()
          .default(1)
          .describe("The page number to display"),
        perPage: z
          .number()
          .optional()
          .default(25)
          .describe("How many entries to display on one page (max 25)"),
      },
      {
        title: "Get a User's AniList Activities",
        readOnlyHint: true,
        openWorldHint: true,
      },
      async ({ user, page, perPage }) => {
        try {
          const activities = await anilist.activity.getUserActivity(
            user,
            page,
            perPage,
          );
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(activities, null, 2),
              },
            ],
          };
        } catch (error: any) {
          return {
            content: [{ type: "text", text: `Error: ${error.message}` }],
            isError: true,
          };
        }
      },
    );

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

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