MCP Server

The Model Context Protocol (MCP) is an open standard that lets AI coding assistants interact with external tools and APIs. Envia's MCP server exposes the complete Shipping, Queries, and Geocodes APIs as tools that AI agents can discover, understand, and call on your behalf.

Instead of copying endpoints and crafting JSON payloads manually, you describe what you need in plain language — and the agent handles the API calls for you.

What you can do with MCP

With Envia's MCP server connected to your AI assistant, you can:

  • Quote shipping rates — "Get me DHL rates from Monterrey to CDMX for a 2.5 kg box"
  • Create shipping labels — "Generate a FedEx Express label for this order"
  • Track packages — "Where is tracking number 7072262094?"
  • Validate addresses — "Is postal code 64060 valid in Mexico?"
  • Explore carriers — "What carriers are available for domestic shipping in Mexico?"
  • Manage shipments — "Cancel shipment 7072262094" or "Schedule a pickup for tomorrow"

The agent reads Envia's API documentation, builds the correct request, and returns the response in a readable format — all inside your editor.

How it works

sequenceDiagram
    participant You as You (IDE)
    participant Agent as AI Agent
    participant MCP as Envia MCP Server
    participant API as Envia APIs

    You->>Agent: "Get DHL rates from MTY to CDMX"
    Agent->>MCP: Discover available tools
    MCP-->>Agent: Tool list (rate, generate, track, ...)
    Agent->>MCP: Call rate tool with parameters
    MCP->>API: POST /ship/rate/
    API-->>MCP: Rate response
    MCP-->>Agent: Formatted results
    Agent-->>You: "DHL Express: $185.20 MXN, 2-3 days"

Prerequisites

Before connecting, make sure you have:

  1. An Envia accountCreate a sandbox account or use your existing production account
  2. An API key — Copy your token from Desarrolladores → Acceso de API in the sandbox dashboard or production dashboard. See Authentication for details
  3. Node.js 18 or later — Required to run the MCP server
  4. An MCP-compatible assistant — Claude Desktop, Cursor, or VS Code with GitHub Copilot

Quick start

Run the server directly with npx — no installation needed:

npx @envia/envia-mcp

Or install it globally:

npm install -g @envia/envia-mcp

The server uses stdio transport, which means your AI assistant launches it as a local process and communicates through standard input/output. You do not need to open ports or deploy anything.

IDE setup

Choose your assistant and add the configuration below. Replace your_api_key_here with the token from Desarrolladores → Acceso de API in the sandbox or production dashboard.

Add to your Claude Desktop configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "envia": {
      "command": "npx",
      "args": ["@envia/envia-mcp"],
      "env": {
        "ENVIA_API_KEY": "your_api_key_here"
      }
    }
  }
}

Restart Claude Desktop after saving. The Envia tools will appear in the tool list automatically.

💡

Tip: To use the production environment, add "ENVIA_ENVIRONMENT": "production" to the env block. The default is sandbox, which is safe for testing without real charges.

Environment variables

VariableRequiredDefaultDescription
ENVIA_API_KEYYesYour Envia JWT token from Desarrolladores → Acceso de API (sandbox | production)
ENVIA_ENVIRONMENTNosandboxsandbox for testing or production for live shipments

The server automatically selects the correct API base URLs for the chosen environment. See Authentication for the full list of sandbox and production URLs.

Available tools

The MCP server registers 10 tools that cover the complete shipping lifecycle:

ToolDescriptionAPI
envia_validate_addressValidate postal codes and look up citiesGeocodes
envia_list_carriersList available carriers and services for a countryQueries
envia_get_shipping_ratesCompare rates across multiple carriers for a routeShipping
envia_create_labelPurchase a shipping label (charges your balance)Shipping
envia_track_packageTrack one or more shipments by tracking numberShipping
envia_cancel_shipmentVoid a label and reclaim your balanceShipping
envia_schedule_pickupSchedule a carrier pickup at the origin addressShipping
envia_get_shipment_historyList all shipments created in a given monthQueries
envia_classify_hscodeClassify a product into an HS code for customsShipping
envia_create_commercial_invoiceGenerate a customs invoice PDF for international shipmentsShipping

Supported AI assistants

Envia's MCP server works with any AI assistant that supports the Model Context Protocol:

Example conversations

These examples show how the AI assistant uses the MCP tools behind the scenes.

Domestic shipment (Mexico)

You: Ship a 2 kg box (30×20×15 cm) from postal code 64000 in Monterrey
     to 03100 in Mexico City. Compare DHL and Estafeta rates.

AI:  [calls envia_validate_address for both postal codes]
     [calls envia_get_shipping_rates with carriers: dhl,estafeta]

     Here are your options:
       DHL Economy:      $185.20 MXN — 3-5 business days
       Estafeta Express: $210.00 MXN — 1-2 business days

     Would you like me to create a label with one of these?

You: Yes, go with DHL Economy.

AI:  [calls envia_create_label]

     Label created!
       Tracking: 7520610403
       Label PDF: https://...
       Price: $185.20 MXN

International customs classification

You: I need to ship handmade ceramic mugs from Mexico to the US.
     What HS code should I use?

AI:  [calls envia_classify_hscode]

     Recommended HS code: 6912.00 — Ceramic tableware
     This code is required for customs when creating an international label.

What's next?

💡

Why MCP?

MCP is becoming the standard way for AI agents to interact with APIs. Companies like Stripe, Cloudflare, and Shopify already publish MCP servers. By supporting MCP, Envia enables developers to build shipping features faster using AI-assisted workflows — without leaving their editor.