Skip to main content
Glama
europarcel
by europarcel

Get Orders List

getOrders

Retrieve a paginated list of customer orders with tracking information. Specify page number and number of orders per page (15, 50, 100, or 200).

Instructions

Get list of customer orders with tracking information. Parameters: page (optional), per_page (15-200, optional)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoPage number for pagination (default: 1)
per_pageNoNumber of orders per page - must be 15, 50, 100, or 200 (default: 15)

Implementation Reference

  • Main handler: registerGetOrdersTool function that registers the 'getOrders' MCP tool. It takes optional page/per_page params, validates API key, calls client.getOrders(), formats results using formatOrderStatus/formatAmount helpers, and returns a formatted text response.
    export function registerGetOrdersTool(server: McpServer): void {
      // Create API client instance
    
      // Register getOrders tool
      server.registerTool(
        "getOrders",
        {
          title: "Get Orders List",
          description:
            "Get list of customer orders with tracking information. Parameters: page (optional), per_page (15-200, optional)",
          inputSchema: {
            page: z
              .number()
              .int()
              .positive()
              .optional()
              .describe("Page number for pagination (default: 1)"),
            per_page: z
              .union([z.literal(15), z.literal(50), z.literal(100), z.literal(200)])
              .optional()
              .describe(
                "Number of orders per page - must be 15, 50, 100, or 200 (default: 15)",
              ),
          },
        },
        async (args: any) => {
          // Get API key from async context
          const apiKey = apiKeyStorage.getStore();
    
          if (!apiKey) {
            return {
              content: [
                {
                  type: "text",
                  text: "Error: X-API-KEY header is required",
                },
              ],
            };
          }
    
          // Create API client with customer's API key
          const client = new EuroparcelApiClient(apiKey);
    
          try {
            const page = args.page || 1;
            const perPage = args.per_page || 15;
    
            logger.info("Fetching orders", { page, per_page: perPage });
    
            const response = await client.getOrders({
              page,
              per_page: perPage,
            });
    
            logger.info(`Retrieved ${response.list.length} orders`);
    
            let formattedResponse = `📋 Orders (Page ${response.pagination.current_page}/${response.pagination.last_page}):\n\n`;
    
            if (response.list.length === 0) {
              formattedResponse += "No orders found.";
            } else {
              response.list.forEach((order) => {
                formattedResponse += formatOrderStatus(order) + "\n";
              });
    
              formattedResponse += `\nShowing ${response.list.length} of ${response.pagination.total} total orders.`;
    
              if (
                response.pagination.current_page < response.pagination.last_page
              ) {
                formattedResponse += `\nUse page parameter to see more (next page: ${response.pagination.current_page + 1}).`;
              }
            }
    
            return {
              content: [
                {
                  type: "text",
                  text: formattedResponse,
                },
              ],
            };
          } catch (error: any) {
            logger.error("Failed to fetch orders", error);
    
            return {
              content: [
                {
                  type: "text",
                  text: `Error fetching orders: ${error.message || "Unknown error"}`,
                },
              ],
            };
          }
        },
      );
    
      logger.info("getOrders tool registered successfully");
    }
  • Helper: formatAmount formats a monetary amount with its currency symbol for display.
    const formatAmount = (amount: number | string, currency: string): string => {
      const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
      return `${numAmount.toFixed(2)} ${currency}`;
    };
  • Helper: formatOrderStatus formats a single order's details (ID, status, carrier, service, total, AWB, tracking, COD) for display.
    const formatOrderStatus = (order: any): string => {
      let status = `📦 Order #${order.id}\n`;
      status += `   Status: ${order.order_status}\n`;
      status += `   Carrier: ${order.carrier_name} (ID: ${order.carrier_id})\n`;
      status += `   Service: ${order.service_name} (ID: ${order.service_id})\n`;
      status += `   Total: ${formatAmount(order.total_amount, order.currency)}\n`;
    
      if (order.awb) {
        status += `   AWB: ${order.awb}\n`;
        if (order.current_status) {
          status += `   Tracking: ${order.current_status}${order.is_current_status_final ? " (Final)" : ""}\n`;
        }
        if (order.track_url) {
          status += `   Track URL: ${order.track_url}\n`;
        }
      }
    
      if (order.repayment_amount > 0) {
        status += `   COD: ${formatAmount(order.repayment_amount, order.repayment_currency)}\n`;
      }
    
      return status;
    };
  • Schema: OrderListResponse interface defining the API response shape with list of Order objects and pagination metadata (total, per_page, current_page, last_page).
    export interface OrderListResponse {
      list: Order[];
      pagination: {
        total: number;
        per_page: number;
        current_page: number;
        last_page: number;
      };
    }
  • Registration: registerOrderTools function that calls registerGetOrdersTool(server) along with other order tool registrations.
    export function registerOrderTools(server: McpServer): void {
      logger.info("Registering order tools...");
    
      // Register all order-related tools
      registerGetOrdersTool(server);
      registerGetOrderByIdTool(server);
      registerCancelOrderTool(server);
      registerTrackAwbsByCarrierTool(server);
      registerGenerateLabelLinkTool(server);
      registerTrackOrdersByIdsTool(server);
      registerCreateOrderTool(server);
    
      // Register pricing tools as well since they're order-related
      registerPricingTools(server);
    
      logger.info("All order tools registered successfully");
    }
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It mentions 'with tracking information' but does not state whether the operation is read-only, the response format, or any side effects.

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 the action, then parameters. No unnecessary words. Perfectly concise.

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?

No output schema exists, so the description should describe the return structure. 'With tracking information' is vague. It does not mention pagination details, sorting, or filtering, leaving the agent guessing about the response.

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%, so baseline is 3. The description repeats parameter names and ranges but adds no new meaning beyond the schema. The range '15-200' for per_page is slightly misleading as it is an enum of discrete values.

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?

The description clearly states 'Get list of customer orders with tracking information', which is a specific verb and resource. It distinguishes from siblings like getOrderById (single order) and trackOrdersByIds (tracking specific orders).

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 is provided on when to use this tool vs alternatives such as getOrderById or trackOrdersByIds. An explicit comparison would help the agent choose correctly.

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/europarcel/mcp-docker'

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