Tools

@composio/core


@composio/core / models/Tools / Tools

Class: Tools<TToolCollection, TTool, TProvider>

Defined in: ts/packages/core/src/models/Tools.ts:57

This class is used to manage tools in the Composio SDK. It provides methods to list, get, and execute tools.

Type Parameters

TToolCollection

TToolCollection

TTool

TTool

TProvider

TProvider extends BaseComposioProvider<TToolCollection, TTool, unknown>

Constructors

Constructor

new Tools<TToolCollection, TTool, TProvider>(client, provider, config?): Tools<TToolCollection, TTool, TProvider>

Defined in: ts/packages/core/src/models/Tools.ts:68

Parameters

client

Composio

provider

TProvider

config?

ComposioConfig<TProvider>

Returns

Tools<TToolCollection, TTool, TProvider>

Methods

createCustomTool()

createCustomTool<T>(body): Promise<{ }>

Defined in: ts/packages/core/src/models/Tools.ts:916

Creates a custom tool that can be used within the Composio SDK.

Custom tools allow you to extend the functionality of Composio with your own implementations while keeping a consistent interface for both built-in and custom tools.

Type Parameters

T

T extends CustomToolInputParameter

Parameters

body

CustomToolOptions<T>

The configuration for the custom tool

Returns

Promise<{ }>

The created custom tool

Examples

