Skip to main content
Glama

get_discount_codes

Read-onlyIdempotent

Retrieve discount codes with pagination support using cursor and per_page parameters for efficient data access.

Instructions

Get all discount codes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cursorNoCursor for fetching the next page of results
per_pageNoNumber of results per page (default: 25)

Implementation Reference

  • The async handler function for the 'get_discount_codes' tool. It calls apiList to fetch discount codes from the /discount_codes endpoint, logs the response, formats the result using formatList, and appends a next-page cursor if present.
      async ({ cursor, per_page }) => {
        try {
          const result = await apiList<EduframeRecord>("/discount_codes", { cursor, per_page });
          void logResponse("get_discount_codes", { cursor, per_page }, result);
          const toolResult = formatList(result.records, "discount codes");
          if (result.nextCursor) {
            toolResult.content.push({ type: "text", text: `\nNext page cursor: ${result.nextCursor}` });
          }
          return toolResult;
        } catch (error) {
          return formatError(error);
        }
      },
    );
  • Input schema for the 'get_discount_codes' tool. Defines optional 'cursor' (string) and 'per_page' (positive integer) parameters with descriptions.
    {
      description: "Get all discount codes",
      annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
      inputSchema: {
        cursor: z.string().optional().describe("Cursor for fetching the next page of results"),
        per_page: z.number().int().positive().optional().describe("Number of results per page (default: 25)"),
      },
  • Tool registration call: server.registerTool('get_discount_codes', ...) which registers the tool name with the MCP server.
    server.registerTool(
  • The registerAllTools function iterates over all tool registrations, including registerDiscountCodeTools, to register them with the MCP server.
    export function registerAllTools(server: McpServer): void {
      for (const register of tools) {
        register(server);
      }
    }
  • The apiList helper function used by the handler to perform a GET request to the Eduframe API with cursor-based pagination support.
    export async function apiList<T>(path: string, query?: Record<string, QueryValue>): Promise<ListResult<T>> {
      const { token } = getConfig();
      const url = buildUrl(path, query);
    
      const response = await fetch(url.toString(), {
        method: "GET",
        headers: buildHeaders(token),
      });
    
      await checkResponse(response);
    
      const records = (await response.json()) as T[];
      const nextCursor = parseNextCursor(response.headers.get("Link"));
    
      return { records, nextCursor };
    }
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true. The description does not contradict these. It adds minimal behavioral context, such as pagination support implied by the schema but not explicitly stated in the description.

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

Conciseness4/5

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

The description is extremely concise, using a single sentence with no wasted words. It is front-loaded with the action and resource. However, it might be too sparse for completeness.

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

Completeness3/5

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

Given the tool's simplicity and the presence of an output schema (none), the description is adequate but misses opportunities to explain pagination or the nature of discount codes. It is moderately complete but could be more informative.

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?

The input schema covers both parameters (cursor, per_page) with descriptions, achieving 100% coverage. The description does not add any extra meaning beyond what the schema provides, 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 'Get all discount codes' clearly states the verb 'Get' and the resource 'discount codes'. It effectively communicates the tool's purpose, though it does not differentiate from other get tools among the siblings. The word 'all' might be slightly misleading given pagination parameters.

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?

The description provides no guidance on when to use this tool versus other get tools (e.g., get_catalog_products). There is no mention of context, prerequisites, or alternatives, which is a significant gap for an AI agent navigating many siblings.

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/martijnpieters/eduframe-mcp'

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