ts/packages/providers/mastra/README.md
Agentic Provider for Mastra in Composio SDK.
npm install @composio/core @composio/mastra
# or
yarn add @composio/core @composio/mastra
# or
pnpm add @composio/core @composio/mastra
Required environment variables:
COMPOSIO_API_KEY: Your Composio API keyMASTRA_API_KEY: Your Mastra API keyOptional environment variables:
MASTRA_API_URL: Custom API base URL (defaults to Mastra's API)MASTRA_DEBUG: Enable debug logging (set to "true")import { Composio } from '@composio/core';
import { MastraProvider } from '@composio/mastra';
// Initialize Composio with Mastra provider
const composio = new Composio({
apiKey: process.env.COMPOSIO_API_KEY,
provider: new MastraProvider({
apiKey: process.env.MASTRA_API_KEY,
}),
});
// Get available tools
const tools = await composio.tools.get('user123', {
toolkits: ['gmail', 'googlecalendar'],
limit: 10,
});
Check out our complete example implementations:
The MastraProvider class extends BaseAgenticProvider and provides Mastra-specific functionality.
new MastraProvider(options?: MastraProviderOptions)
Options:
apiKey: Your Mastra API keyapiUrl: Custom API base URLdebug: Enable debug loggingmodifiers: Custom execution modifiersexecutionStrategy: Custom tool execution strategywrapTool(tool: Tool, executeTool: ExecuteToolFn): MastraToolWraps a tool in the Mastra format.
const tool = provider.wrapTool(composioTool, executeTool);
wrapTools(tools: Tool[], executeTool: ExecuteToolFn): MastraToolCollectionWraps multiple tools in the Mastra format.
const tools = provider.wrapTools(composioTools, executeTool);
executeToolCall(userId: string, toolCall: MastraToolCall, options?: ExecuteToolFnOptions): Promise<string>Executes a tool call from Mastra and returns the result.
const result = await provider.executeToolCall('user123', toolCall, {
connectedAccountId: 'account123',
});
We welcome contributions! Please see our Contributing Guide for more details.
ISC License
For support, please visit our Documentation or join our Discord Community.