@composio/mastra 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,121 +1,65 @@
1
1
  # @composio/mastra
2
2
 
3
- Agentic Provider for Mastra in Composio SDK.
4
-
5
- ## Features
6
-
7
- - **Full Modifier Support**: Support for both schema and execution modifiers
8
- - **Tool Execution**: Execute tools with proper parameter handling
9
- - **Type Safety**: Full TypeScript support with proper type definitions
10
- - **Agentic Capabilities**: Full support for autonomous agent behavior
11
- - **Streaming Support**: First-class support for streaming responses
12
- - **Custom Execution**: Support for custom tool execution strategies
3
+ The Mastra provider turns Composio tools into Mastra's tool format with built-in execution, ready to pass to a Mastra `Agent`.
13
4
 
14
5
  ## Installation
15
6
 
16
7
  ```bash
17
- npm install @composio/core @composio/mastra
18
- # or
19
- yarn add @composio/core @composio/mastra
20
- # or
21
- pnpm add @composio/core @composio/mastra
8
+ npm install @composio/core @composio/mastra @mastra/core @ai-sdk/openai
22
9
  ```
23
10
 
24
- ## Environment Variables
25
-
26
- Required environment variables:
27
-
28
- - `COMPOSIO_API_KEY`: Your Composio API key
29
- - `MASTRA_API_KEY`: Your Mastra API key
11
+ Set `COMPOSIO_API_KEY` with your API key from [the dashboard](https://dashboard.composio.dev/settings), and `OPENAI_API_KEY` (or your LLM provider's key).
30
12
 
31
- Optional environment variables:
13
+ ## Quickstart
32
14
 
33
- - `MASTRA_API_URL`: Custom API base URL (defaults to Mastra's API)
34
- - `MASTRA_DEBUG`: Enable debug logging (set to "true")
35
-
36
- ## Quick Start
15
+ Create a session for your user, fetch its tools, and hand them to an agent:
37
16
 
38
17
  ```typescript
39
18
  import { Composio } from '@composio/core';
40
19
  import { MastraProvider } from '@composio/mastra';
20
+ import { Agent } from '@mastra/core/agent';
21
+ import { openai } from '@ai-sdk/openai';
41
22
 
42
- // Initialize Composio with Mastra provider
43
23
  const composio = new Composio({
44
- apiKey: process.env.COMPOSIO_API_KEY,
45
- provider: new MastraProvider({
46
- apiKey: process.env.MASTRA_API_KEY,
47
- }),
48
- });
49
-
50
- // Get available tools
51
- const tools = await composio.tools.get('user123', {
52
- toolkits: ['gmail', 'googlecalendar'],
53
- limit: 10,
24
+ provider: new MastraProvider(),
54
25
  });
55
- ```
56
26
 
57
- ## Examples
27
+ // Create a session for your user
28
+ const session = await composio.create('user_123');
29
+ const tools = await session.tools();
58
30
 
59
- Check out our complete example implementations:
60
-
61
- - [Basic Mastra Integration](../../examples/mastra/src/index.ts)
62
-
63
- ## API Reference
64
-
65
- ### MastraProvider Class
66
-
67
- The `MastraProvider` class extends `BaseAgenticProvider` and provides Mastra-specific functionality.
68
-
69
- #### Constructor
70
-
71
- ```typescript
72
- new MastraProvider(options?: MastraProviderOptions)
73
- ```
74
-
75
- Options:
76
-
77
- - `apiKey`: Your Mastra API key
78
- - `apiUrl`: Custom API base URL
79
- - `debug`: Enable debug logging
80
- - `modifiers`: Custom execution modifiers
81
- - `executionStrategy`: Custom tool execution strategy
82
-
83
- #### Methods
84
-
85
- ##### `wrapTool(tool: Tool, executeTool: ExecuteToolFn): MastraTool`
31
+ const agent = new Agent({
32
+ id: 'my-agent',
33
+ name: 'My Agent',
34
+ instructions: 'You are a helpful assistant.',
35
+ model: openai('gpt-5.2'),
36
+ tools,
37
+ });
86
38
 
87
- Wraps a tool in the Mastra format.
39
+ const { text } = await agent.generate([
40
+ {
41
+ role: 'user',
42
+ content:
43
+ "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'",
44
+ },
45
+ ]);
88
46
 
89
- ```typescript
90
- const tool = provider.wrapTool(composioTool, executeTool);
47
+ console.log(text);
91
48
  ```
92
49
 
93
- ##### `wrapTools(tools: Tool[], executeTool: ExecuteToolFn): MastraToolCollection`
50
+ Each tool gets both an input and an output schema, so Mastra can validate tool results as well as arguments.
94
51
 
95
- Wraps multiple tools in the Mastra format.
52
+ ## Strict mode
96
53
 
97
- ```typescript
98
- const tools = provider.wrapTools(composioTools, executeTool);
99
- ```
100
-
101
- ##### `executeToolCall(userId: string, toolCall: MastraToolCall, options?: ExecuteToolFnOptions): Promise<string>`
102
-
103
- Executes a tool call from Mastra and returns the result.
54
+ Pass `strict: true` to drop every non-required property from each tool's input schema before Mastra compiles it:
104
55
 
105
56
  ```typescript
106
- const result = await provider.executeToolCall('user123', toolCall, {
107
- connectedAccountId: 'account123',
57
+ const composio = new Composio({
58
+ provider: new MastraProvider({ strict: true }),
108
59
  });
109
60
  ```
110
61
 
111
- ## Contributing
112
-
113
- We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
114
-
115
- ## License
116
-
117
- ISC License
118
-
119
- ## Support
62
+ ## Links
120
63
 
121
- For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
64
+ - [Mastra provider docs](https://docs.composio.dev/docs/providers/mastra)
65
+ - [Composio documentation](https://docs.composio.dev)
package/dist/index.d.mts CHANGED
@@ -42,12 +42,12 @@ declare class MastraProvider extends BaseAgenticProvider<MastraToolCollection, M
42
42
  strict?: boolean;
43
43
  });
44
44
  /**
45
- * Transform MCP URL response into Anthropic-specific format.
46
- * By default, Anthropic uses the standard format (same as default),
47
- * but this method is here to show providers can customize if needed.
45
+ * Transform an MCP URL response into the Mastra provider's format.
46
+ * Mastra expects a URL map keyed by server name, so each entry is
47
+ * reduced into an object of `{ [name]: { url } }`.
48
48
  *
49
49
  * @param data - The MCP URL response data
50
- * @returns Standard MCP server response format
50
+ * @returns The MCP servers as a Mastra URL map
51
51
  */
52
52
  wrapMcpServerResponse(data: McpUrlResponse): MastraUrlMap;
53
53
  wrapTool(tool: Tool, executeTool: ExecuteToolFn): MastraTool;
package/dist/index.mjs CHANGED
@@ -125,12 +125,12 @@ var MastraProvider = class extends BaseAgenticProvider {
125
125
  this.strict = strict;
126
126
  }
127
127
  /**
128
- * Transform MCP URL response into Anthropic-specific format.
129
- * By default, Anthropic uses the standard format (same as default),
130
- * but this method is here to show providers can customize if needed.
128
+ * Transform an MCP URL response into the Mastra provider's format.
129
+ * Mastra expects a URL map keyed by server name, so each entry is
130
+ * reduced into an object of `{ [name]: { url } }`.
131
131
  *
132
132
  * @param data - The MCP URL response data
133
- * @returns Standard MCP server response format
133
+ * @returns The MCP servers as a Mastra URL map
134
134
  */
135
135
  wrapMcpServerResponse(data) {
136
136
  return data.reduce((acc, item) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/mastra",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Agentic Provider for mastra in Composio SDK",
5
5
  "main": "dist/index.mjs",
6
6
  "type": "module",
@@ -12,7 +12,7 @@
12
12
  "bugs": {
13
13
  "url": "https://github.com/ComposioHQ/composio/issues"
14
14
  },
15
- "homepage": "https://github.com/ComposioHQ/composio/tree/main/ts/packages/providers/mastra#readme",
15
+ "homepage": "https://github.com/ComposioHQ/composio/tree/next/ts/packages/providers/mastra#readme",
16
16
  "publishConfig": {
17
17
  "access": "public"
18
18
  },
@@ -35,19 +35,20 @@
35
35
  "license": "ISC",
36
36
  "peerDependencies": {
37
37
  "@composio/core": ">=0.10.0 <1.0.0",
38
- "@mastra/core": "^1.0.4",
38
+ "@mastra/core": "^1.46.0",
39
39
  "zod": "^3.25 || ^4"
40
40
  },
41
41
  "devDependencies": {
42
- "@mastra/core": "^1.42.0",
42
+ "@mastra/core": "^1.50.1",
43
+ "ai": "^6.0.219",
43
44
  "tsdown": "^0.22.3",
44
45
  "typescript": "^6.0.3",
45
- "vitest": "^4.1.9",
46
+ "vitest": "^4.1.10",
46
47
  "zod": "^4.4.3",
47
- "@composio/core": "0.12.0"
48
+ "@composio/core": "0.14.0"
48
49
  },
49
50
  "dependencies": {
50
- "@mastra/schema-compat": "^1.2.9"
51
+ "@mastra/schema-compat": "^1.3.3"
51
52
  },
52
53
  "scripts": {
53
54
  "clean": "git clean -xdf node_modules",