Tools
Methods
get_raw_composio_tool_by_slug()
Returns schema for the given tool slug.
def get_raw_composio_tool_by_slug(slug: str) -> ToolParameters
| Name | Type |
|---|---|
slug | str |
Returns
Tool
Raises
ToolNotFoundError— when the backend reports the slug as unknown (404, or 400 for a malformed slug). Any other client error, such as an invalid API key, is re-raised unchanged.
get_raw_composio_tools()
Get a list of tool schemas based on the provided filters.
def get_raw_composio_tools(tools: list[str] | None = ..., search: str | None = ..., toolkits: list[str] | None = ..., scopes: List[str] | None = ..., limit: int | None = ...) -> list[Tool]Parameters
| Name | Type |
|---|---|
tools? | list[str] | None |
search? | str | None |
toolkits? | list[str] | None |
scopes? | List[str] | None |
limit? | int | None |
Returns
list[Tool]
get_raw_tool_router_meta_tools()
Fetches the tools exposed by a tool router session. This method fetches helper/meta tools and any preloaded app tools from the Composio API and transforms them to the expected format. It provides access to the underlying tool data without provider-specific wrapping.
def get_raw_tool_router_meta_tools(session_id: str, modifiers: 'Modifiers' | None = ...) -> list[Tool]Parameters
| Name | Type | Description |
|---|---|---|
session_id | str | The session ID to get the meta tools for |
modifiers? | 'Modifiers' | None | Optional modifiers to apply to the tool schemas |
Returns
list[Tool] — The list of meta tools
Example
from composio import Composio
composio = Composio()
tools_model = composio.tools
# Get meta tools for a session
meta_tools = tools_model.get_raw_tool_router_meta_tools("session_123")
print(meta_tools)
# Get meta tools with schema modifiers
from composio.core.models import schema_modifier
@schema_modifier
def modify_schema(tool: str, toolkit: str, schema):
# Customize the schema
schema.description = f"Modified: {schema.description}"
return schema
meta_tools = tools_model.get_raw_tool_router_meta_tools(
"session_123",
modifiers=[modify_schema]
)get()
Get a tool or list of tools based on the provided arguments. The return type is automatically inferred based on the provider's generic parameters. For example: - OpenAIProvider -> list[ChatCompletionToolParam] - AnthropicProvider -> list[ToolParam] - CustomProvider[MyTool, list[MyTool]] -> list[MyTool]
def get(user_id: str, *, slug: str | None = ..., tools: list[str] | None = ..., search: str | None = ..., toolkits: list[str] | None = ..., scopes: List[str] | None = ..., modifiers: Modifiers | None = ..., limit: int | None = ...) -> TToolCollectionParameters
| Name | Type | Description |
|---|---|---|
user_id | str | The user ID to get tools for. |
slug? | str | None | Get a single tool by slug. |
tools? | list[str] | None | Get tools by a list of tool slugs. |
search? | str | None | Search tools by search term. |
toolkits? | list[str] | None | Get tools from specific toolkits. |
scopes? | List[str] | None | Filter by scopes. |
modifiers? | Modifiers | None | Optional modifiers to apply. |
limit? | int | None | Limit the number of tools returned. |
Returns
TToolCollection — Provider-specific tool collection (TToolCollection).
execute()
Execute a tool with the provided parameters. This method calls the Composio API to execute the tool and returns the response.
def execute(slug: str, arguments: Dict, *, connected_account_id: str | None = ..., custom_auth_params: tool_execute_params.CustomAuthParams | None = ..., custom_connection_data: tool_execute_params.CustomConnectionData | None = ..., user_id: str | None = ..., text: str | None = ..., version: str | None = ..., dangerously_skip_version_check: bool | None = ..., modifiers: Modifiers | None = ...) -> ToolExecutionResponseParameters
| Name | Type | Description |
|---|---|---|
slug | str | The slug of the tool to execute. |
arguments | Dict | The arguments to pass to the tool. |
connected_account_id? | str | None | The connected account ID, or instant_account to explicitly use the Composio Instant account. |
custom_auth_params? | tool_execute_params.CustomAuthParams | None | The custom auth params to use for the tool. |
custom_connection_data? | tool_execute_params.CustomConnectionData | None | The custom connection data to use for the tool, takes priority over custom_auth_params. |
user_id? | str | None | The ID of the user to execute the tool for. |
text? | str | None | The text to pass to the tool. |
version? | str | None | The version of the tool to execute (overrides the SDK-level toolkit versions for this execution). |
dangerously_skip_version_check? | bool | None | Skip the version check for 'latest' version. This might cause unexpected behavior when new versions are released. |
modifiers? | Modifiers | None | The modifiers to apply to the tool (include @before_file_upload for file path hooks). |
Returns
ToolExecutionResponse — The response from the tool.
proxy()
Proxy a tool call to the Composio API. user_id is the user the connected account belongs to. Projects with 2FA enabled check it against the connected account and may require it.
def proxy(endpoint: str, method: Literal['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD'], body: object | None = ..., connected_account_id: str | None = ..., parameters: List[tool_proxy_params.Parameter] | None = ..., custom_connection_data: tool_proxy_params.CustomConnectionData | None = ..., user_id: str | None = ...) -> tool_proxy_response.ToolProxyResponseParameters
| Name | Type |
|---|---|
endpoint | str |
method | Literal['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD'] |
body? | object | None |
connected_account_id? | str | None |
parameters? | List[tool_proxy_params.Parameter] | None |
custom_connection_data? | tool_proxy_params.CustomConnectionData | None |
user_id? | str | None |
Returns
tool_proxy_response.ToolProxyResponse