How to Use the Amplitude MCP in Mastra AI
Build resilient product analytics workflows in Mastra AI that automatically pull Amplitude data and handle API limits.
Works with every AI agent you already use
…and any MCP-compatible client
Connect Amplitude MCP to Mastra AI
Create your Vinkius account to connect Amplitude 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.
Automate cohort generation pipelines
The `get_cohort` tool triggers behavioral segment downloads directly from your Mastra AI workflows. Because these downloads require polling until the backend finishes processing, Mastra shines here. Its built-in workflow engine handles the wait states automatically without blocking your main thread. You start by calling `list_cohorts` to grab the ID, then pass it to the download function. If the Amplitude API throttles the request, Mastra applies exponential backoff. Your agent retries the pull, grabs the CSV data, and moves it to your data warehouse without writing custom retry logic.
Handle funnel failures gracefully with Mastra AI
Executing `get_funnel` pulls conversion rates across comma-separated event names. Sometimes product teams rename events, causing queries to fail. Mastra AI lets you build conditional branching to catch these errors. If the primary event name throws an error, the agent automatically retries with a legacy event name. Setting this up requires passing your MCP Client into the Agent tools array. Once connected, your workflow can chain these analytics checks together. It runs `event_segmentation` to find the drop-off, then alerts your product manager via Slack if the conversion dips below a specific threshold.
Audit user activity with human oversight
The `search_users` tool locates specific accounts by email or device ID before diving into their behavior. Since this exposes individual customer journeys, you might want strict control over who runs it. Mastra supports `requireToolApproval` for human-in-the-loop validation. When the agent wants to run `get_user_activity` on a high-profile enterprise account using the MCP Server, the workflow pauses. An admin clicks approve, and the query executes. This gives you deep diagnostic power over individual sessions while maintaining strict compliance protocols.
Set up Amplitude 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 Amplitude 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: "amplitude-mcp-client",
servers: {
"amplitude-mcp": {
url: new URL(
"https://edge.vinkius.com/[YOUR_TOKEN_HERE]/mcp"
),
},
},
});
const agent = new Agent({
name: "Amplitude Agent",
model: openai("gpt-4o"),
instructions: "You have access to Amplitude tools.",
tools: {
...(await mcpClient.listTools()),
},
});
const result = await agent.generate(
"List recent Amplitude 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 Amplitude. 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 Amplitude MCP in Mastra AI
Use it with your favorite AI tools
Connect this server to Cursor, Claude, VS Code, and more.
Start using the Amplitude MCP today
We host it, we monitor it, we maintain it. You just paste one token.