Parcel Tracking MCP
# parcel-tracking-mcp
An [MCP](https://modelcontextprotocol.io) server that tracks parcels **directly on the carriers' own websites**, with
no third-party tracking service or API key. Give it a tracking number (and optionally a carrier); it returns one
normalized result: status, delivery time, signer, and every scan event.
> Unofficial. It reads the same public tracking pages a person would use. Keep request volume low and respect each
> carrier's terms.
Full reference for AI assistants: [docs/TOOLS.md](docs/TOOLS.md).
## Tools
| Tool | What it does |
|---|---|
| `track_package` | `number` (required), `carrier` (optional). Returns `status` (`pre_transit`, `in_transit`, `out_for_delivery`, `delivered`, `exception`, `returned`, `not_found`), `statusText`, `deliveredAt`, `estimatedDelivery`, `signedBy`, `service`, `origin`, `destination`, `events[]` (newest first: `time`, `description`, `location`, `status`) and the carrier's own tracking `url`. |
| `list_carriers` | Supported carriers, their aliases, and whether they need a browser. With `number`, also which carriers that number could belong to. |
The carrier is detected from the number's format. When a format fits more than one carrier (for example 12 digits is
FedEx or Purolator) each candidate is tried, plain-HTTP ones first.
## Carriers
| Carrier | How it is fetched |
|---|---|
| Apple Express, Cainiao, 4PX, UniUni, Intelcom (Dragonfly) | The carrier's public data feed, plain HTTPS (about 1 s) |
| Straightship, Canpar | The carrier's tracking web page, parsed (about 1 s) |
| Canada Post, DHL Express, Purolator | The carrier's page in a real browser; the page's own data request is read (3-8 s) |
| FedEx, UPS | The carrier's page in a real browser (signed requests) (5-10 s) |
| eMile | Browser, plus the site's Cloudflare "Verify you are human" checkbox (about 10 s) |
| Landmark Global | Browser, reads the rendered page |
| Asendia | Browser, same Cloudflare checkbox; **experimental** |
| USPS | USPS blocks automated lookups. Parcels bound for Canada are handed to Canada Post, so the number is tried there; otherwise a not-found result with the USPS link |
Browser-based carriers use [rebrowser-puppeteer-core](https://github.com/rebrowser/rebrowser-patches) (removes the DevTools
`Runtime.enable` leak that bot checks look for) in a **headed** Chrome on a virtual display with a persistent profile.
Chrome is only started when a browser carrier is used and is closed after 10 idle minutes.
## Run with Docker (recommended)
```sh
docker build -t parcel-tracking-mcp .
```
**stdio:**
```json
{
"mcpServers": {
"parcel-tracking": {
"command": "docker",
"args": ["run", "-i", "--rm", "--shm-size=1g", "-v", "tracker-profile:/profile", "parcel-tracking-mcp"]
}
}
}
```
**HTTP** (streamable HTTP at `/mcp`, via [mcp-proxy](https://github.com/sparfenyuk/mcp-proxy)):
```sh
docker run -d --name parcel-tracking-mcp --init --shm-size=1g -p 127.0.0.1:3000:3000 \
-v tracker-profile:/profile parcel-tracking-mcp http
```
There is no authentication on the HTTP endpoint: keep it on localhost or behind your own auth.
One lookup from the command line: `docker run --rm --shm-size=1g parcel-tracking-mcp smoke <number> [carrier]`
## Run with Node
Node 20+ and Chrome or Chromium.
```sh
npm install && npm run build
CHROME_PATH=/path/to/chrome node build/index.js # stdio MCP server
npm run smoke -- <number> [carrier]
```
Without a display, run under `xvfb-run` (headless Chrome is more likely to be challenged).
## Configuration
| Variable | Default | Purpose |
|---|---|---|
| `TRACKER_PROFILE_DIR` | `./profile` (`/profile` in Docker) | Chrome profile (carrier-site cookies only) |
| `CHROME_PATH` | auto-detect (`/usr/local/bin/chrome` in Docker) | Chrome binary |
| `HEADLESS` | `false` | Headless Chrome (not recommended) |
| `BROWSER_IDLE_CLOSE_MS` | `600000` | Close Chrome after this idle time; `0` keeps it open |
| `TRACKER_CAPTURE_TIMEOUT_MS` | `30000` | Max wait for a browser carrier's data |
| `TRACKER_HTTP_TIMEOUT_MS` | `20000` | Timeout for plain HTTP carriers |
| `TRACKER_NAV_TIMEOUT_MS` | `45000` | Page load timeout |
| `TRACKER_DEBUG_DIR` | unset | Save a screenshot and HTML of failed browser lookups (may contain tracking details) |
| `UNIUNI_TRACKING_KEY` | built-in | UniUni's public page key, if it ever rotates |
## How it works
Each carrier is a small adapter in `src/carriers/` that turns the carrier's own data into the common result.
Plain-HTTP adapters call the endpoint the carrier's tracking page uses. Browser adapters open the tracking page
and read the response of the page's own data request, so the carrier's bot protection sees an ordinary browser.
When a carrier's response is not in a known format, a generic reader looks for the event list (an array of items with
a time and a description).
## Limitations
- Carrier sites change without notice; an adapter can break until updated. Errors say what the site returned.
- Event formats for some carriers (Purolator, Intelcom, UPS history, Canpar, DHL, 4PX, Cainiao, Landmark, Asendia) were
built from their documented/observed shapes and are read defensively. Report a number that parses badly.
- Browser lookups take a few seconds and about 500 MB of RAM while Chrome is open.
- Tracking numbers are sent only to the carrier's own site. Nothing is stored.
## Adding a carrier
Add an adapter to `src/carriers/http.ts` or `src/carriers/browser.ts` (an `id`, `name`, `aliases`, optional `detect`
regex, `url(n)` and `track(n)` returning `result(...)`) and add it to the exported list.
## License
MIT
TDQS
Scored across 2 tools
The two tools have clearly distinct purposes: list_carriers is for discovery and carrier detection, while track_package performs the actual lookup. An agent can easily tell which tool to use for which task.
Both names follow a consistent snake_case verb_noun pattern: list_carriers and track_package. There is no mixing of conventions or vague verbs.
Two tools is slightly below the typical 3–15 range, but each has a clear, non-redundant role in a narrow parcel-tracking domain. The surface is minimal but intentionally scoped rather than padded.
For a read-only parcel-tracking server, the surface covers the essential lifecycle: discover supported carriers and retrieve detailed tracking status, events, and links. No obvious required operation is missing.