How to Use the Beehiiv MCP in Mastra AI
Build resilient Beehiiv automations with Mastra AI. Create multi-step workflows that handle failures, retries, and conditional logic for you.
Works with every AI agent you already use
…and any MCP-compatible client
Connect Beehiiv MCP to Mastra AI
Create your Vinkius account to connect Beehiiv 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 Subscriber Workflows
Use the `create_subscription` tool inside a Mastra AI workflow to build a bulletproof signup process. If the initial attempt to add a subscriber to Beehiiv fails, Mastra's engine can automatically retry with exponential backoff. You won't lose signups from temporary network blips. You can also build conditional logic. For instance, use `get_subscription` to check if a user is already subscribed. If they are, your agent can trigger a different part of your workflow; if not, it calls `create_subscription`. This lets you handle complex logic without a lot of boilerplate code.
Build Multi-Step Beehiiv Agents with Mastra AI
Mastra AI is designed for running sequential tasks. You can create a workflow that first calls `list_posts`, then iterates through each post ID to call `get_post_stats`. This gives you a simple way to pull analytics for all your content in one automated job. Add human-in-the-loop approvals for critical steps. For example, your agent could use `get_publication` to check settings, propose a change, and then use Mastra's `requireToolApproval` to wait for your sign-off before making an update. It’s automation with a safety net.
Sync Beehiiv Data to Your Systems
Set up a recurring workflow in Mastra AI to pull data from Beehiiv. You could have an agent that runs daily, calls `list_subscriptions`, and syncs the new subscriber list to your internal CRM or data warehouse. Mastra handles the scheduling and execution. This is also great for reporting. Create an agent that calls `get_post_stats` for your latest newsletter, formats the data, and then uses another tool to send a summary to a Slack channel. This MCP server provides the data access; Mastra provides the reliable engine.
Set up Beehiiv 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 Beehiiv 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: "beehiiv-mcp-client",
servers: {
"beehiiv-mcp": {
url: new URL(
"https://edge.vinkius.com/[YOUR_TOKEN_HERE]/mcp"
),
},
},
});
const agent = new Agent({
name: "Beehiiv Agent",
model: openai("gpt-4o"),
instructions: "You have access to Beehiiv tools.",
tools: {
...(await mcpClient.listTools()),
},
});
const result = await agent.generate(
"List recent Beehiiv 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 Beehiiv. 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 Beehiiv MCP in Mastra AI
Use it with your favorite AI tools
Connect this server to Cursor, Claude, VS Code, and more.
Start using the Beehiiv MCP today
We host it, we monitor it, we maintain it. You just paste one token.