tracking-requests-mcp
Allows creating FedEx labels via a staged write path (dev sandbox or production), with preflight validation and idempotent label creation. Integrates with FedEx's API through an n8n webhook for label generation.
Triggers an n8n webhook workflow to process FedEx label requests, which then communicates with FedEx's API and writes results back to the database.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@tracking-requests-mcp check tracking request status for order ABC-123"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
tracking-requests-mcp
An app MCP for the tracking-requests shipping-label app: a broad read-only surface
plus one tightly-staged write path (FedEx label creation) — over stdio (local), against
the dev or prod Cloud SQL database via an env/stage param.
New here? Read GUIDE.md — setup for every Claude surface (Claude Code, Claude Desktop, claude.ai connector) plus everyday usage, the label workflow, and troubleshooting. This README covers the architecture/invariants; DEPLOY.md covers hosting.
Built with the MCP Playbook shape:
one createServer() factory (register.js), thin server.js, one lib/ module per domain,
a read-only guard, graceful degradation, a 360° rollup + a raw-query escape hatch.
Tools (8 read, + 2 write when ENABLE_WRITES is set)
Read (8) — always available
Tool | What it does |
| Raw read-only SQL escape hatch (SELECT/WITH/EXPLAIN/SHOW, single statement). |
| Commodities by |
| Shipping contacts warranting a system flag (No Phone / No Postal Code / Address Line 1|2 > 35) — read-only counterpart of the |
| Tracking requests with triage filters; |
| 360° rollup for ONE request by |
| Live DB vs the tool CONTRACT — missing tables/columns (breakage). |
| Live schema vs the committed baseline — additions = candidate tools, removals = breakage. |
| Validate a proposed shipment with ZERO side effects: parties + flags, per-line commodity/HTS checks, unit-value suggestions, env wiring. |
Write (2) — opt-in via ENABLE_WRITES; staged, dev-first, prod gated
Tool | What it does |
| Create a FedEx label: per-box |
| Re-fire the label webhook for a stranded batch (rows without tracking numbers). No DB write. |
Plus one resource: snl-fedex-mcp://reference (resources/reference.md) — data model,
integrations, canonical keys, footguns, and the write-surface contract.
Related MCP server: Shipping Service MCP Server
Layout
tracking-requests-mcp/
register.js createServer() — all tools + the reference resource
server.js stdio entry (thin); runs schema_check on boot (logs to stderr)
httpServer.js remote entry: stateless Streamable HTTP + bearer auth (Cloud Run)
deploy.sh / DEPLOY.md idempotent Cloud Run deploy + claude.ai connector steps
lib/
env.js one-.env loader + per-env read-only pg Pool factory (dev|prod)
db.js read-only guard + generic query + table/column probes + SELECT *
commodities.js commodity_lookup
contacts.js contacts_needing_fixes (mirrors src/lib/contact-status.ts rules)
tracking.js tracking_requests_list + tracking_request_overview (rollup)
writes.js staged write harness (dev-first, prod confirm gate, ensure-in-dev)
labels.js label_preflight / label_create / label_webhook_retry (mirrors createLabel)
schema.js CONTRACT + schema_check + coverage_report + snapshot
resources/
reference.md tribal knowledge (MCP resource)
evolution-ledger.json /mcp-evolve dedupe ledger
schema-baseline.json coverage_report baseline (created by `npm run snapshot`)
scripts/
verify.mjs end-to-end protocol verification (npm run verify)
snapshot.mjs record schema baseline (npm run snapshot [env])The Phase 7 self-evolution scripts (detect-signals.mjs, mcp-evolve-tick.ps1) are
local-only and not committed — they hardcode one machine's paths and drive an
autonomous agent. See Self-evolution.
Invariants
Readers are read-only, two layers. The
db_queryguard rejects non-read statements; every read pool connects withdefault_transaction_read_only=on. Writes run ONLY throughlib/writes.json a separate writable pool (getWritePool), single-transaction, rollback on error.Writes are opt-in (
ENABLE_WRITES). The two mutating tools (label_create,label_webhook_retry) are registered only whenENABLE_WRITESis set — one gate on the shared factory covers every transport. Unset → a read-only 8-tool server (the default for the hosted multi-user connector); set (local.env, CI) → the full 10-tool surface.Staged writes.
stage:"dev"(default) is a full isolated environment (dev DB + dev n8n + FedEx sandbox);stage:"prod"requiresconfirm:trueand creates real, billable labels. Every mutating call requiresrequestedBy(stampedcreated_by = "mcp:<requestedBy>").Explicit
env(dev|prod), defaultdev. An env is usable only if itsDATABASE_URL_<ENV>is set; an unwired env returns a clean structured error naming the variable, never a driver crash. Write tools additionally refuse when their stage's webhook/API config is missing (names only).Canonical business keys, never serial
idacross envs:sku/shopify_product_id(commodities),transaction_id/batch_id(tracking requests),code(contacts).Graceful degradation: tables are probed before use;
SELECT *so added columns never break a reader; missing pieces return null/empty.
Setup
cd tracking-requests-mcp
npm install
cp .env.example .env # fill in DATABASE_URL_DEV (and _PROD); for label_create also
# N8N_FEDEX_TRACKING_REQUEST_WEBHOOK_URL_<ENV> + snapshot/config vars
npm run verify # end-to-end over the MCP protocol
npm run snapshot dev # record the coverage baseline (needs a wired env)The DBs are Cloud SQL — for local access run the Cloud SQL Auth Proxy and point
DATABASE_URL_DEV at it (see .env.example). Already wired into the repo's .mcp.json as
snl-fedex-mcp (stdio).
Verification status
npm run verify: 16/16 against the live dev database (readers return real data; write
gates refuse structurally; no secret values in any output). Live dev-stage label creation
verified end-to-end on 2026-07-22: preflight → dryRun → label_create → n8n → FedEx sandbox
→ tracking number + label/invoice PDFs written back → tracking_request_overview confirms →
idempotent re-call returns created:false. The dev n8n workflow demonstrably writes back to
the dev DB. Prod stage remains untouched (DATABASE_URL_PROD deliberately unwired locally).
Self-evolution (Phase 7)
Both scripts below are gitignored — they are not in this repo. They hardcode absolute paths for a single developer's machine and launch an autonomous agent, so they're kept local rather than published. Ask if you want a copy to adapt.
scripts/detect-signals.mjs cheaply detects coverage/schema/repo/usage drift and prints
TRIGGER only on a change. scripts/mcp-evolve-tick.ps1 runs it hourly and launches
/mcp-evolve headless on a delta. It is not registered as a scheduled task by the build,
and it deliberately does not push — because this MCP lives inside the app repo whose pushes
auto-deploy the app. Register the task yourself (command at the bottom of the .ps1) once you
want the loop live; consider moving the MCP to its own repo first if you want auto-push/redeploy.
Not built (by design)
Other writes — label creation is the only mutation.
label_cancel(FedEx cancel + soft delete), pickup scheduling, contact/commodity edits: all still require explicit requests on the staged harness.Hosting— now built:httpServer.js+ Cloud Run + claude.ai custom connector, dev-wired only. SeeDEPLOY.md.FedEx pickup-availability read tool — genuinely read-only but needs FedEx OAuth creds and is really an app action; deferred to the roadmap to keep the surface DB-scoped and verifiable.
Roadmap / candidates
label_cancelwrite tool (the undo path: FedEx cancel + soft delete) — spec'd as an open question inopenspec/changes/mcp-fedex-label-creation/design.md.FedEx
pickup_availabilityread tool (needsFEDEX_*creds).Once real sessions accumulate,
/mcp-evolvewill mine recurringdb_queryshapes into curated tools.
Available Tools
9 toolscommodity_lookupA
Look up commodities by any business identifier (sku, htsCode, shopifyProductId, bpProductId, or a title/parent-name substring). ERP-synced rows are source='erp'; app-created rows are source='manual' (no shopify_product_id). Soft-deleted rows (removed_at) are excluded unless includeRemoved. Attaches app-owned manual prices.
Inputs: env, sku, limit, title, +5 more.
contacts_needing_fixesA
List shipping contacts that currently warrant a system status flag (No Phone, No Postal Code, Address Line 1 > 35, Address Line 2 > 35) — i.e. contacts whose details will break FedEx label/invoice creation. Read-only counterpart of the backfill-contact-status script; flags are recomputed live.
Inputs: env, limit, country.
coverage_reportA
Diff the live schema against the committed baseline snapshot. ADDED tables/columns = candidate tools/params; REMOVED = breakage. Run npm run snapshot to acknowledge.
Inputs: env.
db_queryA
Run a READ-ONLY SQL query (SELECT/WITH/EXPLAIN/SHOW only; single statement) against the tracking-requests DB. Escape hatch for anything the curated tools don't cover. Params are passed as $1,$2,… bind values.
Inputs: sql (required), env, params.
label_optionsA
List the ship-from / ship-to / (importer, international only) parties the user can pick, BY NAME, from the same sources as the app form — so nobody needs to know IDs. Returns each option's id, display name, disambiguating context (country for contacts, city/state for stores), any contact flags, and sole when it's the only choice. Show the names to the user, then pass the chosen option's id to label_preflight / label_create. Call this before creating a label when you don't already have the party IDs.
Inputs: shipmentType (required), env.
label_preflightA
Validate a proposed FedEx shipment with ZERO side effects: party resolution + contact system flags (these break FedEx invoices), per-line commodity checks (exists, not soft-deleted, valid 10-digit HTS, required construction/type/fabric), unit-value suggestions (manual price, then commodity_prices), the international declared-value limit (CN $680 / else 5000 RMB live) with a projected total, and env wiring. Custom (off-catalog) lines are checked for their own required fields and get no unit-value suggestion (there is no catalog key to look up). Run this first.
Inputs: numBoxes (required), shipmentType (required), packageDescription (required), env, +7 more.
schema_checkB
Introspect the live DB and report any tables/columns the tools DEPEND ON that are missing (the breakage side of drift). ok:true means the contract holds.
Inputs: env.
tracking_request_overviewA
360° rollup for ONE tracking request by id, transactionId (FedEx), or batchId (uuid). Returns a plain summary (tracking number, ready flag, from/to, contents, boxes) and a files list (shipping label PDF, and commercial invoice PDF for international) with open links, plus the raw request, content lines with resolved commodity, party JSON snapshots, and derived flags. allReady is true once every box has its tracking number and PDFs. A batchId that matches several requests returns them all — use this after creating a label to show the summary and files.
Inputs: id, env, batchId, transactionId.
tracking_requests_listA
List tracking requests with triage filters. missingTrackingOnly:true surfaces requests with no tracking_number yet (the n8n label webhook is fire-and-forget, so a stuck request shows here). Soft-deleted rows excluded unless includeDeleted.
Inputs: env, limit, status, batchId, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Most tools serve distinct purposes: schema checks, commodity lookup, contacts, tracking requests, and label preflight. The only potential confusion is between coverage_report and schema_check, both dealing with schema drift, but their descriptions differentiate them clearly.
Tool names use snake_case but follow inconsistent patterns: some are noun_verb (commodity_lookup, schema_check), others noun_noun (tracking_requests_list, label_options), and one uses an abbreviation (db_query). This mixed convention reduces predictability.
With 9 tools, the server covers core domain operations (commodities, contacts, tracking requests, labels) plus schema introspection. The count is reasonable, though the inclusion of schema tools might be overkill for typical agent interactions.
The server lacks a label_create tool despite references to it in descriptions, and there are no create/update/delete tools for tracking requests. These gaps will likely cause agent failures when attempting to complete workflows.
Maintenance
Related MCP Connectors
MCP server for EasyPost — rate shipments, buy & refund labels, track packages, verify addresses.
MCP server for ua_postal_tracking_mcp
MCP server for Modern Treasury — payment orders, transactions, counterparties and ledgers.
MCP server for tracking parcels using the NetCourier tracking service.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server that enables interaction with ShipEngine's shipping API, allowing users to manage shipments, labels, carriers, and other shipping operations through natural language commands.-
- AlicenseNot gradedqualityDmaintenanceProvides a Model Context Protocol server for managing shipping orders and address book functionality with support for connecting to real shipping services via HTTP API.MIT
- FlicenseNot gradedqualityDmaintenanceA standalone MCP server providing shipping tools like address validation and rate previews through a centralized HTTP interface. It serves as the single source of truth for shipping tool behavior across the ShipSmart platform.2-
- AlicenseNot gradedqualityDmaintenanceA horizontally scalable Model Context Protocol server for exposing shipment tracking (and other data sources) as authenticated MCP tools, starting with DB Schenker's public tracking endpoint.1MIT