How to Use the AfterShip Tracking MCP in Mastra AI
Build resilient logistics workflows that never drop a package using Mastra AI and the AfterShip Tracking MCP Server.
Works with every AI agent you already use
…and any MCP-compatible client
Connect AfterShip Tracking MCP to Mastra AI
Create your Vinkius account to connect AfterShip Tracking to Mastra AI and route execution through our secure gateway. The platform manages server hosting, runtime updates, and security layers. Configuration requires no manual server provisioning.
Automated carrier detection workflows
The `detect_courier` tool inspects raw tracking numbers to route packages to the correct API endpoint automatically. Mastra AI takes that output and branches the workflow depending on whether it is USPS, FedEx, or a regional carrier. If the detection fails, your agent doesn't crash. It uses built-in exponential backoff to retry the request or triggers a fallback step to ask the user for clarification.
Resilient tracking registration
Firing the `create_tracking` tool registers a new package ID to start monitoring its journey across the supply chain. You drop this step into a multi-stage workflow right after an order completes in your database. Should the API reject the registration due to rate limits, Mastra pauses and tries again later. The MCP integration ensures that every single tracking number eventually hits the monitoring system.
Audit shipments with Mastra AI
The `list_trackings` tool dumps your entire active shipment ledger into the agent's context window. You can build a cron-triggered workflow that scans this data daily for exceptions like stuck in transit or delivery attempted. Combine this with the `get_tracking_details` tool to pull granular coordinates for problematic packages. Your system then fires off an email to the customer explaining the delay before they even realize there is an issue.
Set up AfterShip Tracking MCP in Mastra AI
Prerequisites
- Node.js 18+ and a TypeScript project
-
@mastra/mcp+@mastra/corepackages - Active Vinkius subscription with a valid endpoint token
- 1
Install dependencies
Run
npm install @mastra/mcp @mastra/coreplus your preferred model provider (e.g.@ai-sdk/openai). - 2
Configure the MCPClient
Create an
MCPClientwith your Vinkius endpoint as aURLobject. Replace[YOUR_TOKEN_HERE]with your token from cloud.vinkius.com. - 3
Discover and inject tools
Call
mcpClient.listTools()and spread the result into your agent'stoolsobject. All AfterShip Tracking tools become native Mastra tools. - 4
Run with any model
Swap
openai("gpt-4o")for any AI SDK-compatible provider. Callagent.generate()and the agent routes tool calls through MCP automatically.
import { MCPClient } from "@mastra/mcp";
import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";
const mcpClient = new MCPClient({
id: "aftership-tracking-mcp-client",
servers: {
"aftership-tracking-mcp": {
url: new URL(
"https://edge.vinkius.com/[YOUR_TOKEN_HERE]/mcp"
),
},
},
});
const agent = new Agent({
name: "AfterShip Tracking Agent",
model: openai("gpt-4o"),
instructions: "You have access to AfterShip Tracking tools.",
tools: {
...(await mcpClient.listTools()),
},
});
const result = await agent.generate(
"List recent AfterShip Tracking transactions"
);
console.log(result.text); Independent Platform Disclaimer: Vinkius is an independent platform and is not affiliated with, endorsed by, sponsored by, verified by, or otherwise authorized by AfterShip Tracking. All third-party trademarks, logos, and brand names are the property of their respective owners. Their use on this website is strictly for informational purposes to identify service compatibility and interoperability.
Why Choose Vinkius
Vinkius connects your tools to AI with real-time monitoring and automatic cost savings — all from one dashboard.
Real-time monitoring
Live
visibility into every interaction
Connect your favorite tools to your AI and see exactly what's happening — every request, every response, in real time.
Built-in savings
60%
lower AI costs
Vinkius compresses data between your apps and your AI automatically. Lower bills every month — no configuration required.
Single dashboard
One
place for every integration
Every tool your AI connects to, managed from a single screen. One account, complete control.
Common questions about AfterShip Tracking MCP in Mastra AI
Use it with your favorite AI tools
Connect this server to Cursor, Claude, VS Code, and more.
Start using the AfterShip Tracking MCP today
We host it, we monitor it, we maintain it. You just paste one token.