Mastra
Connect a Mastra agent to Leadovaro using MCPClient with Streamable HTTP transport. Mastra's MCP client exposes all discovered tools directly to a Mastra Agent.
Prerequisites
- Node.js 20+
- A Leadovaro account at app.leadovaro.com with a configured toolkit
- A Leadovaro token and an Anthropic API key
Installation
pnpm add @mastra/mcp @mastra/core @ai-sdk/anthropic
Environment Variables
LEADOVARO_URL=/_sites/app.leadovaro.com/hub/mcp?profile=your-toolkit
LEADOVARO_TOKEN=your-leadovaro-token
ANTHROPIC_API_KEY=your-anthropic-key
Get Your Credentials
How to generate a Leadovaro token and configure toolkit URL parameters
Connecting to Leadovaro
Use MCPClient with the servers config, then call listToolsets() to get all tools:
import { MCPClient } from "@mastra/mcp";
import { Agent } from "@mastra/core/agent";
import { anthropic } from "@ai-sdk/anthropic";
const leadovaroMcp = new MCPClient({
servers: {
leadovaro: {
url: new URL(process.env.LEADOVARO_URL!),
requestInit: {
headers: { Authorization: `Bearer ${process.env.LEADOVARO_TOKEN}` },
},
},
},
});
// Use listToolsets() — not getTools()
const toolsets = await leadovaroMcp.listToolsets();
const allTools = Object.values(toolsets).reduce(
(acc, ts) => ({ ...acc, ...ts }),
{}
);
console.log(`${Object.keys(allTools).length} tools loaded`);
const agent = new Agent({
name: "Leadovaro Assistant",
model: anthropic("claude-sonnet-4-6"),
instructions: "You are a helpful assistant with access to Leadovaro tools.",
tools: allTools,
});
note
Use leadovaroMcp.listToolsets() — not leadovaroMcp.getTools(). Merge the returned toolsets object with Object.values(toolsets).reduce((acc, ts) => ({ ...acc, ...ts }), {}) before passing to the agent.
Running the Agent
async function main() {
const response = await agent.generate("What events do I have today?");
console.log(response.text);
await leadovaroMcp.disconnect();
}
main();
Production Configuration
For production agents, lock to a specific toolkit using the profile URL parameter:
LEADOVARO_URL=/_sites/app.leadovaro.com/hub/mcp?profile=your-production-toolkit
Reference Implementation
mastra-reference-implementation-leadovaro
Complete implementation with Fastify chat UI and deployment guide