@devries-cameron20 / composio Mirror · read-only
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 06:00 UTC

next
md 65 lines 2.16 KB
Rendered Raw
1 # @composio/mastra
2
3 The Mastra provider turns Composio tools into Mastra's tool format with built-in execution, ready to pass to a Mastra `Agent`.
4
5 ## Installation
6
7 ```bash
8 npm install @composio/core @composio/mastra @mastra/core @ai-sdk/openai
9 ```
10
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).
12
13 ## Quickstart
14
15 Create a session for your user, fetch its tools, and hand them to an agent:
16
17 ```typescript
18 import { Composio } from '@composio/core';
19 import { MastraProvider } from '@composio/mastra';
20 import { Agent } from '@mastra/core/agent';
21 import { openai } from '@ai-sdk/openai';
22
23 const composio = new Composio({
24 provider: new MastraProvider(),
25 });
26
27 // Create a session for your user
28 const session = await composio.create('user_123');
29 const tools = await session.tools();
30
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 });
38
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 ]);
46
47 console.log(text);
48 ```
49
50 Each tool gets both an input and an output schema, so Mastra can validate tool results as well as arguments.
51
52 ## Strict mode
53
54 Pass `strict: true` to normalize each tool's input schema for OpenAI structured outputs before Mastra compiles it: every object lists all of its properties in `required` and is closed, and optional properties stay available but accept `null`. A `null` is dropped before the tool runs unless the tool's own schema accepts `null` for that parameter, so nullable fields still receive an explicit `null`. Tools whose schema cannot be expressed in strict mode, such as objects that accept arbitrary keys, `allOf`, `prefixItems`, or unresolved `$ref`s, keep their original schema and log a warning:
55
56 ```typescript
57 const composio = new Composio({
58 provider: new MastraProvider({ strict: true }),
59 });
60 ```
61
62 ## Links
63
64 - [Mastra provider docs](https://docs.composio.dev/docs/providers/mastra)
65 - [Composio documentation](https://docs.composio.dev)