1// creating a custom tool with a toolkit
2await composio.tools.createCustomTool({
3 name: 'My Custom Tool',
4 description: 'A custom tool that does something specific',
5 slug: 'MY_CUSTOM_TOOL',
6 userId: 'default',
7 connectedAccountId: '123',
8 toolkitSlug: 'github',
9 inputParameters: z.object({
10 param1: z.string().describe('First parameter'),
11 }),
12 execute: async (input, connectionConfig, executeToolRequest) => {
13 // Custom logic here
14 return { data: { result: 'Success!' } };
15 }
16});
1// creating a custom tool without a toolkit
2await composio.tools.createCustomTool({
3 name: 'My Custom Tool',
4 description: 'A custom tool that does something specific',
5 slug: 'MY_CUSTOM_TOOL',
6 inputParameters: z.object({
7 param1: z.string().describe('First parameter'),
8 }),
9 execute: async (input) => {
10 // Custom logic here
11 return { data: { result: 'Success!' } };
12 }
13});
14
15***
16
17### execute()
18
19> **execute**(`slug`, `body`, `modifiers?`): `Promise`\<\{ \}\>
20
21Defined in: ts/packages/core/src/models/Tools.ts:724
22
23Executes a given tool with the provided parameters.
24
25This method calls the Composio API or a custom tool handler to execute the tool and returns the response.
26It automatically determines whether to use a custom tool or a Composio API tool based on the slug.
27
28**Version Control:**
29By default, manual tool execution requires a specific toolkit version. If the version resolves to "latest",
30the execution will throw a `ComposioToolVersionRequiredError` unless `dangerouslySkipVersionCheck` is set to `true`.
31This helps prevent unexpected behavior when new toolkit versions are released.
32
33#### Parameters
34
35##### slug
36
37`string`
38
39The slug/ID of the tool to be executed
40
41##### body
42
43The parameters to be passed to the tool
44
45##### modifiers?
46
47`ExecuteToolModifiers`
48
49Optional modifiers to transform the request or response
50
51#### Returns
52
53`Promise`\<\{ \}\>
54
55- The response from the tool execution
56
57#### Throws
58
59If the CustomTools instance is not initialized
60
61#### Throws
62
63If the connected account is not found
64
65#### Throws
66
67If the tool with the given slug is not found
68
69#### Throws
70
71If version resolves to "latest" and dangerouslySkipVersionCheck is not true
72
73#### Throws
74
75If there is an error during tool execution
76
77#### Examples
78
79```typescript
80const result = await composio.tools.execute('GITHUB_GET_REPOS', {
81 userId: 'default',
82 version: '20250909_00',
83 arguments: { owner: 'composio' }
84});
1const result = await composio.tools.execute('HACKERNEWS_GET_USER', {
2 userId: 'default',
3 arguments: { userId: 'pg' },
4 dangerouslySkipVersionCheck: true // Allows execution with "latest" version
5});
1// If toolkitVersions are set during Composio initialization, no need to pass version
2const composio = new Composio({ toolkitVersions: { github: '20250909_00' } });
3const result = await composio.tools.execute('GITHUB_GET_REPOS', {
4 userId: 'default',
5 arguments: { owner: 'composio' }
6});
1const result = await composio.tools.execute('GITHUB_GET_ISSUES', {
2 userId: 'default',
3 version: '20250909_00',
4 arguments: { owner: 'composio', repo: 'sdk' }
5}, {
6 beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
7 console.log(`Executing ${toolSlug} from ${toolkitSlug}`);
8 return params;
9 },
10 afterExecute: ({ toolSlug, toolkitSlug, result }) => {
11 console.log(`Completed ${toolSlug}`);
12 return result;
13 }
14});

get()

Get a tool or list of tools based on the provided arguments. This is an implementation method that handles all overloads.

Param

The user id to get the tool(s) for

Param

Either a slug string or filters object

Param

Optional provider options or version string

Param

Optional provider options (when arg3 is version)

Call Signature

get<T>(userId, filters, options?): Promise<ReturnType<T["wrapTools"]>>

Defined in: ts/packages/core/src/models/Tools.ts:519

Get a list of tools from Composio based on filters. This method fetches the tools from the Composio API and wraps them using the provider.

Type Parameters
T

T extends BaseComposioProvider<TToolCollection, TTool, unknown>

Parameters
userId

string

The user id to get the tools for

filters

ToolListParams

The filters to apply when fetching tools

options?

ProviderOptions<TProvider>

Optional provider options including modifiers

Returns

Promise<ReturnType<T["wrapTools"]>>

The tool collection

Param

The user id to get the tool(s) for

Param

Either a slug string or filters object

Param

Optional provider options or version string

Param

Optional provider options (when arg3 is version)

Example
1// Get tools from the GitHub toolkit
2const tools = await composio.tools.get('default', {
3 toolkits: ['github'],
4 limit: 10
5});
6
7// Get tools with search
8const searchTools = await composio.tools.get('default', {
9 search: 'user',
10 limit: 10
11});
12
13// Get a specific tool by slug
14const hackerNewsUserTool = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
15
16// Get a tool with schema modifications
17const tool = await composio.tools.get('default', 'GITHUB_GET_REPOS', {
18 modifySchema: (toolSlug, toolkitSlug, schema) => {
19 // Customize the tool schema
20 return {...schema, description: 'Custom description'};
21 }
22});

Call Signature

get<T>(userId, slug, options?): Promise<ReturnType<T["wrapTools"]>>

Defined in: ts/packages/core/src/models/Tools.ts:548

Get a specific tool by its slug. This method fetches the tool from the Composio API and wraps it using the provider.

Type Parameters
T

T extends BaseComposioProvider<TToolCollection, TTool, unknown>

Parameters
userId

string

The user id to get the tool for

slug

string

The slug of the tool to fetch

options?

ProviderOptions<TProvider>

Optional provider options including modifiers

Returns

Promise<ReturnType<T["wrapTools"]>>

The tool collection

Param

The user id to get the tool(s) for

Param

Either a slug string or filters object

Param

Optional provider options or version string

Param

Optional provider options (when arg3 is version)

Example
1// Get a specific tool by slug
2const hackerNewsUserTool = await composio.tools.get('default', 'HACKERNEWS_GET_USER');
3
4// Get a tool with schema modifications
5const tool = await composio.tools.get('default', 'GITHUB_GET_REPOS', {
6 modifySchema: (toolSlug, toolkitSlug, schema) => {
7 // Customize the tool schema
8 return {...schema, description: 'Custom description'};
9 }
10});

getInput()

getInput(slug, body): Promise<ToolGetInputResponse>

Defined in: ts/packages/core/src/models/Tools.ts:811

Fetches the input parameters for a given tool.

This method is used to get the input parameters for a tool before executing it.

Parameters

slug

string

The ID of the tool to find input for

body

ToolGetInputParams

The parameters to be passed to the tool

Returns

Promise<ToolGetInputResponse>

The input parameters schema for the specified tool

Example

1// Get input parameters for a specific tool
2const inputParams = await composio.tools.getInput('GITHUB_CREATE_ISSUE', {
3 userId: 'default'
4});
5console.log(inputParams.schema);

getRawComposioToolBySlug()

getRawComposioToolBySlug(slug, options?): Promise<{ }>

Defined in: ts/packages/core/src/models/Tools.ts:445

Retrieves a specific tool by its slug from the Composio API.

This method fetches a single tool in raw format without provider-specific wrapping, providing direct access to the tool’s schema and metadata. Tool versions are controlled at the Composio SDK initialization level through the toolkitVersions configuration.

Parameters

slug

string

The unique identifier of the tool (e.g., ‘GITHUB_GET_REPOS’)

options?

SchemaModifierOptions

Optional configuration for tool retrieval

Returns

Promise<{ }>

The requested tool with its complete schema and metadata

Example

1// Get a tool by slug
2const tool = await composio.tools.getRawComposioToolBySlug('GITHUB_GET_REPOS');
3console.log(tool.name, tool.description);
4
5// Get a tool with schema transformation
6const customizedTool = await composio.tools.getRawComposioToolBySlug(
7 'SLACK_SEND_MESSAGE',
8 {
9 modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
10 return {
11 ...schema,
12 description: `Enhanced ${schema.description} with custom modifications`,
13 customMetadata: {
14 lastModified: new Date().toISOString(),
15 toolkit: toolkitSlug
16 }
17 };
18 }
19 }
20);
21
22// Get a custom tool (will check custom tools first)
23const customTool = await composio.tools.getRawComposioToolBySlug('MY_CUSTOM_TOOL');
24
25// Access tool properties
26const githubTool = await composio.tools.getRawComposioToolBySlug('GITHUB_CREATE_ISSUE');
27console.log({
28 slug: githubTool.slug,
29 name: githubTool.name,
30 toolkit: githubTool.toolkit?.name,
31 version: githubTool.version,
32 availableVersions: githubTool.availableVersions,
33 inputParameters: githubTool.inputParameters
34});

getRawComposioTools()

getRawComposioTools(query, options?): Promise<ToolList>

Defined in: ts/packages/core/src/models/Tools.ts:305

Lists all tools available in the Composio SDK including custom tools.

This method fetches tools from the Composio API in raw format and combines them with any registered custom tools. The response can be filtered and modified as needed. It provides access to the underlying tool data without provider-specific wrapping.

Parameters

query

ToolListParams

Query parameters to filter the tools (required)

options?

SchemaModifierOptions

Optional configuration for tool retrieval

Returns

Promise<ToolList>

List of tools matching the query criteria

Example

1// Get tools from specific toolkits
2const githubTools = await composio.tools.getRawComposioTools({
3 toolkits: ['github'],
4 limit: 10
5});
6
7// Get specific tools by slug
8const specificTools = await composio.tools.getRawComposioTools({
9 tools: ['GITHUB_GET_REPOS', 'HACKERNEWS_GET_USER']
10});
11
12// Get tools from specific toolkits
13const githubTools = await composio.tools.getRawComposioTools({
14 toolkits: ['github'],
15 limit: 10
16});
17
18// Get tools with schema transformation
19const customizedTools = await composio.tools.getRawComposioTools({
20 toolkits: ['github'],
21 limit: 5
22}, {
23 modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
24 // Add custom properties to tool schema
25 return {
26 ...schema,
27 customProperty: `Modified ${toolSlug} from ${toolkitSlug}`,
28 tags: [...(schema.tags || []), 'customized']
29 };
30 }
31});
32
33// Search for tools
34const searchResults = await composio.tools.getRawComposioTools({
35 search: 'user management'
36});
37
38// Get tools by authentication config
39const authSpecificTools = await composio.tools.getRawComposioTools({
40 authConfigIds: ['auth_config_123']
41});

getToolsEnum()

getToolsEnum(): Promise<ToolRetrieveEnumResponse>

Defined in: ts/packages/core/src/models/Tools.ts:789

Fetches the list of all available tools in the Composio SDK.

This method is mostly used by the CLI to get the list of tools. No filtering is done on the tools, the list is cached in the backend, no further optimization is required.

Returns

Promise<ToolRetrieveEnumResponse>

The complete list of all available tools with their metadata

Example

1// Get all available tools as an enum
2const toolsEnum = await composio.tools.getToolsEnum();
3console.log(toolsEnum.items);

proxyExecute()

proxyExecute(body): Promise<ToolProxyResponse>

Defined in: ts/packages/core/src/models/Tools.ts:838

Proxies a custom request to a toolkit/integration.

This method allows sending custom requests to a specific toolkit or integration when you need more flexibility than the standard tool execution methods provide.

Parameters

body

The parameters for the proxy request including toolkit slug and custom data

Returns

Promise<ToolProxyResponse>

The response from the proxied request

Example

1// Send a custom request to a toolkit
2const response = await composio.tools.proxyExecute({
3 toolkitSlug: 'github',
4 userId: 'default',
5 data: {
6 endpoint: '/repos/owner/repo/issues',
7 method: 'GET'
8 }
9});
10console.log(response.data);