Skip to main content
Glama
europarcel
by europarcel

Get Order Details

getOrderById

Get detailed order information by providing the order ID. Access status, items, and tracking details with a single request.

Instructions

Get detailed information about a specific order by ID. This calls GET /orders/{order_id}. Parameter: order_id (required - the order ID, accepts both numbers like 6505 and strings like '6505')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
order_idYesThe order ID to retrieve details for

Implementation Reference

  • The main handler function that registers and implements the getOrderById tool. It validates the order_id, calls the API client, formats the order details into a rich text response, and handles errors.
    export function registerGetOrderByIdTool(server: McpServer): void {
      // Create API client instance
    
      // Register getOrderById tool
      server.registerTool(
        "getOrderById",
        {
          title: "Get Order Details",
          description:
            "Get detailed information about a specific order by ID. This calls GET /orders/{order_id}. Parameter: order_id (required - the order ID, accepts both numbers like 6505 and strings like '6505')",
          inputSchema: {
            order_id: z
              .union([z.string(), z.number()])
              .describe("The order ID to retrieve details for"),
          },
        },
        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 {
            if (!args.order_id) {
              return {
                content: [
                  {
                    type: "text",
                    text: "Error: order_id parameter is required",
                  },
                ],
              };
            }
    
            const orderId = Number(args.order_id);
            if (!Number.isInteger(orderId) || orderId <= 0) {
              return {
                content: [
                  {
                    type: "text",
                    text: "Error: order_id must be a positive integer",
                  },
                ],
              };
            }
    
            logger.info("Fetching order details", { order_id: orderId });
    
            const order = await client.getOrderById(orderId);
    
            logger.info("Retrieved order details");
    
            let formattedResponse = `šŸ“¦ Order Details #${order.id}\n\n`;
            formattedResponse += `Status: ${order.order_status}\n`;
            formattedResponse += `Created: ${new Date(order.created_at).toLocaleString()}\n`;
            formattedResponse += `Updated: ${new Date(order.updated_at).toLocaleString()}\n\n`;
    
            formattedResponse += `🚚 Shipping Details:\n`;
            formattedResponse += `   Carrier: ${order.carrier_name} (ID: ${order.carrier_id})\n`;
            formattedResponse += `   Service: ${order.service_name} (ID: ${order.service_id})\n`;
    
            if (order.awb) {
              formattedResponse += `   AWB: ${order.awb}\n`;
              if (order.current_status) {
                formattedResponse += `   Current Status: ${order.current_status}\n`;
                formattedResponse += `   Description: ${order.current_status_description}\n`;
                formattedResponse += `   Final Status: ${order.is_current_status_final ? "Yes" : "No"}\n`;
              }
              if (order.track_url) {
                formattedResponse += `   Track URL: ${order.track_url}\n`;
              }
            }
    
            formattedResponse += `\nšŸ’° Financial Details:\n`;
            formattedResponse += `   Subtotal: ${formatAmount(order.subtotal, order.currency)}\n`;
            formattedResponse += `   Tax: ${formatAmount(order.tax_amount, order.currency)}\n`;
            if (order.discount_amount > 0) {
              formattedResponse += `   Discount: ${formatAmount(order.discount_amount, order.currency)}\n`;
            }
            formattedResponse += `   Total: ${formatAmount(order.total_amount, order.currency)}\n`;
    
            if (order.repayment_amount > 0) {
              formattedResponse += `\nšŸ’µ COD Details:\n`;
              formattedResponse += `   Amount: ${formatAmount(order.repayment_amount, order.repayment_currency)}\n`;
            }
    
            if (order.history && order.history.length > 0) {
              formattedResponse += `\nšŸ“œ Tracking History (${order.history.length} events):\n`;
              order.history.slice(0, 5).forEach((event) => {
                formattedResponse += `   • ${new Date(event.timestamp).toLocaleString()}: ${event.status}\n`;
                if (event.location) {
                  formattedResponse += `     Location: ${event.location}\n`;
                }
              });
              if (order.history.length > 5) {
                formattedResponse += `   ... and ${order.history.length - 5} more events\n`;
              }
            }
    
            return {
              content: [
                {
                  type: "text",
                  text: formattedResponse,
                },
              ],
            };
          } catch (error: any) {
            logger.error("Failed to fetch order details", error);
    
            return {
              content: [
                {
                  type: "text",
                  text: `Error fetching order details: ${error.message || "Unknown error"}`,
                },
              ],
            };
          }
        },
      );
    
      logger.info("getOrderById tool registered successfully");
    }
  • The API client method that performs the actual HTTP GET request to /orders/{orderId} to fetch order data from the Europarcel API.
    async getOrderById(orderId: number): Promise<Order> {
      const response = await this.client.get<Order>(`/orders/${orderId}`);
      return response.data;
    }
  • Input schema definition for the getOrderById tool. Accepts order_id as a union of string or number.
    inputSchema: {
      order_id: z
        .union([z.string(), z.number()])
        .describe("The order ID to retrieve details for"),
    },
  • Registration call that invokes registerGetOrderByIdTool(server) within the registerOrderTools function.
    registerGetOrderByIdTool(server);
  • Re-export of registerGetOrderByIdTool from the orders index module for external use.
    export { registerGetOrderByIdTool } from "./getOrderById.js";
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the HTTP method and parameter format but fails to disclose auth needs, rate limits, or side effects, which is inadequate for a read operation.

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 contain all essential information with zero fluff, making it highly efficient.

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?

The tool has no output schema, and the description only says 'detailed information' without specifying the return structure. It is adequate for a simple GET but could be more complete.

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?

The description adds concrete examples and clarifies the order_id accepts both numbers and strings, which goes beyond the schema's type definition.

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 the tool retrieves detailed information for a specific order by ID, which distinguishes it from siblings like getOrders (listing) and cancelOrder (different action).

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

Usage Guidelines3/5

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

The description implies use for single order retrieval but does not explicitly state when to use this vs alternatives like getOrders or trackOrdersByIds.

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