Skip to main content
Glama

List Notifications

list_notifications

Retrieve user notifications with pagination and filtering by read status, using offset or cursor.

Instructions

Get user notifications.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
firstNoNumber of notifications to fetch
offsetNoOffset for pagination
afterNoCursor for pagination
unreadOnlyNoShow only unread notifications

Implementation Reference

  • The handler function for the 'list_notifications' tool. It sends a GraphQL query to fetch user notifications with pagination (first, offset, after) and optional unreadOnly filter, then returns the results via the text() helper.
    const listNotificationsHandler = async ({ first = 20, offset, after, unreadOnly = false }: { first?: number; offset?: number; after?: string; unreadOnly?: boolean }) => {
      try {
        const query = `
          query GetNotifications($pagination: PaginationInput!) {
            currentUser {
              notifications(pagination: $pagination) {
                edges {
                  cursor
                  node {
                    id
                    type
                    body
                    read
                    level
                    createdAt
                    updatedAt
                  }
                }
                totalCount
                pageInfo {
                  hasNextPage
                  endCursor
                }
              }
            }
          }
        `;
        
        const data = await gql.request<{ currentUser: { notifications: any } }>(query, {
          pagination: {
            first,
            offset,
            after
          }
        });
        
        let notifications = (data.currentUser?.notifications?.edges || []).map((edge: any) => edge.node);
        if (unreadOnly) {
          notifications = notifications.filter((n: any) => !n.read);
        }
        
        return text(notifications);
      } catch (error: any) {
        return text({ error: error.message });
      }
    };
  • The registration of the 'list_notifications' tool on the MCP server, including the input schema with Zod validators for 'first', 'offset', 'after', and 'unreadOnly' parameters.
    server.registerTool(
      "list_notifications",
      {
        title: "List Notifications",
        description: "Get user notifications.",
        inputSchema: {
          first: z.number().optional().describe("Number of notifications to fetch"),
          offset: z.number().optional().describe("Offset for pagination"),
          after: z.string().optional().describe("Cursor for pagination"),
          unreadOnly: z.boolean().optional().describe("Show only unread notifications")
        }
      },
      listNotificationsHandler as any
    );
  • src/index.ts:191-191 (registration)
    Where registerNotificationTools is called to register all notification tools (including 'list_notifications') on the MCP server.
    registerNotificationTools(server, gql);
  • The export of registerNotificationTools function that encapsulates registration of notification tools.
    export function registerNotificationTools(server: McpServer, gql: GraphQLClient) {
  • The text() helper utility used by listNotificationsHandler to format the response as MCP text content.
    export function text(data: unknown) {
      if (typeof data === "string") {
        return { content: [{ type: "text" as const, text: data }] };
      }
    
      if (data !== null && typeof data === "object" && !Array.isArray(data)) {
        const structuredContent = cloneJsonValue(data);
        return {
          content: [{ type: "text" as const, text: JSON.stringify(structuredContent) }],
          structuredContent,
        };
      }
    
      return {
        content: [{ type: "text" as const, text: JSON.stringify(data) }],
      };
    }
Behavior2/5

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

With no annotations, the description must disclose behaviors. It doesn't mention that the tool supports pagination (first, offset, after) or filtering (unreadOnly), nor the response structure. The minimal text provides no behavioral insight.

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

Conciseness2/5

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

The description is extremely brief (4 words) but fails to provide necessary context. It is under-specified, not efficiently concise. A single sentence is acceptable, but this lacks substance.

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

Completeness2/5

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

Given 4 parameters and no output schema, the description should explain pagination, filtering, and expected return. It does none, leaving the agent with insufficient understanding to invoke the tool correctly.

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 coverage is 100% with all parameters described. The description adds no additional meaning, so baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly states the tool retrieves user notifications, but it fails to differentiate from the sibling 'read_all_notifications'. The verb 'get' is generic but acceptable.

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

Usage Guidelines2/5

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

No guidance on when to use this tool vs 'read_all_notifications' or other alternatives. The description omits context about pagination or filtering, leaving the agent without decision support.

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/DAWNCR0W/affine-mcp-server'

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