Creating custom tools
Learn how to extend Composio's toolkits with your own tools
Custom tools allow you to create your own tools that can be used with Composio.
- Standalone tools - Simple tools that don’t require any authentication
- Toolkit-based tools - Tools that require authentication and can use toolkit credentials
Creating a Custom Tool
Standalone Tool
A standalone tool is the simplest form of custom tool. It only requires input parameters and an execute function:
Toolkit-based Tool
A toolkit-based tool has access to two ways of making authenticated requests:
- Using
executeToolRequest- The recommended way to make authenticated requests to the toolkit’s API endpoints. Composio automatically handles credential injection and baseURL resolution:
- Using
connectionConfig- For making direct API calls when needed:
Using Custom Headers and Query Parameters
You can add custom headers and query parameters to your toolkit-based tools using the parameters option in executeToolRequest:
Executing Custom Tools
You can execute custom tools just like any other tool:
Best Practices
- Use descriptive names and slugs for your tools
- Always provide descriptions for input parameters using
describe() - Handle errors gracefully in your execute function
- For toolkit-based tools:
- Prefer
executeToolRequestover direct API calls when possible - Use relative paths with
executeToolRequest- Composio will automatically inject the correct baseURL - Use the
parametersoption to add custom headers or query parameters: - Remember that
executeToolRequestcan only call tools from the same toolkit - Use
executeToolRequestto leverage Composio’s automatic credential handling - Only use
connectionConfigwhen you need to make direct API calls or interact with different services
- Prefer
- Chain multiple toolkit operations using
executeToolRequestfor better maintainability
Limitations
- Custom tools are stored in memory and are not persisted
- They need to be recreated when the application restarts
- Toolkit-based tools require a valid connected account with the specified toolkit
executeToolRequestcan only execute tools from the same toolkit that the custom tool belongs to- Each toolkit-based tool can only use one connected account at a time