Fetching and Filtering Tools

Learn how to fetch and filter Composio's tools and toolsets

To effectively use tools, it is recommended to fetch, inspect, and filter them based on your criteria.

This process returns a union of all tools that match the specified criteria, ensuring you provide the most relevant tools to the agents.

When fetching tools, they are automatically formatted to match the requirements of the provider you are using. This means you do not need to manually convert or adapt the tool format.

Filtering by toolkit

Toolkits are collections of tools that from a specific app!

Fetching tools from a toolkit is a good way to get a sense of the tools available.

Tools are ordered by importance

When you fetch tools from a toolkit, the most important tools are returned first.

Composio determines the importance of a tool based on the usage and relevance of the tool.

1const tools = await composio.tools.get(
2 userId,
3 {
4 toolkits: ["GITHUB", "LINEAR"],
5 }
6);

Limiting the results

Multiple toolkits have 100s of tools. These can easily overwhelm the LLM. Hence, the SDK allows you to limit the number of tools returned.

The default limit is 20 — meaning you get the top 20 important tools from the toolkit.

1const tools = await composio.tools.get(userId, {
2 toolkits: ["GITHUB"],
3 limit: 5, // Returns the top 5 important tools from the toolkit
4});

Filtering by tool

You may specify the list of tools to fetch by directly providing the tool names. Browse the list of tools here to view and inspect the tools for each toolkit.

1const tools = await composio.tools.get(userId, {
2 tools: [
3 "GITHUB_CREATE_AN_ISSUE",
4 "GITHUB_CREATE_AN_ISSUE_COMMENT",
5 "GITHUB_CREATE_A_COMMIT",
6 ],
7});

Fetching raw tools

To examine the raw schema definitition of a tool to understand the input/output parameters or to build custom logic around tool definitions, you can use the following methods. This can be useful for:

  • Understanding exact input parameters and output structures.
  • Building custom logic around tool definitions.
  • Debugging tool interactions.
  • Research and experimentation.
1import { Composio } from '@composio/core';
2
3const composio = new Composio();
4
5const tools_1 = await composio.tools.getRawComposioToolBySlug('user@acme.org', 'GITHUB_CREATE_AN_ISSUE');
6console.log(tools_1);
7
8const tools_2 = await composio.tools.getRawComposioTools('user@acme.org', {
9 toolkits: ['SLACK'],
10});
11console.log(tools_2);

Filtering by search (Experimental)

You may also filter tools by searching for them. This is a good way to find tools that are relevant to a given use case.

This step runs a semantic search on the tool names and descriptions and returns the most relevant tools.

1const tools = await composio.tools.get(userId, {
2 search: "hubspot organize contacts",
3});