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 22, 23:15 UTC
Update docs
haxzie committed
Jun 20, 2025 at 12:45 UTC
8fe6f538105a0ad82642044bd07bc96097837fa9
3 files changed
+226
-6
fern/pages/src/tool-calling/executing-tools.mdx
+123
-1
@@ -231,4 +231,126 @@ response = composio.tools.proxy(
231
```
232
</CodeGroup>
233
234
-If you're interested in extending toolkits and creating custom tools, see [Custom tools](/docs/custom-tools).
\ No newline at end of file
234
+If you're interested in extending toolkits and creating custom tools, see [Custom tools](/docs/custom-tools).
235
+
236
+## Automatic File Handling
237
+
238
+Composio SDK includes automatic file handling for tools that work with files. When enabled (default), the SDK automatically handles file uploads and downloads during tool execution.
239
+
240
+### File Upload
241
+
242
+When a tool accepts file inputs (marked with `file_uploadable: true`), you can pass local file paths or URLs. Here's an example using Google Drive upload:
243
+
244
+<CodeGroup>
245
+```typescript TypeScript maxLines=60 wordWrap
246
+import { Composio } from '@composio/core';
247
+import path from 'path';
248
+
249
+const composio = new Composio({
250
+ apiKey: process.env.COMPOSIO_API_KEY
251
+});
252
+
253
+// Upload a local file to Google Drive
254
+const result = await composio.tools.execute('GOOGLEDRIVE_UPLOAD_FILE', {
255
+ userId: 'default',
256
+ arguments: {
257
+ file_to_upload: path.join(__dirname, 'document.pdf') // Local file path
258
+ }
259
+});
260
+
261
+console.log(result.data); // Contains Google Drive file details
262
+```
263
+
264
+```python Python maxLines=60 wordWrap
265
+from composio import Composio
266
+import os
267
+
268
+composio = Composio()
269
+
270
+# Upload a local file to Google Drive
271
+result = composio.tools.execute(
272
+ "GOOGLEDRIVE_UPLOAD_FILE",
273
+ user_id="default",
274
+ arguments={
275
+ "file_to_upload": os.path.join(os.getcwd(), "document.pdf") # Local file path
276
+ }
277
+)
278
+
279
+print(result.data) # Contains Google Drive file details
280
+```
281
+</CodeGroup>
282
+
283
+The SDK automatically:
284
+1. Reads the file content
285
+2. Uploads it to secure storage
286
+3. Passes the file metadata to the tool
287
+
288
+### File Download
289
+
290
+When a tool returns file outputs, the SDK automatically:
291
+1. Downloads the file to a local temporary directory
292
+2. Provides the local file path in the response
293
+
294
+<CodeGroup>
295
+```typescript TypeScript maxLines=60 wordWrap
296
+// Download a file from Google Drive
297
+const result = await composio.tools.execute('GOOGLEDRIVE_DOWNLOAD_FILE', {
298
+ userId: 'default',
299
+ arguments: {
300
+ file_id: 'your_file_id'
301
+ }
302
+});
303
+
304
+// Result includes local file path
305
+console.log(result.data.file.uri); // "/path/to/downloaded/file.pdf"
306
+```
307
+
308
+```python Python maxLines=60 wordWrap
309
+# Download a file from Google Drive
310
+result = composio.tools.execute(
311
+ "GOOGLEDRIVE_DOWNLOAD_FILE",
312
+ user_id="default",
313
+ arguments={
314
+ "file_id": "your_file_id"
315
+ }
316
+)
317
+
318
+# Result includes local file path
319
+print(result.data["file"]["uri"]) # "/path/to/downloaded/file.pdf"
320
+```
321
+</CodeGroup>
322
+
323
+### Disabling Auto File Handling
324
+
325
+You can disable automatic file handling when initializing the SDK:
326
+
327
+<CodeGroup>
328
+```typescript TypeScript maxLines=60 wordWrap
329
+const composio = new Composio({
330
+ apiKey: process.env.COMPOSIO_API_KEY,
331
+ autoUploadDownloadFiles: false
332
+});
333
+
334
+// Now you need to handle files manually using composio.files API
335
+const fileData = await composio.files.upload({
336
+ filePath: path.join(__dirname, 'document.pdf'),
337
+ toolSlug: 'GOOGLEDRIVE_UPLOAD_FILE',
338
+ toolkitSlug: 'googledrive'
339
+});
340
+```
341
+
342
+```python Python maxLines=60 wordWrap
343
+composio = Composio(
344
+ auto_upload_download_files=False
345
+)
346
+
347
+# Now you need to handle files manually using composio.files API
348
+file_data = composio.files.upload(
349
+ file_path=os.path.join(os.getcwd(), "document.pdf"),
350
+ tool_slug="GOOGLEDRIVE_UPLOAD_FILE",
351
+ toolkit_slug="googledrive"
352
+)
353
+```
354
+</CodeGroup>
355
+
356
+For more details on file handling, see [Auto Upload and Download Files](/docs/advanced/auto-upload-download).
\ No newline at end of file
fern/pages/src/tool-calling/fetching-tools.mdx
+75
-3
@@ -22,6 +22,7 @@ When you fetch tools from a toolkit, the most important tools are returned first
22
23
Composio determines the importance of a tool based on the usage and relevance of the tool.
24
</Tip>
25
+
26
<CodeGroup>
27
```typescript TypeScript maxLines=60 wordWrap
28
const tools = await composio.tools.get(
@@ -57,7 +58,38 @@ const tools = await composio.tools.get(userId, {
58
tools = composio.tools.get(
59
user_id,
60
toolkits=["GITHUB"],
60
- limit=5, # Returns the top 5 important tools from the toolkit
61
+ limit=5, // Returns the top 5 important tools from the toolkit
62
+)
63
+```
64
+</CodeGroup>
65
+
66
+**Filtering by scopes**
67
+
68
+When working with OAuth-based toolkits, you can filter tools based on their required scopes. This is useful when you want to:
69
+- Get tools that match specific permission levels
70
+- Ensure tools align with available user permissions
71
+- Filter tools based on their required OAuth scopes
72
+
73
+<Tip title="Single Toolkit Requirement" icon="warning">
74
+Scope filtering can only be used with a single toolkit at a time.
75
+</Tip>
76
+
77
+<CodeGroup>
78
+```typescript TypeScript maxLines=60 wordWrap
79
+// Get GitHub tools that require specific scopes
80
+const tools = await composio.tools.get(userId, {
81
+ toolkits: ["GITHUB"],
82
+ scopes: ["repo"], // Only get tools requiring these scopes
83
+ limit: 10
84
+});
85
+```
86
+```python Python maxLines=60 wordWrap
87
+# Get GitHub tools that require specific scopes
88
+tools = composio.tools.get(
89
+ user_id,
90
+ toolkits=["GITHUB"],
91
+ scopes=["repo",], // Only get tools requiring these scopes
92
+ limit=10
93
)
94
```
95
</CodeGroup>
@@ -118,11 +150,17 @@ You may also filter tools by searching for them. This is a good way to find tool
150
This step runs a semantic search on the tool names and descriptions and returns the most relevant tools.
151
152
<CodeGroup>
121
-
153
```typescript TypeScript maxLines=60 wordWrap
154
const tools = await composio.tools.get(userId, {
155
search: "hubspot organize contacts",
156
});
157
+
158
+// Search within a specific toolkit
159
+const tools = await composio.tools.get(userId, {
160
+ search: "repository issues",
161
+ toolkits: ["GITHUB"], // Optional: limit search to specific toolkit
162
+ limit: 5 // Optional: limit number of results
163
+});
164
```
165
166
```python Python maxLines=60 wordWrap
@@ -130,5 +168,39 @@ tools = composio.tools.get(
168
user_id,
169
search="hubspot organize contacts",
170
)
171
+
172
+# Search within a specific toolkit
173
+tools = composio.tools.get(
174
+ user_id,
175
+ search="repository issues",
176
+ toolkits=["GITHUB"], // Optional: limit search to specific toolkit
177
+ limit=5 // Optional: limit number of results
178
+)
179
```
134
-</CodeGroup>
\ No newline at end of file
180
+</CodeGroup>
181
+
182
+## Filter Combinations
183
+
184
+When fetching tools, you must use one of these filter combinations:
185
+
186
+1. **Tools Only**: Fetch specific tools by their slugs
187
+ ```typescript
188
+ { tools: ["TOOL_1", "TOOL_2"] }
189
+ ```
190
+
191
+2. **Toolkits Only**: Fetch tools from specific toolkits
192
+ ```typescript
193
+ { toolkits: ["TOOLKIT_1", "TOOLKIT_2"], limit?: number }
194
+ ```
195
+
196
+3. **Single Toolkit with Scopes**: Fetch tools requiring specific OAuth scopes
197
+ ```typescript
198
+ { toolkits: ["GITHUB"], scopes: ["read:repo"], limit?: number }
199
+ ```
200
+
201
+4. **Search**: Search across all tools or within specific toolkits
202
+ ```typescript
203
+ { search: "query", toolkits?: string[], limit?: number }
204
+ ```
205
+
206
+These combinations are mutually exclusive - you can't mix `tools` with `search` or use `scopes` with multiple toolkits.
\ No newline at end of file
ts/docs/api/tools.md
+28
-2
@@ -178,13 +178,15 @@ type ToolsOnlyParams = {
178
toolkits?: never; // Cannot be used with tools
179
limit?: never;
180
search?: never;
181
-};
181
+ scopes?: never;
182
+}
183
184
type ToolkitsOnlyParams = {
185
tools?: never; // Cannot be used with toolkits
186
toolkits: string[]; // List of toolkit slugs to filter by
187
limit?: number; // Limit the number of results
187
- search?: never; // Cannot be used with important flag,
188
+ search?: never; // Cannot be used with important flag
189
+ scopes?: string[]; // Optional list of required OAuth scopes
190
};
191
192
type ToolkitSearchOnlyParams = {
@@ -192,6 +194,7 @@ type ToolkitSearchOnlyParams = {
194
toolkits?: string[]; // Optional list of toolkit slugs to filter by
195
limit?: number; // Limit the number of results
196
search: string; // Search term
197
+ scopes?: string[]; // Optional list of required OAuth scopes
198
};
199
200
type ToolListParams = ToolsOnlyParams | ToolkitsOnlyParams | ToolkitSearchOnlyParams;
@@ -202,6 +205,29 @@ Note: The parameters are organized into three mutually exclusive combinations:
205
1. Using `tools` array to fetch specific tools by their slugs
206
2. Using `toolkits` with optional `important` flag to fetch tools from specific toolkits
207
3. Using `search` with optional `toolkits` to search for tools by name/description
208
+4. Using `scopes` can only be done with a single `toolkits` slug
209
+
210
+You can also filter tools by their scopes:
211
+
212
+```typescript
213
+// Get tools with specific scopes
214
+const scopedTools = await composio.tools.get('default', {
215
+ toolkits: ['github'],
216
+ scopes: ['read:repo', 'write:repo'], // Only get tools requiring these scopes
217
+});
218
+
219
+// Search tools with specific scopes
220
+const searchedScopedTools = await composio.tools.get('default', {
221
+ search: 'repository',
222
+ scopes: ['read:repo'], // Only get tools requiring read:repo scope
223
+ limit: 10,
224
+});
225
+```
226
+
227
+The `scopes` parameter allows you to:
228
+- Filter tools based on their required OAuth scopes
229
+- Get tools that match specific permission levels
230
+- Ensure tools align with available user permissions
231
232
Examples:
233