@devries-cameron20 / composio Mirror · read-only / commits / a5f396ca1
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 17:00 UTC

keep old tool router stuff

Sushmithamallesh committed Dec 15, 2025 at 22:37 UTC a5f396ca149b2d95408cff12a40eea6e90cee415
3 files changed +323
fern/pages/src/tool-router/quick-start.mdx new
+240
@@ -0,0 +1,240 @@
1 +---
2 +title: Tool Router Quick Start
3 +image: "https://og.composio.dev/api/og?title=Tool%20Router%20Quick%20Start" # image for socials
4 +keywords: ''
5 +subtitle: 'Learn how to use tool router to route tool calls to the correct tool.'
6 +hide-nav-links: false
7 +---
8 +
9 +
10 +Tool Router automatically discovers, authenticates, and executes the right tools for any task. It's an experimental feature that handles the entire workflow—from finding relevant tools across 500+ integrations to managing authentication and parallel execution.
11 +
12 +This is what powers complex agentic products like [Rube](https://rube.app).
13 +
14 +## Quick start
15 +
16 +<Steps toc={true}>
17 + <Step title="Install SDKs">
18 + Install the Composio SDK and OpenAI Agents SDK:
19 +
20 + <CodeGroup>
21 +
22 + ```bash Python
23 + pip install composio_openai_agents openai-agents
24 + ```
25 +
26 + ```bash TypeScript
27 + pnpm install @composio/core @composio/openai-agents @openai/agents
28 + ```
29 +
30 + </CodeGroup>
31 +
32 + Get your Composio API key from [settings](https://platform.composio.dev/?next_page=/settings) and set it as an environment variable:
33 +
34 + ```bash
35 + export COMPOSIO_API_KEY="your-api-key"
36 + ```
37 + </Step>
38 +
39 + <Step title="Create Tool Router session">
40 + Initialize Composio and create a session for your user:
41 +
42 + <Tip icon="info">
43 + **Authentication is handled automatically**
44 +
45 + Tool Router provides auth URLs when needed. For production, consider [pre-configuring authentication](/docs/authenticating-tools).
46 + </Tip>
47 +
48 + <CodeGroup>
49 +
50 + <SnippetCode
51 + src="fern/snippets/tool-router/python/quickstart.py"
52 + startLine={1}
53 + endLine={16}
54 + title="Python"
55 + />
56 +
57 + <SnippetCode
58 + src="fern/snippets/tool-router/typescript/quickstart.ts"
59 + startLine={1}
60 + endLine={18}
61 + title="TypeScript"
62 + />
63 +
64 + </CodeGroup>
65 +
66 + This generates a secure MCP endpoint URL that your AI agent will use to access Tool Router.
67 +
68 + <Tip icon="info">
69 + **What are sessions?**
70 +
71 + Sessions are designed for security. Each presigned URL contains user authentication credentials and should never be stored long-term or exposed to the client. Generate a new URL for each conversation.
72 + </Tip>
73 + </Step>
74 +
75 + <Step title="Set up your agent">
76 + Configure an OpenAI agent with the Tool Router MCP endpoint:
77 +
78 + <CodeGroup>
79 +
80 + <SnippetCode
81 + src="fern/snippets/tool-router/python/quickstart.py"
82 + startLine={17}
83 + endLine={33}
84 + title="Python"
85 + />
86 +
87 + <SnippetCode
88 + src="fern/snippets/tool-router/typescript/quickstart.ts"
89 + startLine={20}
90 + endLine={30}
91 + title="TypeScript"
92 + />
93 +
94 + </CodeGroup>
95 + </Step>
96 +
97 + <Step title="Run your agent">
98 + Execute the agent with a task:
99 +
100 + <CodeGroup>
101 +
102 + <SnippetCode
103 + src="fern/snippets/tool-router/python/quickstart.py"
104 + startLine={34}
105 + endLine={42}
106 + title="Python"
107 + />
108 +
109 + <SnippetCode
110 + src="fern/snippets/tool-router/typescript/quickstart.ts"
111 + startLine={32}
112 + endLine={41}
113 + title="TypeScript"
114 + />
115 +
116 + </CodeGroup>
117 + </Step>
118 +</Steps>
119 +
120 +### Visualizing Tool Router in MCP Inspector
121 +
122 +You can inspect the session URL in any MCP client. Here's what it looks like in the MCP Inspector:
123 +
124 +<Frame>
125 + <img src="../../../assets/images/tool-router/inspector.jpeg" alt="Tool Router Inspector" />
126 +</Frame>
127 +
128 +## How Tool Router works
129 +
130 +The Tool Router executes a three-phase workflow:
131 +
132 +**1. Discovery**
133 +Searches across all available tools to find ones matching your task. Returns relevant toolkits with their descriptions, schemas, and connection status.
134 +
135 +**2. Authentication**
136 +Checks if the user has an active connection to the required toolkit. If not, creates an auth config and returns a connection URL using [Auth Link](/docs/authenticating-tools#hosted-authentication-connect-link). The user completes authentication through this link.
137 +
138 +**3. Execution**
139 +Loads authenticated tools into context and executes them. Supports parallel execution across multiple tools for efficiency.
140 +
141 +These phases are orchestrated through a set of meta tools, which handle search, planning, connection management, execution, and remote workbench.
142 +
143 +<Warning>
144 +**Experimental Feature**
145 +
146 +Tool Router is under active development. The meta tools, their schemas, parameters, and behaviors are subject to change as we iterate and improve the functionality. We recommend not using these tools individually.
147 +</Warning>
148 +
149 +## Works with any MCP client
150 +
151 +The session URL you created is a standard MCP endpoint. Use it with any framework that supports MCP:
152 +
153 +<Info>
154 +Tool Router uses Streamable HTTP transport for MCP communication. Make sure your MCP client supports HTTP transport (most do).
155 +</Info>
156 +
157 +<CardGroup cols={2}>
158 + <Card
159 + title="Vercel AI SDK"
160 + icon={<img src="../../../assets/images/vercel-logo.svg" width="24" height="24" />}
161 + href="https://ai-sdk.dev/cookbook/next/mcp-tools#mcp-tools"
162 + >
163 + Use experimental_createMCPClient with StreamableHTTPClientTransport to integrate with Next.js apps
164 + </Card>
165 + <Card
166 + title="Claude"
167 + icon={<img src="../../../assets/images/anthropic-logo.svg" width="24" height="24" />}
168 + href="https://docs.claude.com/en/docs/agents-and-tools/remote-mcp-servers"
169 + >
170 + Connect remote MCP servers through Anthropic's MCP connector API
171 + </Card>
172 + <Card
173 + title="LangChain"
174 + icon={<img src="../../../assets/images/langgraph-logo.svg" width="24" height="24" />}
175 + href="https://docs.langchain.com/oss/python/langchain/mcp"
176 + >
177 + Load Tool Router tools using langchain_mcp_adapters for Python workflows
178 + </Card>
179 +</CardGroup>
180 +
181 +<Note>
182 +The necessary scaffolding will be integrated into existing provider abstractions before Tool Router is generally available.
183 +</Note>
184 +
185 +## Customization
186 +
187 +### Restricting toolkits
188 +
189 +Control which toolkits are available by specifying them during session creation. This limits which apps your users can access.
190 +
191 +<CodeGroup>
192 +```python
193 +session = composio.experimental.tool_router.create_session(
194 + user_id="user@example.com",
195 + toolkits=["github", "slack", "gmail"]
196 +)
197 +```
198 +
199 +```typescript
200 +const session = await composio.experimental.toolRouter.createSession(
201 + "user@example.com",
202 + {
203 + toolkits: ["github", "slack", "gmail"]
204 + }
205 +);
206 +```
207 +</CodeGroup>
208 +
209 +
210 +### Manual connection management
211 +
212 +For advanced use cases, you can manually manage connections:
213 +
214 +<CodeGroup>
215 +```python
216 +session = composio.experimental.tool_router.create_session(
217 + user_id="user@example.com",
218 + toolkits=[{"toolkit": "gmail", "auth_config_id": "ac_nnn"}],
219 + manually_manage_connections=True
220 +)
221 +```
222 +
223 +```typescript
224 +const session = await composio.experimental.toolRouter.createSession(
225 + "user@example.com",
226 + {
227 + toolkits: [{ toolkit: 'gmail', authConfigId: 'ac_nnn' }],
228 + manuallyManageConnections: true
229 + }
230 +);
231 +```
232 +</CodeGroup>
233 +
234 +When you pass the auth config ID, you can use regular Composio functions to connect accounts and check authentication status.
235 +
236 +## Feedback
237 +
238 +This is still very experimental and work in progress, and you can expect the contracts to change and improve as we iterate on this. That said, we would love to hear your feedback on this.
239 +
240 +Give us feedback on this GitHub discussion [here](https://github.com/ComposioHQ/composio/discussions/2011).
\ No newline at end of file
fern/snippets/tool-router/python/quickstart.py new
+42
@@ -0,0 +1,42 @@
1 +import asyncio
2 +import os
3 +from composio import Composio
4 +from composio_openai_agents import OpenAIAgentsProvider
5 +from agents import Agent, Runner, HostedMCPTool
6 +
7 +async def main() -> None:
8 + # Initialize Composio and create Tool Router session
9 + composio = Composio(
10 + api_key=os.getenv("COMPOSIO_API_KEY"), # Uses env var by default
11 + provider=OpenAIAgentsProvider()
12 + )
13 + session = composio.experimental.tool_router.create_session(
14 + user_id="user@example.com",
15 + toolkits=["gmail", "github"] # Optional: Limit available toolkits
16 + )
17 +
18 + # Set up OpenAI agent with Tool Router MCP endpoint
19 + agent = Agent(
20 + name="Assistant",
21 + instructions="You are a helpful assistant that can access Gmail and GitHub. "
22 + "Help users fetch emails, create issues, manage pull requests, and more.",
23 + tools=[
24 + HostedMCPTool(
25 + tool_config={
26 + "type": "mcp",
27 + "server_label": "tool_router",
28 + "server_url": session['url'],
29 + "require_approval": "never",
30 + }
31 + )
32 + ],
33 + )
34 +
35 + # Execute the agent
36 + result = await Runner.run(
37 + agent,
38 + "Fetch the contributors to composiohq/composio github repository and email the list to user@example.com"
39 + )
40 + print(result.final_output)
41 +
42 +asyncio.run(main())
\ No newline at end of file
fern/snippets/tool-router/typescript/quickstart.ts new
+41
@@ -0,0 +1,41 @@
1 +import { Composio } from '@composio/core';
2 +import { OpenAIAgentsProvider } from '@composio/openai-agents';
3 +import { Agent, hostedMcpTool, run } from '@openai/agents';
4 +
5 +async function main() {
6 + // Initialize Composio with OpenAI Agents Provider
7 + const composio = new Composio({
8 + apiKey: process.env.COMPOSIO_API_KEY,
9 + provider: new OpenAIAgentsProvider()
10 + });
11 +
12 + // Create a Tool Router session for your user
13 + const session = await composio.experimental.toolRouter.createSession(
14 + 'user@example.com',
15 + {
16 + toolkits: ['gmail', 'github'] // Optional: Limit available toolkits
17 + }
18 + );
19 +
20 + // Create an agent with Tool Router MCP endpoint
21 + const agent = new Agent({
22 + name: 'Assistant',
23 + instructions: 'You are a helpful assistant that can access Gmail and GitHub. Help users fetch emails, create issues, manage pull requests, and more.',
24 + tools: [
25 + hostedMcpTool({
26 + serverLabel: 'tool_router',
27 + serverUrl: session.url,
28 + }),
29 + ],
30 + });
31 +
32 + // Execute the agent
33 + const result = await run(
34 + agent,
35 + 'Fetch the contributors to composiohq/composio github repository and email the list to user@example.com'
36 + );
37 +
38 + console.log(result.finalOutput);
39 +}
40 +
41 +main();
\ No newline at end of file