ToolRouterSession
Usage
Access this class through the composio.toolRouterSession property:
const composio = new Composio({ apiKey: 'your-api-key' });
const result = await composio.toolRouterSession.list();Properties
| Name | Type |
|---|---|
experimental | SessionExperimental |
mcp | object |
sessionId | string |
Methods
authorize()
Initiate an authorization flow for a toolkit. Returns a ConnectionRequest with a redirect URL for the user.
async authorize(toolkit: string, options?: { callbackUrl?: string }): Promise<ConnectionRequest>Parameters
| Name | Type |
|---|---|
toolkit | string |
options? | object |
Returns
Promise<ConnectionRequest>
customToolkits()
List all custom toolkits registered in this session. Returns toolkits with their tools showing final slugs.
customToolkits(): RegisteredCustomToolkit[]Returns
RegisteredCustomToolkit[] — Array of registered custom toolkits
customTools()
List all custom tools registered in this session. Returns tools with their final slugs, schemas, and resolved toolkit.
customTools(options?: { toolkit?: string }): RegisteredCustomTool[]Parameters
| Name | Type |
|---|---|
options? | object |
Returns
RegisteredCustomTool[] — Array of registered custom tools
execute()
Execute a tool within the session.
For custom tools, accepts the original slug (e.g. "GREP") or the full slug (e.g. "LOCAL_GREP"). Custom tools are executed in-process; remote tools are sent to the Composio backend.
async execute(toolSlug: string, arguments_?: Record<string, unknown>): Promise<{ data: Record<string, unknown>; error: string | null; logId: string }>Parameters
| Name | Type | Description |
|---|---|---|
toolSlug | string | The tool slug to execute |
arguments_? | Record<string, unknown> | Optional tool arguments |
Returns
Promise<...> — The tool execution result
proxyExecute()
Proxy an API call through Composio's auth layer using the session's connected account. The backend resolves the connected account from the toolkit within the session.
async proxyExecute(params: object): Promise<ToolRouterSessionProxyExecuteResponse>Parameters
| Name | Type | Description |
|---|---|---|
params | object | Proxy request parameters (toolkit, endpoint, method, body, headers/query params) |
Returns
Promise<ToolRouterSessionProxyExecuteResponse> — The proxied API response with status, data, headers
search()
Search for tools by semantic use case. Returns relevant tools for the given query with schemas and guidance.
async search(params: { query: string; toolkits?: string[] }): Promise<...>Parameters
| Name | Type |
|---|---|
params | object |
Returns
Promise<...>
toolkits()
Query the connection state of toolkits in the session. Supports pagination and filtering by toolkit slugs.
async toolkits(options?: { isConnected?: boolean; limit?: number; nextCursor?: string; search?: string; toolkits?: string[] }): Promise<...>Parameters
| Name | Type |
|---|---|
options? | object |
Returns
Promise<...>
tools()
Get the tools available in the session, formatted for your AI framework. Requires a provider to be configured in the Composio constructor.
When custom tools are bound to the session, execution of COMPOSIO_MULTI_EXECUTE_TOOL is intercepted: local tools are executed in-process, remote tools are sent to the backend.
async tools(modifiers?: SessionMetaToolOptions): Promise<ReturnType>Parameters
| Name | Type |
|---|---|
modifiers? | SessionMetaToolOptions |
Returns
Promise<ReturnType>