CustomTools

@composio/core


@composio/core / CustomTools / CustomTools

Class: CustomTools

Defined in: ts/packages/core/src/models/CustomTools.ts:36

Constructors

Constructor

new CustomTools(client): CustomTools

Defined in: ts/packages/core/src/models/CustomTools.ts:40

Parameters

client

Composio

Returns

CustomTools

Methods

createTool()

createTool<T>(toolOptions): Promise<{ }>

Defined in: ts/packages/core/src/models/CustomTools.ts:75

Create a custom tool and registers it in the registry. This is just an in memory registry and is not persisted.

Type Parameters

T

T extends CustomToolInputParameter

Parameters

toolOptions

CustomToolOptions<T>

CustomToolOptions

Returns

Promise<{ }>

The tool created

Example

1// Create a custom tool with input parameters
2const customTool = await composio.customTools.createTool({
3 name: 'My Custom Tool',
4 description: 'A tool that performs a custom operation',
5 slug: 'MY_CUSTOM_TOOL',
6 inputParams: z.object({
7 query: z.string().describe('The search query'),
8 limit: z.number().optional().describe('Maximum number of results')
9 }),
10 execute: async (input, connectionConfig, executeToolRequest) => {
11 // Custom implementation logic
12 return {
13 data: { results: ['result1', 'result2'] }
14 };
15 }
16});

executeCustomTool()

executeCustomTool(slug, body): Promise<{ }>

Defined in: ts/packages/core/src/models/CustomTools.ts:236

Execute a custom tool

Parameters

slug

string

The slug of the tool to execute

body

Returns

Promise<{ }>

The response from the tool

Description

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()

getCustomToolBySlug(slug): Promise<{ }>

Defined in: ts/packages/core/src/models/CustomTools.ts:168

Get a custom tool by slug from the registry.

Parameters

slug

string

The slug of the tool to get

Returns

Promise<{ }>

The tool

Example

1// Get a specific custom tool by its slug
2const myTool = await composio.customTools.getCustomToolBySlug('MY_CUSTOM_TOOL');
3if (myTool) {
4 console.log(`Found tool: ${myTool.name}`);
5} else {
6 console.log('Tool not found');
7}

getCustomTools()

getCustomTools(__namedParameters): Promise<ToolList>

Defined in: ts/packages/core/src/models/CustomTools.ts:133

Get all the custom tools from the registry.

Parameters

__namedParameters
toolSlugs?

string[]

Returns

Promise<ToolList>

The list of tools

Example

1// Get all custom tools
2const allTools = await composio.customTools.getCustomTools({});
3
4// Get specific custom tools by slug
5const specificTools = await composio.customTools.getCustomTools({
6 toolSlugs: ['MY_CUSTOM_TOOL', 'ANOTHER_CUSTOM_TOOL']
7});