Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
Rename auth credentials to connection config
haxzie81fddf9f0e5d
diff --git a/examples/custom-tools/README.md b/examples/custom-tools/README.mdindex 92e26467b..9a86c3d97 100644--- a/examples/custom-tools/README.md+++ b/examples/custom-tools/README.md@@ -42,7 +42,7 @@ const tool = await composio.tools.createCustomTool({inputParams: z.object({owner: z.string().describe('Repository owner'),}),- execute: async (input, authCredentials, executeToolRequest) => {+ execute: async (input, connectionConfig, executeToolRequest) => {// executeToolRequest can only call tools from the 'github' toolkit// Uses the same connected account credentials automaticallyconst listResult = await executeToolRequest({@@ -78,14 +78,14 @@ const tool = await composio.tools.createCustomTool({inputParams: z.object({repository: z.string().describe('The repository to star'),}),- execute: async (input, authCredentials) => {- // Use authCredentials for direct API calls or when interacting with different services+ execute: async (input, connectionConfig) => {+ // Use connectionConfig for direct API calls or when interacting with different servicesconst result = await fetch(`https://api.github.com/user/starred/composiohq/${input.repository}`,{method: 'PUT',headers: {- Authorization: `Bearer ${authCredentials.val?.access_token}`,+ Authorization: `Bearer ${connectionConfig.val?.access_token}`,},});@@ -127,7 +127,7 @@ const tool = await composio.tools.createCustomTool({1. **Standalone vs Toolkit-based Tools**- Standalone tools only receive input parameters- - Toolkit-based tools have access to both `executeToolRequest` and `authCredentials`+ - Toolkit-based tools have access to both `executeToolRequest` and `connectionConfig`2. **Authentication Methods**@@ -136,7 +136,7 @@ const tool = await composio.tools.createCustomTool({- Uses the connected account credentials automatically- No need to manage auth tokens- Better maintainability and security- - `authCredentials`: For direct API calls+ - `connectionConfig`: For direct API calls- Use when you need to make direct API calls- Use when you need to interact with different services- Requires manual token managementdiff --git a/examples/custom-tools/src/auth-credentials.ts b/examples/custom-tools/src/auth-credentials.tsindex a4279d42e..2c26f2e11 100644--- a/examples/custom-tools/src/auth-credentials.ts+++ b/examples/custom-tools/src/auth-credentials.ts@@ -32,9 +32,9 @@ const tool = await composio.tools.createCustomTool({inputParams: z.object({repository: z.string().describe('The repository to star'),}),- execute: async (input, authCredentials) => {+ execute: async (input, connectionConfig) => {console.log('π ~ execute: ~ params:', input);- console.log('π ~ execute: ~ authCredentials:', authCredentials);+ console.log('π ~ execute: ~ connectionConfig:', connectionConfig);/*** The auth credentials are the auth credentials for the connected account.* You can use them to make requests to the API.@@ -44,7 +44,7 @@ const tool = await composio.tools.createCustomTool({{method: 'PUT',headers: {- Authorization: `Bearer ${authCredentials?.access_token}`,+ Authorization: `Bearer ${connectionConfig?.access_token}`,},});diff --git a/examples/custom-tools/src/index.ts b/examples/custom-tools/src/index.tsindex 07a816458..d6a7f5517 100644--- a/examples/custom-tools/src/index.ts+++ b/examples/custom-tools/src/index.ts@@ -32,9 +32,9 @@ const tool = await composio.tools.createCustomTool({inputParams: z.object({repository: z.string().describe('The repository to star'),}),- execute: async (input, authCredentials, executeToolRequest) => {+ execute: async (input, connectionConfig, executeToolRequest) => {console.log('π ~ execute: ~ params:', input);- console.log('π ~ execute: ~ authCredentials:', authCredentials);+ console.log('π ~ execute: ~ connectionConfig:', connectionConfig);const result = await executeToolRequest({endpoint: `/user/starred/composiohq/${input.repository}`,diff --git a/fern/pages/sdk/typescript/CustomTools/classes/CustomTools.mdx b/fern/pages/sdk/typescript/CustomTools/classes/CustomTools.mdxindex 0561fe4c9..4f4796f9b 100644--- a/fern/pages/sdk/typescript/CustomTools/classes/CustomTools.mdx+++ b/fern/pages/sdk/typescript/CustomTools/classes/CustomTools.mdx@@ -1,6 +1,6 @@[**@composio/core**](../../README.mdx)-***+---[@composio/core](../../README.mdx) / [CustomTools](../README.mdx) / CustomTools@@ -41,7 +41,7 @@ This is just an in memory registry and is not persisted.##### T-`T` *extends* `CustomToolInputParameter`+`T` _extends_ `CustomToolInputParameter`#### Parameters@@ -67,18 +67,18 @@ const customTool = await composio.customTools.createTool({slug: 'MY_CUSTOM_TOOL',inputParams: z.object({query: z.string().describe('The search query'),- limit: z.number().optional().describe('Maximum number of results')+ limit: z.number().optional().describe('Maximum number of results'),}),- execute: async (input, authCredentials, executeToolRequest) => {+ execute: async (input, connectionConfig, executeToolRequest) => {// Custom implementation logicreturn {- data: { results: ['result1', 'result2'] }+ data: { results: ['result1', 'result2'] },};- }+ },});```-***+---### executeCustomTool()@@ -110,7 +110,7 @@ If a toolkit is used, the connected account id is used to execute the tool.If a connected account id is provided, it is used to execute the tool.If a connected account id is not provided, the first connected account for the toolkit is used.-***+---### getCustomToolBySlug()@@ -146,7 +146,7 @@ if (myTool) {}```-***+---### getCustomTools()@@ -178,6 +178,6 @@ const allTools = await composio.customTools.getCustomTools({});// Get specific custom tools by slugconst specificTools = await composio.customTools.getCustomTools({- toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL']+ toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL'],});```diff --git a/fern/pages/sdk/typescript/models/Tools/classes/Tools.mdx b/fern/pages/sdk/typescript/models/Tools/classes/Tools.mdxindex a1b2d5c4a..a51c2f122 100644--- a/fern/pages/sdk/typescript/models/Tools/classes/Tools.mdx+++ b/fern/pages/sdk/typescript/models/Tools/classes/Tools.mdx@@ -1,6 +1,6 @@[**@composio/core**](../../../README.mdx)-***+---[@composio/core](../../../README.mdx) / [models/Tools](../README.mdx) / Tools@@ -23,7 +23,7 @@ It provides methods to list, get, and execute tools.### TProvider-`TProvider` *extends* [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>+`TProvider` _extends_ [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>## Constructors@@ -64,7 +64,7 @@ while keeping a consistent interface for both built-in and custom tools.##### T-`T` *extends* `CustomToolInputParameter`+`T` _extends_ `CustomToolInputParameter`#### Parameters@@ -94,14 +94,14 @@ await composio.tools.createCustomTool({inputParameters: z.object({param1: z.string().describe('First parameter'),}),- execute: async (input, authCredentials, executeToolRequest) => {+ execute: async (input, connectionConfig, executeToolRequest) => {// Custom logic herereturn { data: { result: 'Success!' } };- }+ },});```-```typescript+````typescript// creating a custom tool without a toolkitawait composio.tools.createCustomTool({name: 'My Custom Tool',@@ -188,9 +188,9 @@ const result = await composio.tools.execute('GITHUB_GET_ISSUES', {return result;}});-```+````-***+---### get()@@ -222,7 +222,7 @@ This method fetches the tools from the Composio API and wraps them using the pro###### T-`T` *extends* [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>+`T` _extends_ [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>##### Parameters@@ -268,13 +268,13 @@ Optional provider options// Get tools from the GitHub toolkitconst tools = await composio.tools.get('default', {toolkits: ['github'],- limit: 10+ limit: 10,});// Get tools with searchconst tools = await composio.tools.get('default', {search: 'user',- important: true+ important: true,});```@@ -291,7 +291,7 @@ This method fetches the tool from the Composio API and wraps it using the provid###### T-`T` *extends* [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>+`T` _extends_ [`BaseComposioProvider`](../../../provider/BaseProvider/type-aliases/BaseComposioProvider.mdx)\<`TToolCollection`, `TTool`\>##### Parameters@@ -341,12 +341,12 @@ const hackerNewsUserTool = await composio.tools.get('default', 'HACKERNEWS_GET_Uconst tool = await composio.tools.get('default', 'GITHUB_GET_REPOS', {modifySchema: (toolSlug, toolkitSlug, schema) => {// Customize the tool schema- return {...schema, description: 'Custom description'};- }+ return { ...schema, description: 'Custom description' };+ },});```-***+---### getInput()@@ -383,12 +383,12 @@ The input parameters schema for the specified tool```typescript// Get input parameters for a specific toolconst inputParams = await composio.tools.getInput('GITHUB_CREATE_ISSUE', {- userId: 'default'+ userId: 'default',});console.log(inputParams.schema);```-***+---### getRawComposioToolBySlug()@@ -427,7 +427,7 @@ The toolconst tool = await composio.tools.getRawComposioToolBySlug('default', 'github');```-***+---### getRawComposioTools()@@ -475,19 +475,21 @@ const tools = await composio.tools.getRawComposioTools('default');// Get tools with filtersconst githubTools = await composio.tools.getRawComposioTools('default', {toolkits: ['github'],- important: true+ important: true,});// Get tools with schema transformation-const tools = await composio.tools.getRawComposioTools('default', {},+const tools = await composio.tools.getRawComposioTools(+ 'default',+ {},(toolSlug, toolkitSlug, tool) => {// Add custom properties to tool schema- return {...tool, customProperty: 'value'};+ return { ...tool, customProperty: 'value' };});```-***+---### getToolsEnum()@@ -514,7 +516,7 @@ const toolsEnum = await composio.tools.getToolsEnum();console.log(toolsEnum.items);```-***+---### proxyExecute()@@ -548,8 +550,8 @@ const response = await composio.tools.proxyExecute({userId: 'default',data: {endpoint: '/repos/owner/repo/issues',- method: 'GET'- }+ method: 'GET',+ },});console.log(response.data);```diff --git a/fern/pages/tool-calling/custom-tools.mdx b/fern/pages/tool-calling/custom-tools.mdxindex 7317bbe06..95bfa61ce 100644--- a/fern/pages/tool-calling/custom-tools.mdx+++ b/fern/pages/tool-calling/custom-tools.mdx@@ -1,7 +1,7 @@---title: Creating custom tools-image: "https://og.composio.dev/api/og?title=Creating%20custom%20tools" # image for socials-keywords: ""+image: 'https://og.composio.dev/api/og?title=Creating%20custom%20tools' # image for socials+keywords: ''subtitle: "Learn how to extend Composio's toolkits with your own tools"hide-nav-links: false---@@ -38,7 +38,7 @@ const tool = await composio.tools.createCustomTool({``````python Python maxLines=60 wordWrap-```+````</CodeGroup>### Toolkit-based Tool@@ -59,7 +59,7 @@ const tool = await composio.tools.createCustomTool({page: z.number().optional().describe('Pagination page number'),customHeader: z.string().optional().describe('Custom header'),}),- execute: async (input, authCredentials, executeToolRequest) => {+ execute: async (input, connectionConfig, executeToolRequest) => {// This method makes authenticated requests to relevant API// You can use relative paths!// Composio will automatically inject the baseURL@@ -86,12 +86,15 @@ const tool = await composio.tools.createCustomTool({return result;},});-```+````+```python Python maxLines=60 wordWrap+```+</CodeGroup>-2. Using `authCredentials` - For making direct API calls when needed:+2. Using `connectionConfig` - For making direct API calls when needed:<CodeGroup>```typescript TypeScript maxLines=60 wordWrap@@ -103,11 +106,11 @@ const tool = await composio.tools.createCustomTool({inputParams: z.object({repo: z.string().describe('Repository name'),}),- execute: async (input, authCredentials, executeToolRequest) => {- // Use authCredentials for direct API calls+ execute: async (input, connectionConfig, executeToolRequest) => {+ // Use connectionConfig for direct API callsconst result = await fetch(`https://api.github.com/repos/${input.repo}`, {headers: {- Authorization: `Bearer ${authCredentials.access_token}`,+ Authorization: `Bearer ${connectionConfig.access_token}`,},});@@ -116,11 +119,14 @@ const tool = await composio.tools.createCustomTool({error: null,successful: true,};- },++},});-```++```````python Python maxLines=60 wordWrap-```+````+</CodeGroup>### Using Custom Headers and Query Parameters@@ -139,7 +145,7 @@ const tool = await composio.tools.createCustomTool({perPage: z.number().optional().describe('Results per page'),acceptType: z.string().optional().describe('Custom accept header'),}),- execute: async (input, authCredentials, executeToolRequest) => {+ execute: async (input, connectionConfig, executeToolRequest) => {const result = await executeToolRequest({endpoint: '/search/repositories',method: 'GET',@@ -211,7 +217,7 @@ const result = await composio.tools.execute('TOOL_SLUG', {```- Remember that `executeToolRequest` can only call tools from the same toolkit- Use `executeToolRequest` to leverage Composio's automatic credential handling- - Only use `authCredentials` when you need to make direct API calls or interact with different services+ - Only use `connectionConfig` when you need to make direct API calls or interact with different services5. Chain multiple toolkit operations using `executeToolRequest` for better maintainability## Limitations@@ -220,4 +226,4 @@ const result = await composio.tools.execute('TOOL_SLUG', {2. They need to be recreated when the application restarts3. Toolkit-based tools require a valid connected account with the specified toolkit4. `executeToolRequest` can only execute tools from the same toolkit that the custom tool belongs to-5. Each toolkit-based tool can only use one connected account at a time\ No newline at end of file+5. Each toolkit-based tool can only use one connected account at a timediff --git a/packages/core/src/models/CustomTools.ts b/packages/core/src/models/CustomTools.tsindex d5aa1c3ca..9bf53794b 100644--- a/packages/core/src/models/CustomTools.ts+++ b/packages/core/src/models/CustomTools.ts@@ -63,7 +63,7 @@ export class CustomTools {* query: z.string().describe('The search query'),* limit: z.number().optional().describe('Maximum number of results')* }),- * execute: async (input, authCredentials, executeToolRequest) => {+ * execute: async (input, connectionConfig, executeToolRequest) => {* // Custom implementation logic* return {* data: { results: ['result1', 'result2'] }@@ -239,7 +239,7 @@ export class CustomTools {throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);}- let authCredentials: ConnectionData | null = null;+ let connectionConfig: ConnectionData | null = null;const { toolkitSlug, execute, inputParams } = tool.options;// if a toolkit is used, get the connected account, and auth credentialslet connectedAccountId: string | undefined = body.connectedAccountId;@@ -265,7 +265,7 @@ export class CustomTools {});}- authCredentials = connectedAccount.state ?? null;+ connectionConfig = connectedAccount.state ?? null;connectedAccountId = connectedAccount.id;}@@ -322,6 +322,6 @@ export class CustomTools {});}- return execute(parsedInput.data, authCredentials, executeToolRequest);+ return execute(parsedInput.data, connectionConfig, executeToolRequest);}}diff --git a/packages/core/src/models/Tools.ts b/packages/core/src/models/Tools.tsindex 48b4047a2..26d460c92 100644--- a/packages/core/src/models/Tools.ts+++ b/packages/core/src/models/Tools.ts@@ -771,7 +771,7 @@ export class Tools<* inputParameters: z.object({* param1: z.string().describe('First parameter'),* }),- * execute: async (input, authCredentials, executeToolRequest) => {+ * execute: async (input, connectionConfig, executeToolRequest) => {* // Custom logic here* return { data: { result: 'Success!' } };* }diff --git a/packages/core/src/types/customTool.types.ts b/packages/core/src/types/customTool.types.tsindex 92b847a9f..95d5bb2c5 100644--- a/packages/core/src/types/customTool.types.ts+++ b/packages/core/src/types/customTool.types.ts@@ -13,7 +13,7 @@ type BaseCustomToolOptions<T extends z.ZodType> = {type ToolkitBasedExecute<T extends z.ZodType> = {execute: (input: z.infer<T>,- authCredentials: ConnectionData | null,+ connectionConfig: ConnectionData | null,executeToolRequest: (data: ToolProxyParams) => Promise<ToolExecuteResponse>) => Promise<ToolExecuteResponse>;toolkitSlug: string;diff --git a/ts/docs/api/custom-tools.md b/ts/docs/api/custom-tools.mdindex 5ed1b1dd8..978380cc7 100644--- a/ts/docs/api/custom-tools.md+++ b/ts/docs/api/custom-tools.md@@ -47,7 +47,7 @@ const tool = await composio.tools.createCustomTool({page: z.number().optional().describe('Page number for pagination'),customHeader: z.string().optional().describe('Custom header value'),}),- execute: async (input, authCredentials, executeToolRequest) => {+ execute: async (input, connectionConfig, executeToolRequest) => {// executeToolRequest makes authenticated requests to the toolkit's API// You can use relative paths - Composio will automatically inject the baseURLconst result = await executeToolRequest({@@ -75,7 +75,7 @@ const tool = await composio.tools.createCustomTool({});```-2. Using `authCredentials` - For making direct API calls when needed:+2. Using `connectionConfig` - For making direct API calls when needed:```typescriptconst tool = await composio.tools.createCustomTool({@@ -86,11 +86,11 @@ const tool = await composio.tools.createCustomTool({inputParams: z.object({repo: z.string().describe('Repository name'),}),- execute: async (input, authCredentials, executeToolRequest) => {- // Use authCredentials for direct API calls+ execute: async (input, connectionConfig, executeToolRequest) => {+ // Use connectionConfig for direct API callsconst result = await fetch(`https://api.github.com/repos/${input.repo}`, {headers: {- Authorization: `Bearer ${authCredentials.val?.access_token}`,+ Authorization: `Bearer ${connectionConfig.val?.access_token}`,},});@@ -118,7 +118,7 @@ const tool = await composio.tools.createCustomTool({perPage: z.number().optional().describe('Results per page'),acceptType: z.string().optional().describe('Custom accept header'),}),- execute: async (input, authCredentials, executeToolRequest) => {+ execute: async (input, connectionConfig, executeToolRequest) => {const result = await executeToolRequest({endpoint: '/search/repositories',method: 'GET',@@ -173,7 +173,7 @@ The custom tools implementation provides full type safety:1. Input parameters are validated using Zod schemas2. The execute function's parameters are inferred based on whether toolkitSlug is provided:- Without toolkitSlug: `(input) => Promise<ToolExecuteResponse>`- - With toolkitSlug: `(input, authCredentials, executeToolRequest) => Promise<ToolExecuteResponse>`+ - With toolkitSlug: `(input, connectionConfig, executeToolRequest) => Promise<ToolExecuteResponse>`## Best Practices@@ -192,7 +192,7 @@ The custom tools implementation provides full type safety:```- Remember that `executeToolRequest` can only call tools from the same toolkit- Use `executeToolRequest` to leverage Composio's automatic credential handling- - Only use `authCredentials` when you need to make direct API calls or interact with different services+ - Only use `connectionConfig` when you need to make direct API calls or interact with different services5. Chain multiple toolkit operations using `executeToolRequest` for better maintainability## Limitations