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 23, 00:30 UTC
Rename auth credentials to connection config
haxzie committed
Jun 12, 2025 at 17:55 UTC
81fddf9f0e5de8b6240c24172a4a1c7bf165dbc4
10 files changed
+83
-75
examples/custom-tools/README.md
+6
-6
@@ -42,7 +42,7 @@ const tool = await composio.tools.createCustomTool({
42
inputParams: z.object({
43
owner: z.string().describe('Repository owner'),
44
}),
45
- execute: async (input, authCredentials, executeToolRequest) => {
45
+ execute: async (input, connectionConfig, executeToolRequest) => {
46
// executeToolRequest can only call tools from the 'github' toolkit
47
// Uses the same connected account credentials automatically
48
const listResult = await executeToolRequest({
@@ -78,14 +78,14 @@ const tool = await composio.tools.createCustomTool({
78
inputParams: z.object({
79
repository: z.string().describe('The repository to star'),
80
}),
81
- execute: async (input, authCredentials) => {
82
- // Use authCredentials for direct API calls or when interacting with different services
81
+ execute: async (input, connectionConfig) => {
82
+ // Use connectionConfig for direct API calls or when interacting with different services
83
const result = await fetch(
84
`https://api.github.com/user/starred/composiohq/${input.repository}`,
85
{
86
method: 'PUT',
87
headers: {
88
- Authorization: `Bearer ${authCredentials.val?.access_token}`,
88
+ Authorization: `Bearer ${connectionConfig.val?.access_token}`,
89
},
90
}
91
);
@@ -127,7 +127,7 @@ const tool = await composio.tools.createCustomTool({
127
1. **Standalone vs Toolkit-based Tools**
128
129
- Standalone tools only receive input parameters
130
- - Toolkit-based tools have access to both `executeToolRequest` and `authCredentials`
130
+ - Toolkit-based tools have access to both `executeToolRequest` and `connectionConfig`
131
132
2. **Authentication Methods**
133
@@ -136,7 +136,7 @@ const tool = await composio.tools.createCustomTool({
136
- Uses the connected account credentials automatically
137
- No need to manage auth tokens
138
- Better maintainability and security
139
- - `authCredentials`: For direct API calls
139
+ - `connectionConfig`: For direct API calls
140
- Use when you need to make direct API calls
141
- Use when you need to interact with different services
142
- Requires manual token management
examples/custom-tools/src/auth-credentials.ts
+3
-3
@@ -32,9 +32,9 @@ const tool = await composio.tools.createCustomTool({
32
inputParams: z.object({
33
repository: z.string().describe('The repository to star'),
34
}),
35
- execute: async (input, authCredentials) => {
35
+ execute: async (input, connectionConfig) => {
36
console.log('🚀 ~ execute: ~ params:', input);
37
- console.log('🚀 ~ execute: ~ authCredentials:', authCredentials);
37
+ console.log('🚀 ~ execute: ~ connectionConfig:', connectionConfig);
38
/**
39
* The auth credentials are the auth credentials for the connected account.
40
* You can use them to make requests to the API.
@@ -44,7 +44,7 @@ const tool = await composio.tools.createCustomTool({
44
{
45
method: 'PUT',
46
headers: {
47
- Authorization: `Bearer ${authCredentials?.access_token}`,
47
+ Authorization: `Bearer ${connectionConfig?.access_token}`,
48
},
49
}
50
);
examples/custom-tools/src/index.ts
+2
-2
@@ -32,9 +32,9 @@ const tool = await composio.tools.createCustomTool({
32
inputParams: z.object({
33
repository: z.string().describe('The repository to star'),
34
}),
35
- execute: async (input, authCredentials, executeToolRequest) => {
35
+ execute: async (input, connectionConfig, executeToolRequest) => {
36
console.log('🚀 ~ execute: ~ params:', input);
37
- console.log('🚀 ~ execute: ~ authCredentials:', authCredentials);
37
+ console.log('🚀 ~ execute: ~ connectionConfig:', connectionConfig);
38
39
const result = await executeToolRequest({
40
endpoint: `/user/starred/composiohq/${input.repository}`,
fern/pages/sdk/typescript/CustomTools/classes/CustomTools.mdx
+10
-10
@@ -1,6 +1,6 @@
1
[**@composio/core**](../../README.mdx)
2
3
-***
3
+---
4
5
[@composio/core](../../README.mdx) / [CustomTools](../README.mdx) / CustomTools
6
@@ -41,7 +41,7 @@ This is just an in memory registry and is not persisted.
41
42
##### T
43
44
-`T` *extends* `CustomToolInputParameter`
44
+`T` _extends_ `CustomToolInputParameter`
45
46
#### Parameters
47
@@ -67,18 +67,18 @@ const customTool = await composio.customTools.createTool({
67
slug: 'MY_CUSTOM_TOOL',
68
inputParams: z.object({
69
query: z.string().describe('The search query'),
70
- limit: z.number().optional().describe('Maximum number of results')
70
+ limit: z.number().optional().describe('Maximum number of results'),
71
}),
72
- execute: async (input, authCredentials, executeToolRequest) => {
72
+ execute: async (input, connectionConfig, executeToolRequest) => {
73
// Custom implementation logic
74
return {
75
- data: { results: ['result1', 'result2'] }
75
+ data: { results: ['result1', 'result2'] },
76
};
77
- }
77
+ },
78
});
79
```
80
81
-***
81
+---
82
83
### executeCustomTool()
84
@@ -110,7 +110,7 @@ If a toolkit is used, the connected account id is used to execute the tool.
110
If a connected account id is provided, it is used to execute the tool.
111
If a connected account id is not provided, the first connected account for the toolkit is used.
112
113
-***
113
+---
114
115
### getCustomToolBySlug()
116
@@ -146,7 +146,7 @@ if (myTool) {
146
}
147
```
148
149
-***
149
+---
150
151
### getCustomTools()
152
@@ -178,6 +178,6 @@ const allTools = await composio.customTools.getCustomTools({});
178
179
// Get specific custom tools by slug
180
const specificTools = await composio.customTools.getCustomTools({
181
- toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL']
181
+ toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL'],
182
});
183
```
fern/pages/sdk/typescript/models/Tools/classes/Tools.mdx
+27
-25
@@ -1,6 +1,6 @@
1
[**@composio/core**](../../../README.mdx)
2
3
-***
3
+---
4
5
[@composio/core](../../../README.mdx) / [models/Tools](../README.mdx) / Tools
6
@@ -23,7 +23,7 @@ It provides methods to list, get, and execute tools.
23
24
### TProvider
25
26
-`TProvider` *extends* [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>
26
+`TProvider` _extends_ [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>
27
28
## Constructors
29
@@ -64,7 +64,7 @@ while keeping a consistent interface for both built-in and custom tools.
64
65
##### T
66
67
-`T` *extends* `CustomToolInputParameter`
67
+`T` _extends_ `CustomToolInputParameter`
68
69
#### Parameters
70
@@ -94,14 +94,14 @@ await composio.tools.createCustomTool({
94
inputParameters: z.object({
95
param1: z.string().describe('First parameter'),
96
}),
97
- execute: async (input, authCredentials, executeToolRequest) => {
97
+ execute: async (input, connectionConfig, executeToolRequest) => {
98
// Custom logic here
99
return { data: { result: 'Success!' } };
100
- }
100
+ },
101
});
102
```
103
104
-```typescript
104
+````typescript
105
// creating a custom tool without a toolkit
106
await composio.tools.createCustomTool({
107
name: 'My Custom Tool',
@@ -188,9 +188,9 @@ const result = await composio.tools.execute('GITHUB_GET_ISSUES', {
188
return result;
189
}
190
});
191
-```
191
+````
192
193
-***
193
+---
194
195
### get()
196
@@ -222,7 +222,7 @@ This method fetches the tools from the Composio API and wraps them using the pro
222
223
###### T
224
225
-`T` *extends* [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>
225
+`T` _extends_ [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>
226
227
##### Parameters
228
@@ -268,13 +268,13 @@ Optional provider options
268
// Get tools from the GitHub toolkit
269
const tools = await composio.tools.get('default', {
270
toolkits: ['github'],
271
- limit: 10
271
+ limit: 10,
272
});
273
274
// Get tools with search
275
const tools = await composio.tools.get('default', {
276
search: 'user',
277
- important: true
277
+ important: true,
278
});
279
```
280
@@ -291,7 +291,7 @@ This method fetches the tool from the Composio API and wraps it using the provid
291
292
###### T
293
294
-`T` *extends* [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>
294
+`T` _extends_ [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>
295
296
##### Parameters
297
@@ -341,12 +341,12 @@ const hackerNewsUserTool = await composio.tools.get('default', 'HACKERNEWS_GET_U
341
const tool = await composio.tools.get('default', 'GITHUB_GET_REPOS', {
342
modifySchema: (toolSlug, toolkitSlug, schema) => {
343
// Customize the tool schema
344
- return {...schema, description: 'Custom description'};
345
- }
344
+ return { ...schema, description: 'Custom description' };
345
+ },
346
});
347
```
348
349
-***
349
+---
350
351
### getInput()
352
@@ -383,12 +383,12 @@ The input parameters schema for the specified tool
383
```typescript
384
// Get input parameters for a specific tool
385
const inputParams = await composio.tools.getInput('GITHUB_CREATE_ISSUE', {
386
- userId: 'default'
386
+ userId: 'default',
387
});
388
console.log(inputParams.schema);
389
```
390
391
-***
391
+---
392
393
### getRawComposioToolBySlug()
394
@@ -427,7 +427,7 @@ The tool
427
const tool = await composio.tools.getRawComposioToolBySlug('default', 'github');
428
```
429
430
-***
430
+---
431
432
### getRawComposioTools()
433
@@ -475,19 +475,21 @@ const tools = await composio.tools.getRawComposioTools('default');
475
// Get tools with filters
476
const githubTools = await composio.tools.getRawComposioTools('default', {
477
toolkits: ['github'],
478
- important: true
478
+ important: true,
479
});
480
481
// Get tools with schema transformation
482
-const tools = await composio.tools.getRawComposioTools('default', {},
482
+const tools = await composio.tools.getRawComposioTools(
483
+ 'default',
484
+ {},
485
(toolSlug, toolkitSlug, tool) => {
486
// Add custom properties to tool schema
485
- return {...tool, customProperty: 'value'};
487
+ return { ...tool, customProperty: 'value' };
488
}
489
);
490
```
491
490
-***
492
+---
493
494
### getToolsEnum()
495
@@ -514,7 +516,7 @@ const toolsEnum = await composio.tools.getToolsEnum();
516
console.log(toolsEnum.items);
517
```
518
517
-***
519
+---
520
521
### proxyExecute()
522
@@ -548,8 +550,8 @@ const response = await composio.tools.proxyExecute({
550
userId: 'default',
551
data: {
552
endpoint: '/repos/owner/repo/issues',
551
- method: 'GET'
552
- }
553
+ method: 'GET',
554
+ },
555
});
556
console.log(response.data);
557
```
fern/pages/tool-calling/custom-tools.mdx
+21
-15
@@ -1,7 +1,7 @@
1
---
2
title: Creating custom tools
3
-image: "https://og.composio.dev/api/og?title=Creating%20custom%20tools" # image for socials
4
-keywords: ""
3
+image: 'https://og.composio.dev/api/og?title=Creating%20custom%20tools' # image for socials
4
+keywords: ''
5
subtitle: "Learn how to extend Composio's toolkits with your own tools"
6
hide-nav-links: false
7
---
@@ -38,7 +38,7 @@ const tool = await composio.tools.createCustomTool({
38
```
39
```python Python maxLines=60 wordWrap
40
41
-```
41
+````
42
</CodeGroup>
43
44
### Toolkit-based Tool
@@ -59,7 +59,7 @@ const tool = await composio.tools.createCustomTool({
59
page: z.number().optional().describe('Pagination page number'),
60
customHeader: z.string().optional().describe('Custom header'),
61
}),
62
- execute: async (input, authCredentials, executeToolRequest) => {
62
+ execute: async (input, connectionConfig, executeToolRequest) => {
63
// This method makes authenticated requests to relevant API
64
// You can use relative paths!
65
// Composio will automatically inject the baseURL
@@ -86,12 +86,15 @@ const tool = await composio.tools.createCustomTool({
86
return result;
87
},
88
});
89
-```
89
+````
90
+
91
```python Python maxLines=60 wordWrap
92
+
93
```
94
+
95
</CodeGroup>
96
94
-2. Using `authCredentials` - For making direct API calls when needed:
97
+2. Using `connectionConfig` - For making direct API calls when needed:
98
99
<CodeGroup>
100
```typescript TypeScript maxLines=60 wordWrap
@@ -103,11 +106,11 @@ const tool = await composio.tools.createCustomTool({
106
inputParams: z.object({
107
repo: z.string().describe('Repository name'),
108
}),
106
- execute: async (input, authCredentials, executeToolRequest) => {
107
- // Use authCredentials for direct API calls
109
+ execute: async (input, connectionConfig, executeToolRequest) => {
110
+ // Use connectionConfig for direct API calls
111
const result = await fetch(`https://api.github.com/repos/${input.repo}`, {
112
headers: {
110
- Authorization: `Bearer ${authCredentials.access_token}`,
113
+ Authorization: `Bearer ${connectionConfig.access_token}`,
114
},
115
});
116
@@ -116,11 +119,14 @@ const tool = await composio.tools.createCustomTool({
119
error: null,
120
successful: true,
121
};
119
- },
122
+
123
+},
124
});
121
-```
125
+
126
+````
127
```python Python maxLines=60 wordWrap
123
-```
128
+````
129
+
130
</CodeGroup>
131
132
### Using Custom Headers and Query Parameters
@@ -139,7 +145,7 @@ const tool = await composio.tools.createCustomTool({
145
perPage: z.number().optional().describe('Results per page'),
146
acceptType: z.string().optional().describe('Custom accept header'),
147
}),
142
- execute: async (input, authCredentials, executeToolRequest) => {
148
+ execute: async (input, connectionConfig, executeToolRequest) => {
149
const result = await executeToolRequest({
150
endpoint: '/search/repositories',
151
method: 'GET',
@@ -211,7 +217,7 @@ const result = await composio.tools.execute('TOOL_SLUG', {
217
```
218
- Remember that `executeToolRequest` can only call tools from the same toolkit
219
- Use `executeToolRequest` to leverage Composio's automatic credential handling
214
- - Only use `authCredentials` when you need to make direct API calls or interact with different services
220
+ - Only use `connectionConfig` when you need to make direct API calls or interact with different services
221
5. Chain multiple toolkit operations using `executeToolRequest` for better maintainability
222
223
## Limitations
@@ -220,4 +226,4 @@ const result = await composio.tools.execute('TOOL_SLUG', {
226
2. They need to be recreated when the application restarts
227
3. Toolkit-based tools require a valid connected account with the specified toolkit
228
4. `executeToolRequest` can only execute tools from the same toolkit that the custom tool belongs to
223
-5. Each toolkit-based tool can only use one connected account at a time
\ No newline at end of file
229
+5. Each toolkit-based tool can only use one connected account at a time
packages/core/src/models/CustomTools.ts
+4
-4
@@ -63,7 +63,7 @@ export class CustomTools {
63
* query: z.string().describe('The search query'),
64
* limit: z.number().optional().describe('Maximum number of results')
65
* }),
66
- * execute: async (input, authCredentials, executeToolRequest) => {
66
+ * execute: async (input, connectionConfig, executeToolRequest) => {
67
* // Custom implementation logic
68
* return {
69
* data: { results: ['result1', 'result2'] }
@@ -239,7 +239,7 @@ export class CustomTools {
239
throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
240
}
241
242
- let authCredentials: ConnectionData | null = null;
242
+ let connectionConfig: ConnectionData | null = null;
243
const { toolkitSlug, execute, inputParams } = tool.options;
244
// if a toolkit is used, get the connected account, and auth credentials
245
let connectedAccountId: string | undefined = body.connectedAccountId;
@@ -265,7 +265,7 @@ export class CustomTools {
265
}
266
);
267
}
268
- authCredentials = connectedAccount.state ?? null;
268
+ connectionConfig = connectedAccount.state ?? null;
269
connectedAccountId = connectedAccount.id;
270
}
271
@@ -322,6 +322,6 @@ export class CustomTools {
322
});
323
}
324
325
- return execute(parsedInput.data, authCredentials, executeToolRequest);
325
+ return execute(parsedInput.data, connectionConfig, executeToolRequest);
326
}
327
}
packages/core/src/models/Tools.ts
+1
-1
@@ -771,7 +771,7 @@ export class Tools<
771
* inputParameters: z.object({
772
* param1: z.string().describe('First parameter'),
773
* }),
774
- * execute: async (input, authCredentials, executeToolRequest) => {
774
+ * execute: async (input, connectionConfig, executeToolRequest) => {
775
* // Custom logic here
776
* return { data: { result: 'Success!' } };
777
* }
packages/core/src/types/customTool.types.ts
+1
-1
@@ -13,7 +13,7 @@ type BaseCustomToolOptions<T extends z.ZodType> = {
13
type ToolkitBasedExecute<T extends z.ZodType> = {
14
execute: (
15
input: z.infer<T>,
16
- authCredentials: ConnectionData | null,
16
+ connectionConfig: ConnectionData | null,
17
executeToolRequest: (data: ToolProxyParams) => Promise<ToolExecuteResponse>
18
) => Promise<ToolExecuteResponse>;
19
toolkitSlug: string;
ts/docs/api/custom-tools.md
+8
-8
@@ -47,7 +47,7 @@ const tool = await composio.tools.createCustomTool({
47
page: z.number().optional().describe('Page number for pagination'),
48
customHeader: z.string().optional().describe('Custom header value'),
49
}),
50
- execute: async (input, authCredentials, executeToolRequest) => {
50
+ execute: async (input, connectionConfig, executeToolRequest) => {
51
// executeToolRequest makes authenticated requests to the toolkit's API
52
// You can use relative paths - Composio will automatically inject the baseURL
53
const result = await executeToolRequest({
@@ -75,7 +75,7 @@ const tool = await composio.tools.createCustomTool({
75
});
76
```
77
78
-2. Using `authCredentials` - For making direct API calls when needed:
78
+2. Using `connectionConfig` - For making direct API calls when needed:
79
80
```typescript
81
const tool = await composio.tools.createCustomTool({
@@ -86,11 +86,11 @@ const tool = await composio.tools.createCustomTool({
86
inputParams: z.object({
87
repo: z.string().describe('Repository name'),
88
}),
89
- execute: async (input, authCredentials, executeToolRequest) => {
90
- // Use authCredentials for direct API calls
89
+ execute: async (input, connectionConfig, executeToolRequest) => {
90
+ // Use connectionConfig for direct API calls
91
const result = await fetch(`https://api.github.com/repos/${input.repo}`, {
92
headers: {
93
- Authorization: `Bearer ${authCredentials.val?.access_token}`,
93
+ Authorization: `Bearer ${connectionConfig.val?.access_token}`,
94
},
95
});
96
@@ -118,7 +118,7 @@ const tool = await composio.tools.createCustomTool({
118
perPage: z.number().optional().describe('Results per page'),
119
acceptType: z.string().optional().describe('Custom accept header'),
120
}),
121
- execute: async (input, authCredentials, executeToolRequest) => {
121
+ execute: async (input, connectionConfig, executeToolRequest) => {
122
const result = await executeToolRequest({
123
endpoint: '/search/repositories',
124
method: 'GET',
@@ -173,7 +173,7 @@ The custom tools implementation provides full type safety:
173
1. Input parameters are validated using Zod schemas
174
2. The execute function's parameters are inferred based on whether toolkitSlug is provided:
175
- Without toolkitSlug: `(input) => Promise<ToolExecuteResponse>`
176
- - With toolkitSlug: `(input, authCredentials, executeToolRequest) => Promise<ToolExecuteResponse>`
176
+ - With toolkitSlug: `(input, connectionConfig, executeToolRequest) => Promise<ToolExecuteResponse>`
177
178
## Best Practices
179
@@ -192,7 +192,7 @@ The custom tools implementation provides full type safety:
192
```
193
- Remember that `executeToolRequest` can only call tools from the same toolkit
194
- Use `executeToolRequest` to leverage Composio's automatic credential handling
195
- - Only use `authCredentials` when you need to make direct API calls or interact with different services
195
+ - Only use `connectionConfig` when you need to make direct API calls or interact with different services
196
5. Chain multiple toolkit operations using `executeToolRequest` for better maintainability
197
198
## Limitations