Skip to main content
Glama
europarcel
by europarcel

Get Repayments

getRepayments

Retrieve customer repayment details including AWB numbers, amounts, and delivery status for Europarcel shipping operations. Filter by order ID or paginate through results.

Instructions

Retrieves customer repayments with AWB details, amounts, and delivery status. Parameters: page (number), order_id (number - optional filter)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoPage number for pagination (1-1000, default: 1)
order_idNoFilter repayments by specific order ID (optional)

Implementation Reference

  • The core handler function for the 'getRepayments' MCP tool. It retrieves the API key, creates an EuroparcelApiClient, fetches repayments data, formats it nicely with pagination and status emojis, and returns a text response or error.
    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 {
        logger.info("Fetching repayments", args);
    
        const response = await client.getRepayments({
          page: args.page,
          order_id: args.order_id,
        });
    
        logger.info(`Retrieved ${response.list.length} repayments`);
    
        let formattedResponse = `Found ${response.pagination.total} total repayments`;
    
        if (args.order_id) {
          formattedResponse += ` for order #${args.order_id}`;
        }
    
        formattedResponse += `\nPage ${response.pagination.current_page} of ${response.pagination.last_page}\n\n`;
    
        if (response.list.length === 0) {
          formattedResponse += "No repayments found.";
        } else {
          response.list.forEach((repayment: Repayment) => {
            formattedResponse += `📦 AWB: ${repayment.awb}\n`;
            formattedResponse += `   Order ID: ${repayment.order_id}\n`;
            formattedResponse += `   Carrier: ${repayment.carrier_name || repayment.carrier_id}\n`;
            formattedResponse += `   Recipient: ${repayment.recipient_name || "N/A"}\n`;
            formattedResponse += `   Amount: ${formatAmount(repayment.repayment_amount, repayment.repayment_currency)}\n`;
            formattedResponse += `   Status: ${formatStatus(repayment.status)}\n`;
    
            if (repayment.delivered_at) {
              formattedResponse += `   Delivered: ${repayment.delivered_at}\n`;
            }
    
            if (repayment.payout_id) {
              formattedResponse += `   Payout ID: ${repayment.payout_id}\n`;
              if (repayment.bank_iban) {
                formattedResponse += `   Bank: ${repayment.bank_holder || "N/A"} - ${repayment.bank_iban}\n`;
              }
            }
    
            formattedResponse += "\n";
          });
    
          // Add pagination info if there are more pages
          if (response.pagination.last_page > 1) {
            formattedResponse += `\nShowing ${response.list.length} of ${response.pagination.total} repayments`;
            if (
              response.pagination.current_page < response.pagination.last_page
            ) {
              formattedResponse += `\nUse page: ${response.pagination.current_page + 1} to see more`;
            }
          }
        }
    
        return {
          content: [
            {
              type: "text",
              text: formattedResponse,
            },
          ],
        };
      } catch (error: any) {
        logger.error("Failed to fetch repayments", error);
    
        return {
          content: [
            {
              type: "text",
              text: `Error fetching repayments: ${error.message || "Unknown error"}`,
            },
          ],
        };
      }
    },
  • Input schema using Zod for validating tool parameters: optional page (int 1-1000) and order_id (int >=1).
    inputSchema: {
      page: z
        .number()
        .int()
        .min(1)
        .max(1000)
        .optional()
        .describe("Page number for pagination (1-1000, default: 1)"),
      order_id: z
        .number()
        .int()
        .min(1)
        .optional()
        .describe("Filter repayments by specific order ID (optional)"),
    },
  • The registration function that sets up the 'getRepayments' tool on the MCP server, including name, schema, description, and handler.
    export function registerGetRepaymentsTool(server: McpServer): void {
      // Create API client instance
    
      // Register getRepayments tool
      server.registerTool(
        "getRepayments",
        {
          title: "Get Repayments",
          description:
            "Retrieves customer repayments with AWB details, amounts, and delivery status. Parameters: page (number), order_id (number - optional filter)",
          inputSchema: {
            page: z
              .number()
              .int()
              .min(1)
              .max(1000)
              .optional()
              .describe("Page number for pagination (1-1000, default: 1)"),
            order_id: z
              .number()
              .int()
              .min(1)
              .optional()
              .describe("Filter repayments by specific order ID (optional)"),
          },
        },
        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 {
            logger.info("Fetching repayments", args);
    
            const response = await client.getRepayments({
              page: args.page,
              order_id: args.order_id,
            });
    
            logger.info(`Retrieved ${response.list.length} repayments`);
    
            let formattedResponse = `Found ${response.pagination.total} total repayments`;
    
            if (args.order_id) {
              formattedResponse += ` for order #${args.order_id}`;
            }
    
            formattedResponse += `\nPage ${response.pagination.current_page} of ${response.pagination.last_page}\n\n`;
    
            if (response.list.length === 0) {
              formattedResponse += "No repayments found.";
            } else {
              response.list.forEach((repayment: Repayment) => {
                formattedResponse += `📦 AWB: ${repayment.awb}\n`;
                formattedResponse += `   Order ID: ${repayment.order_id}\n`;
                formattedResponse += `   Carrier: ${repayment.carrier_name || repayment.carrier_id}\n`;
                formattedResponse += `   Recipient: ${repayment.recipient_name || "N/A"}\n`;
                formattedResponse += `   Amount: ${formatAmount(repayment.repayment_amount, repayment.repayment_currency)}\n`;
                formattedResponse += `   Status: ${formatStatus(repayment.status)}\n`;
    
                if (repayment.delivered_at) {
                  formattedResponse += `   Delivered: ${repayment.delivered_at}\n`;
                }
    
                if (repayment.payout_id) {
                  formattedResponse += `   Payout ID: ${repayment.payout_id}\n`;
                  if (repayment.bank_iban) {
                    formattedResponse += `   Bank: ${repayment.bank_holder || "N/A"} - ${repayment.bank_iban}\n`;
                  }
                }
    
                formattedResponse += "\n";
              });
    
              // Add pagination info if there are more pages
              if (response.pagination.last_page > 1) {
                formattedResponse += `\nShowing ${response.list.length} of ${response.pagination.total} repayments`;
                if (
                  response.pagination.current_page < response.pagination.last_page
                ) {
                  formattedResponse += `\nUse page: ${response.pagination.current_page + 1} to see more`;
                }
              }
            }
    
            return {
              content: [
                {
                  type: "text",
                  text: formattedResponse,
                },
              ],
            };
          } catch (error: any) {
            logger.error("Failed to fetch repayments", error);
    
            return {
              content: [
                {
                  type: "text",
                  text: `Error fetching repayments: ${error.message || "Unknown error"}`,
                },
              ],
            };
          }
        },
      );
    
      logger.info("getRepayments tool registered successfully");
    }
  • Higher-level registration function that calls registerGetRepaymentsTool among others.
    export function registerRepaymentTools(server: McpServer): void {
      logger.info("Registering repayment tools...");
    
      // Register all repayment-related tools
      registerGetRepaymentsTool(server);
      registerGetPayoutReportsTool(server);
    
      logger.info("All repayment tools registered successfully");
    }
  • Helper to format repayment status strings with descriptive emojis.
    function formatStatus(status: string): string {
      const statusMap: Record<string, string> = {
        pending: "⏳ Pending",
        processing: "🔄 Processing",
        paid: "✅ Paid",
        cancelled: "❌ Cancelled",
        failed: "⚠️ Failed",
      };
      return statusMap[status] || status;
    }
  • Helper to format repayment amounts as currency strings.
    function formatAmount(amount: number, currency: string): string {
      return `${amount.toFixed(2)} ${currency}`;
    }
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 'retrieves' which suggests a read operation, but lacks details on permissions, rate limits, pagination behavior beyond the 'page' parameter, or what happens if no repayments exist. This leaves significant behavioral gaps for an agent.

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 front-loaded with the core purpose and includes parameter details in a second sentence. It's efficient with no wasted words, though the parameter listing could be integrated more seamlessly.

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 no annotations and no output schema, the description is moderately complete for a read tool. It covers the purpose and parameters, but lacks behavioral context (e.g., response format, error handling) and doesn't fully compensate for the absence of structured metadata, leaving room for improvement.

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 description coverage is 100%, so the schema fully documents both parameters. The description adds minimal value by listing parameters and noting 'order_id' as an optional filter, but doesn't provide additional context beyond what the schema already specifies (e.g., default values, usage examples).

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 verb 'retrieves' and the resource 'customer repayments' with specific data fields (AWB details, amounts, delivery status). It distinguishes from some siblings like 'getOrders' or 'getOrderById' by focusing on repayments, though not explicitly contrasting with all potential alternatives.

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 usage for retrieving repayments, but provides no explicit guidance on when to use this tool versus alternatives like 'getOrders' or 'getOrderById' (which might relate to orders rather than repayments). The optional 'order_id' filter hints at filtering by order, but no clear when/when-not rules are stated.

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'

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