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:
- An Envia account — Create a sandbox account or use your existing production account
- An API key — Copy your token from Desarrolladores → Acceso de API in the sandbox dashboard or production dashboard. See Authentication for details
- Node.js 18 or later — Required to run the MCP server
- 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-mcpOr install it globally:
npm install -g @envia/envia-mcpThe 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 theenvblock. The default issandbox, which is safe for testing without real charges.
Environment variables
| Variable | Required | Default | Description |
|---|---|---|---|
ENVIA_API_KEY | Yes | — | Your Envia JWT token from Desarrolladores → Acceso de API (sandbox | production) |
ENVIA_ENVIRONMENT | No | sandbox | sandbox 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:
| Tool | Description | API |
|---|---|---|
envia_validate_address | Validate postal codes and look up cities | Geocodes |
envia_list_carriers | List available carriers and services for a country | Queries |
envia_get_shipping_rates | Compare rates across multiple carriers for a route | Shipping |
envia_create_label | Purchase a shipping label (charges your balance) | Shipping |
envia_track_package | Track one or more shipments by tracking number | Shipping |
envia_cancel_shipment | Void a label and reclaim your balance | Shipping |
envia_schedule_pickup | Schedule a carrier pickup at the origin address | Shipping |
envia_get_shipment_history | List all shipments created in a given month | Queries |
envia_classify_hscode | Classify a product into an HS code for customs | Shipping |
envia_create_commercial_invoice | Generate a customs invoice PDF for international shipments | Shipping |
Supported AI assistants
Envia's MCP server works with any AI assistant that supports the Model Context Protocol:
Anthropic's desktop app with native MCP support. Recommended for the best experience.
AI-native code editor with built-in MCP client. Ideal for developers building integrations.
GitHub Copilot in VS Code supports MCP servers in agent mode.
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?
Full request/response examples for every shipping step — rates, labels, tracking, and more.
End-to-end walkthrough covering all three APIs from address validation to production.
How to generate API keys and authenticate requests across all three Envia APIs.
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.
Updated about 15 hours ago
