Get Services
getServicesRetrieve available shipping services and carrier information, filtering by service type, carrier, or country to support logistics operations.
Instructions
Retrieves available services with carrier information. Optional filters: service_id, carrier_id, country_code
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| service_id | No | Optional service ID: 1=From home to home, 2=From home to locker, 3=From locker to home, 4=From locker to locker | |
| carrier_id | No | Optional carrier ID: 1=Cargus, 2=DPD, 3=FAN Courier, 4=GLS, 6=Sameday, 16=Bookurier | |
| country_code | No | Optional country code - must be 'RO' (Romania) |
Implementation Reference
- src/tools/locations/getServices.ts:7-109 (handler)The main tool registration and handler function for 'getServices'. It registers the tool with name 'getServices', defines the input schema (service_id, carrier_id, country_code), validates the API key, calls the API client, and formats the response.
export function registerGetServicesTool(server: McpServer): void { // Create API client instance // Register getServices tool server.registerTool( "getServices", { title: "Get Services", description: "Retrieves available services with carrier information. Optional filters: service_id, carrier_id, country_code", inputSchema: { service_id: z .union([z.literal(1), z.literal(2), z.literal(3), z.literal(4)]) .optional() .describe( "Optional service ID: 1=From home to home, 2=From home to locker, 3=From locker to home, 4=From locker to locker", ), carrier_id: z .union([ z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(6), z.literal(16), ]) .optional() .describe( "Optional carrier ID: 1=Cargus, 2=DPD, 3=FAN Courier, 4=GLS, 6=Sameday, 16=Bookurier", ), country_code: z .enum(["RO"]) .optional() .describe("Optional country code - must be 'RO' (Romania)"), }, }, 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 services", args); const services = await client.getServices({ service_id: args.service_id, carrier_id: args.carrier_id, country_code: args.country_code, }); logger.info(`Retrieved ${services.length} services`); let formattedResponse = `Found ${services.length} services`; if (args.service_id || args.carrier_id || args.country_code) { formattedResponse += " (filtered)"; } formattedResponse += ":\n\n"; services.forEach((service) => { formattedResponse += `${service.service_name} (ID: ${service.service_id})\n`; formattedResponse += ` Carrier: ${service.carrier_name} (${service.carrier_id})\n`; formattedResponse += ` Country: ${service.country_code}\n\n`; }); return { content: [ { type: "text", text: formattedResponse, }, ], }; } catch (error: any) { logger.error("Failed to fetch services", error); return { content: [ { type: "text", text: `Error fetching services: ${error.message || "Unknown error"}`, }, ], }; } }, ); logger.info("getServices tool registered successfully"); } - src/tools/locations/getServices.ts:11-42 (registration)Registration of the 'getServices' tool via server.registerTool() with its name and input schema definitions.
server.registerTool( "getServices", { title: "Get Services", description: "Retrieves available services with carrier information. Optional filters: service_id, carrier_id, country_code", inputSchema: { service_id: z .union([z.literal(1), z.literal(2), z.literal(3), z.literal(4)]) .optional() .describe( "Optional service ID: 1=From home to home, 2=From home to locker, 3=From locker to home, 4=From locker to locker", ), carrier_id: z .union([ z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(6), z.literal(16), ]) .optional() .describe( "Optional carrier ID: 1=Cargus, 2=DPD, 3=FAN Courier, 4=GLS, 6=Sameday, 16=Bookurier", ), country_code: z .enum(["RO"]) .optional() .describe("Optional country code - must be 'RO' (Romania)"), }, }, - Input schema for getServices tool: optional service_id (1-4), carrier_id (1,2,3,4,6,16), and country_code (RO).
{ title: "Get Services", description: "Retrieves available services with carrier information. Optional filters: service_id, carrier_id, country_code", inputSchema: { service_id: z .union([z.literal(1), z.literal(2), z.literal(3), z.literal(4)]) .optional() .describe( "Optional service ID: 1=From home to home, 2=From home to locker, 3=From locker to home, 4=From locker to locker", ), carrier_id: z .union([ z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(6), z.literal(16), ]) .optional() .describe( "Optional carrier ID: 1=Cargus, 2=DPD, 3=FAN Courier, 4=GLS, 6=Sameday, 16=Bookurier", ), country_code: z .enum(["RO"]) .optional() .describe("Optional country code - must be 'RO' (Romania)"), }, - src/api/client.ts:208-217 (helper)EuroparcelApiClient.getServices() method that makes the HTTP GET request to /locations/services with optional query parameters.
async getServices(params?: { service_id?: number; carrier_id?: string; country_code?: string; }): Promise<Service[]> { const response = await this.client.get<Service[]>("/locations/services", { params, }); return response.data; } - src/types/index.ts:129-135 (schema)Service interface type definition with fields: service_id, service_name, carrier_id, carrier_name, country_code.
export interface Service { service_id: number; service_name: string; carrier_id: string; carrier_name: string; country_code: string; }