Skip to main content
Glama
iamfiro

Parcel Tracking MCP Server

by iamfiro

tracking-delivery

Track parcel deliveries using a tracking number and carrier ID with the MCP server. Automatically detect carriers or specify manually for accurate results.

Instructions

Track a parcel delivery via 17TRACK

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
carrierNoCarrier ID (number). If omitted, 17TRACK will auto-detect, but accuracy may be lower.
numberYesThe tracking number of the parcel

Implementation Reference

  • The main handler function for the 'tracking-delivery' tool. Validates the carrier ID if provided, registers the tracking number with 17TRACK API, fetches the delivery information, and returns it as JSON. Handles errors and prompts for carrier if missing.
    async ({ number, carrier }) => { if (carrier && !validateCarrierId(carrier)) { return { content: [ { type: "text", text: `The carrier ID "${carrier}" is not valid. Please use the 'search-carrier' tool to find the correct carrier ID.`, } as const, ], }; } if (!carrier) { return { content: [ { type: "text", text: "Please specify the carrier ID along with the tracking number for more accurate results. You can use the 'search-carrier' tool to look up the carrier ID first.", } as const, ], }; } try { await register({ number, carrier }); const data = await getDelivery({ number, carrier }); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), } as const, ], }; } catch (error) { return { content: [ { type: "text", text: "Error tracking delivery: " + (error instanceof Error ? error.message : String(error)), } as const, ], }; } }
  • Zod input schema defining the parameters for the 'tracking-delivery' tool: required 'number' (tracking number as string) and optional 'carrier' (carrier ID as number). Includes descriptions for each parameter.
    { number: z.string().describe("The tracking number of the parcel"), carrier: z .number() .optional() .describe( "Carrier ID (number). If omitted, 17TRACK will auto-detect, but accuracy may be lower." ), },
  • src/index.ts:168-226 (registration)
    Registers the 'tracking-delivery' tool on the MCP server using server.tool(), providing the tool name, description, input schema, and handler function.
    server.tool( "tracking-delivery", "Track a parcel delivery via 17TRACK", { number: z.string().describe("The tracking number of the parcel"), carrier: z .number() .optional() .describe( "Carrier ID (number). If omitted, 17TRACK will auto-detect, but accuracy may be lower." ), }, async ({ number, carrier }) => { if (carrier && !validateCarrierId(carrier)) { return { content: [ { type: "text", text: `The carrier ID "${carrier}" is not valid. Please use the 'search-carrier' tool to find the correct carrier ID.`, } as const, ], }; } if (!carrier) { return { content: [ { type: "text", text: "Please specify the carrier ID along with the tracking number for more accurate results. You can use the 'search-carrier' tool to look up the carrier ID first.", } as const, ], }; } try { await register({ number, carrier }); const data = await getDelivery({ number, carrier }); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), } as const, ], }; } catch (error) { return { content: [ { type: "text", text: "Error tracking delivery: " + (error instanceof Error ? error.message : String(error)), } as const, ], }; } } );
  • Helper function to register a tracking number with the 17TRACK API prior to querying status.
    async function register({ number, carrier }: Props) { const body = [ { number, carrier: carrier ?? 0, }, ]; const res = await fetch(`${TRACKER_API_BASE_URL}/register`, { method: "POST", headers: { "17token": apiToken, "Content-Type": "application/json", "User-Agent": USER_AGENT, }, body: JSON.stringify(body), }); return res.json(); }
  • Helper function to fetch the current delivery tracking information from the 17TRACK API.
    async function getDelivery({ number, carrier }: Props) { const body = [ { number, carrier: carrier ?? 0, }, ]; const res = await fetch(`${TRACKER_API_BASE_URL}/gettrackinfo`, { method: "POST", headers: { "17token": apiToken, "Content-Type": "application/json", "User-Agent": USER_AGENT, }, body: JSON.stringify(body), }); return res.json(); }

Other Tools

Related 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/iamfiro/parcel-tracking-mcp'

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