How to Use the Heap MCP in Mastra AI
Build analytics workflows for Heap that don't break. Mastra AI adds automatic retries and conditional logic to your event tracking.
Works with every AI agent you already use
…and any MCP-compatible client
Connect Heap MCP to Mastra AI
Create your Vinkius account to connect Heap 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.
Create Unbreakable Event Pipelines
Stop losing events during API outages or traffic spikes. A Mastra AI workflow can wrap `track_event` calls with built-in retry logic. If Heap's API is temporarily unavailable, the workflow waits and tries again automatically. For high-volume jobs, you can build smarter logic. The workflow can try `track_event`, but if it hits a rate limit, it can pivot to buffering and sending events with `bulk_track_events` instead. It's a self-healing data pipeline for your MCP integration.
Automate Your User Onboarding with Mastra AI
A user signing up isn't a single event—it's a process. A Mastra AI agent can orchestrate the whole thing: first it calls `identify_user`, then follows up with `add_user_properties` to set their plan, and finally uses `add_account_properties` to link them to their company. The best part is the error handling. If adding account properties fails, the workflow doesn't just crash. It can log the specific failure, notify a support channel, and still complete the user-facing parts of the signup.
Hands-off GDPR Compliance
Automate your GDPR "right to be forgotten" process. When a deletion request comes in, it can trigger a Mastra AI workflow using this MCP server. The agent's only job is to call the `delete_user_data` tool with the user's ID. Mastra's engine guarantees execution. If the initial API call fails for any reason, the workflow will retry until it gets a success confirmation from Heap. You get an auditable, reliable process for data deletion without any manual work.
Set up Heap 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 Heap 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: "heap-mcp-client",
servers: {
"heap-mcp": {
url: new URL(
"https://edge.vinkius.com/[YOUR_TOKEN_HERE]/mcp"
),
},
},
});
const agent = new Agent({
name: "Heap Agent",
model: openai("gpt-4o"),
instructions: "You have access to Heap tools.",
tools: {
...(await mcpClient.listTools()),
},
});
const result = await agent.generate(
"List recent Heap 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 Heap. 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 Heap MCP in Mastra AI
Use it with your favorite AI tools
Connect this server to Cursor, Claude, VS Code, and more.
Start using the Heap MCP today
We host it, we monitor it, we maintain it. You just paste one token.