Mastra
The Mastra provider transforms Composio tools into Mastra's tool format with built-in execution.
Install
npm install @composio/core @composio/mastra @mastra/core @ai-sdk/openaiConfigure API Keys
Set COMPOSIO_API_KEY with your API key from Settings and OPENAI_API_KEY with your OpenAI API key.
COMPOSIO_API_KEY=xxxxxxxxx
OPENAI_API_KEY=xxxxxxxxxCreate session and run
import { Composio } from "@composio/core";
import { MastraProvider } from "@composio/mastra";
import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";
const composio = new Composio({
provider: new MastraProvider(),
});
// Create a session for your user
const session = await composio.create("user_123");
const tools = await session.tools();
const agent = new Agent({
id: "my-agent",
name: "My Agent",
instructions: "You are a helpful assistant.",
model: openai("gpt-5.2"),
tools,
});
const { text } = await agent.generate([
{ role: "user", content: "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'" },
]);
console.log(text);