@devries-cameron20 / composio-1 / commits / c5369010b
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.

docs: merge Tool Router section into main docs

- Move Tool Router content to main docs section: - Authentication pages → /docs/authenticating-users/ - Guide pages → /docs/guides/ - Toolkit pages → /docs/toolkits/ - Add MCP and native tool examples to provider pages: - openai-agents.mdx: Usage with Tools, Usage with MCP, Usage with direct tools - vercel.mdx: Usage with Tools, Usage with MCP, Usage with direct tools - anthropic.mdx: Usage with MCP, Usage with direct tools - Remove Tool Router section entirely: - Delete content/tool-router/ folder - Delete app/(home)/tool-router/ routes - Remove from navigation, search, and LLM routes - Remove "Usage with direct MCP servers" sections (deprecated approach) - Update all internal links from /tool-router/* to /docs/* - Add redirects for old Tool Router URLs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Jan 22, 2026 at 21:45 UTC c5369010b3ef8aa24afef00596b12630de5cd46c
36 files changed +747 -1124
docs/app/(home)/tool-router/[[...slug]]/page.tsx deleted
-6
@@ -1,6 +0,0 @@
1 -import { toolRouterSource } from '@/lib/source';
2 -import { createDocsPage, createGenerateStaticParams, createGenerateMetadata } from '@/lib/create-docs-page';
3 -
4 -export default createDocsPage(toolRouterSource);
5 -export const generateStaticParams = createGenerateStaticParams(toolRouterSource);
6 -export const generateMetadata = createGenerateMetadata(toolRouterSource);
docs/app/(home)/tool-router/layout.tsx deleted
-4
@@ -1,4 +0,0 @@
1 -import { toolRouterSource } from '@/lib/source';
2 -import { createDocsLayout } from '@/lib/create-docs-layout';
3 -
4 -export default createDocsLayout(toolRouterSource);
docs/app/api/search/route.ts
+1 -8
@@ -1,5 +1,5 @@
1 // Use direct imports from collections to avoid top-level await in lib/source.ts
2 -import { docs, toolRouter, examples, toolkits } from 'fumadocs-mdx:collections/server';
2 +import { docs, examples, toolkits } from 'fumadocs-mdx:collections/server';
3 import { createSearchAPI } from 'fumadocs-core/search/server';
4 import { loader } from 'fumadocs-core/source';
5 import { lucideIconsPlugin } from 'fumadocs-core/source/lucide-icons';
@@ -11,12 +11,6 @@ const docsSource = loader({
11 plugins: [lucideIconsPlugin()],
12 });
13
14 -const toolRouterSource = loader({
15 - baseUrl: '/tool-router',
16 - source: toolRouter.toFumadocsSource(),
17 - plugins: [lucideIconsPlugin()],
18 -});
19 -
14 const examplesSource = loader({
15 baseUrl: '/examples',
16 source: examples.toFumadocsSource(),
@@ -31,7 +25,6 @@ const toolkitsSource = loader({
25
26 const allPages = [
27 ...docsSource.getPages(),
34 - ...toolRouterSource.getPages(),
28 ...examplesSource.getPages(),
29 ...toolkitsSource.getPages(),
30 ];
docs/app/llms.mdx/[[...slug]]/route.ts
-2
@@ -1,6 +1,5 @@
1 import {
2 source,
3 - toolRouterSource,
3 referenceSource,
4 examplesSource,
5 toolkitsSource,
@@ -377,7 +376,6 @@ async function openapiPageToMarkdown(
376 // Map URL prefixes to their sources
377 const sources = [
378 { prefix: 'docs', source },
380 - { prefix: 'tool-router', source: toolRouterSource },
379 { prefix: 'reference', source: referenceSource },
380 { prefix: 'examples', source: examplesSource },
381 { prefix: 'toolkits', source: toolkitsSource },
docs/content/docs/authenticating-users/in-chat-authentication.mdx renamed
+1 -1
@@ -1,5 +1,5 @@
1 ---
2 -title: Using In-chat authentication
2 +title: In-chat authentication
3 description: Let your agent prompt users to connect accounts during conversation
4 keywords: [automatic auth, dynamic auth, agent prompts]
5 ---
docs/content/docs/authenticating-users/manually-authenticating.mdx renamed
docs/content/docs/authenticating-users/meta.json new
+7
@@ -0,0 +1,7 @@
1 +{
2 + "title": "Authenticating users",
3 + "pages": [
4 + "in-chat-authentication",
5 + "manually-authenticating"
6 + ]
7 +}
docs/content/docs/authentication.mdx
+4 -4
@@ -23,7 +23,7 @@ You: Done
23 Agent: Done! I've starred ComposioHQ/composio.
24 ```
25
26 -This flow works well for chat applications where users interact directly with the agent. See [Using in-chat authentication](/tool-router/using-in-chat-authentication).
26 +This flow works well for chat applications where users interact directly with the agent. See [In-chat authentication](/docs/authenticating-users/in-chat-authentication).
27
28 ## Manual authentication
29
@@ -50,7 +50,7 @@ console.log(connectionRequest.redirectUrl);
50 </Tab>
51 </Tabs>
52
53 -Use this when you want users to connect accounts during onboarding, or when building a custom connections page. See [Manually authenticating users](/tool-router/manually-authenticating-users) for a detailed guide.
53 +Use this when you want users to connect accounts during onboarding, or when building a custom connections page. See [Manually authenticating users](/docs/authenticating-users/manually-authenticating) for a detailed guide.
54
55 ## How Tool Router manages auth configs
56
@@ -67,9 +67,9 @@ You don't need to create auth configs manually for most toolkits.
67 Tool Router supports **Composio managed OAuth** (GitHub, Gmail, Slack, and most toolkits) and **API key auth** (users enter their own keys via Connect Link).
68
69 <Callout type="info">
70 -Toolkits without Composio managed auth require a custom auth config. See [Using custom auth configs](/tool-router/using-custom-auth-configs).
70 +Toolkits without Composio managed auth require a custom auth config. See [Using custom auth configs](/docs/guides/using-custom-auth-configuration).
71 </Callout>
72
73 ## White-labeling
74
75 -Show your own branding on OAuth consent screens by creating your own OAuth app. See [White-labeling authentication](/tool-router/white-labeling-authentication).
75 +Show your own branding on OAuth consent screens by creating your own OAuth app. See [White-labeling authentication](/docs/guides/white-labeling-authentication).
docs/content/docs/guides/managing-multiple-connected-accounts.mdx renamed
+1 -1
@@ -1,5 +1,5 @@
1 ---
2 -title: Managing multiple accounts
2 +title: Managing multiple connected accounts
3 description: Handle users with multiple accounts for the same toolkit
4 keywords: [multiple accounts, work personal, switch account]
5 ---
docs/content/docs/guides/multitenancy.mdx new
+5
@@ -0,0 +1,5 @@
1 +---
2 +title: Multitenancy
3 +description: Build multi-tenant applications with Composio
4 +---
5 +
docs/content/docs/guides/using-custom-auth-configuration.mdx renamed
+1 -1
@@ -1,5 +1,5 @@
1 ---
2 -title: Using custom auth configs
2 +title: Using custom auth configuration
3 description: Set up auth configs for toolkits without Composio managed authentication
4 keywords: [custom credentials, no managed auth]
5 ---
docs/content/docs/guides/white-labeling-authentication.mdx renamed
docs/content/docs/meta.json
+9
@@ -3,11 +3,20 @@
3 "---Get Started---",
4 "index",
5 "quickstart",
6 + "quickstart-tool-router",
7 "providers",
8 "---Core Concepts---",
9 "users-and-sessions",
10 "authentication",
11 "tools-and-toolkits",
12 + "---Getting Started---",
13 + "authenticating-users",
14 + "toolkits",
15 + "---Guides---",
16 + "guides/white-labeling-authentication",
17 + "guides/managing-multiple-connected-accounts",
18 + "guides/using-custom-auth-configuration",
19 + "guides/multitenancy",
20 "---Tools---",
21 "fetching-tools",
22 "authenticating-tools",
docs/content/docs/migration-guide/tool-router-beta.mdx
+5 -5
@@ -103,11 +103,11 @@ const session = await composio.create('user_123',
103
104 Check out these new features available in the stable version:
105
106 -- **[Native tools](/tool-router/using-as-a-native-tool)**: Use Tool Router with any AI framework
106 +- **[Native tools](/docs/providers)**: Use Tool Router with any AI framework
107 - **Better [session](/docs/users-and-sessions) and [auth](/docs/authentication) config**
108 -- **[Multi-account support](/tool-router/managing-multiple-accounts)**: Manage multiple accounts per user seamlessly
109 -- **[Manual authentication](/tool-router/manually-authenticating-users)**: Control when and how users authenticate
110 -- **[Custom auth](/tool-router/using-custom-auth-configs)**: Support for toolkits that don't have composio managed auth
111 -- **[White labeling](/tool-router/white-labeling-authentication)**: Customize authentication screens with your branding
108 +- **[Multi-account support](/docs/guides/managing-multiple-connected-accounts)**: Manage multiple accounts per user seamlessly
109 +- **[Manual authentication](/docs/authenticating-users/manually-authenticating)**: Control when and how users authenticate
110 +- **[Custom auth](/docs/guides/using-custom-auth-configuration)**: Support for toolkits that don't have composio managed auth
111 +- **[White labeling](/docs/guides/white-labeling-authentication)**: Customize authentication screens with your branding
112 </Step>
113 </Steps>
docs/content/docs/providers/anthropic.mdx
+184 -108
@@ -6,9 +6,190 @@ keywords: [claude]
6
7 The Anthropic Provider transforms Composio tools into a format compatible with Anthropic's function calling capabilities through its Messages API.
8
9 -## Setup
9 +## Usage with MCP
10
11 -The Anthropic provider can be installed for both SDKs.
11 +Use Composio Tool Router with the Claude Agent SDK for a fully managed MCP experience.
12 +
13 +### Installation
14 +
15 +<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
16 +<Tab value="Python">
17 +```bash
18 +pip install python-dotenv composio claude-agent-sdk
19 +```
20 +</Tab>
21 +<Tab value="TypeScript">
22 +```bash
23 +npm install dotenv @composio/core @anthropic-ai/claude-agent-sdk
24 +```
25 +</Tab>
26 +</Tabs>
27 +
28 +### Usage
29 +
30 +Create a Tool Router session and execute tasks with Claude:
31 +
32 +<Callout type="info">
33 +- Set your `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
34 +- Set your `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://platform.claude.com/settings/keys).
35 +</Callout>
36 +
37 +<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
38 +<Tab value="Python">
39 +```python
40 +import asyncio
41 +from dotenv import load_dotenv
42 +from claude_agent_sdk.client import ClaudeSDKClient
43 +from claude_agent_sdk.types import (
44 + ClaudeAgentOptions,
45 + AssistantMessage,
46 + TextBlock,
47 + ToolUseBlock,
48 +)
49 +from composio import Composio
50 +
51 +load_dotenv()
52 +
53 +# Initialize Composio (API key from env var COMPOSIO_API_KEY or pass explicitly)
54 +composio = Composio()
55 +
56 +# Unique identifier of the user
57 +user_id = "user_123"
58 +# Create a tool router session for the user
59 +session = composio.create(user_id=user_id)
60 +
61 +# Configure Claude with Composio MCP server
62 +options = ClaudeAgentOptions(
63 + system_prompt=(
64 + "You are a helpful assistant with access to external tools. "
65 + "Always use the available tools to complete user requests."
66 + ),
67 + mcp_servers={
68 + "composio": {
69 + "type": "http",
70 + "url": session.mcp.url,
71 + "headers": session.mcp.headers, # Authentication headers for the Composio MCP server
72 + }
73 + },
74 + permission_mode="bypassPermissions", # Auto-approve tools (demo only)
75 +)
76 +
77 +async def main():
78 + print("""
79 +What task would you like me to help you with?
80 +I can use tools like Gmail, GitHub, Linear, Notion, and more.
81 +(Type 'exit' to exit)
82 +Example tasks:
83 + • 'Summarize my emails from today'
84 + • 'List all open issues on the composio github repository and create a notion page with the issues'
85 +""")
86 +
87 + async with ClaudeSDKClient(options) as client:
88 + # Multi-turn conversation with agentic tool calling
89 + while True:
90 + user_input = input("\nYou: ").strip()
91 + if user_input.lower() == "exit":
92 + break
93 +
94 + print("\nClaude: ", end="", flush=True)
95 + try:
96 + await client.query(user_input)
97 + async for msg in client.receive_response():
98 + if isinstance(msg, AssistantMessage):
99 + for block in msg.content:
100 + if isinstance(block, ToolUseBlock):
101 + print(f"\n[Using tool: {block.name}]", end="")
102 + elif isinstance(block, TextBlock):
103 + print(block.text, end="", flush=True)
104 + except Exception as e:
105 + print(f"\n[Error]: {e}")
106 +
107 +if __name__ == "__main__":
108 + asyncio.run(main())
109 +```
110 +</Tab>
111 +<Tab value="TypeScript">
112 +```typescript
113 +import "dotenv/config";
114 +import { query, type Options } from "@anthropic-ai/claude-agent-sdk";
115 +import { Composio } from "@composio/core";
116 +import { createInterface } from "readline/promises";
117 +
118 +// Initialize Composio (API key from env var COMPOSIO_API_KEY or pass explicitly: { apiKey: "your-key" })
119 +const composio = new Composio();
120 +
121 +// Unique identifier of the user
122 +const userId = "user_123";
123 +
124 +// Create a tool router session for the user
125 +const session = await composio.create(userId);
126 +
127 +const options: Options = {
128 + systemPrompt: `You are a helpful assistant with access to external tools. ` +
129 + `Always use the available tools to complete user requests.`,
130 + mcpServers: {
131 + composio: {
132 + type: "http",
133 + url: session.mcp.url,
134 + headers: session.mcp.headers // Authentication headers for the Composio MCP server
135 + },
136 + },
137 + permissionMode: "bypassPermissions", // Auto-approve tools (demo only - use "default" in production)
138 +};
139 +
140 +// Set up interactive terminal input/output for the conversation
141 +const readline = createInterface({ input: process.stdin, output: process.stdout });
142 +
143 +console.log(`
144 +What task would you like me to help you with?
145 +I can use tools like Gmail, GitHub, Linear, Notion, and more.
146 +(Type 'exit' to exit)
147 +Example tasks:
148 + • 'Summarize my emails from today'
149 + • 'List all open issues on the composio github repository and create a notion page with the issues'
150 +`);
151 +
152 +let isFirstQuery = true;
153 +
154 +// Multi-turn conversation with agentic tool calling
155 +while (true) {
156 + const answer = await readline.question('You: ');
157 + const input = answer.trim();
158 + if (input.toLowerCase() === "exit") break;
159 +
160 + process.stdout.write("Claude: ");
161 +
162 + const queryOptions = isFirstQuery ? options : { ...options, continue: true };
163 + isFirstQuery = false;
164 +
165 + try {
166 + for await (const stream of query({ prompt: input, options: queryOptions })) {
167 + // Only process assistant messages (the SDK also sends result/error messages)
168 + if (stream.type === "assistant") {
169 + const { content } = stream.message;
170 + for (const block of content) {
171 + if (block.type === "tool_use") {
172 + process.stdout.write(`\n[Using tool: ${block.name}]`);
173 + } else if (block.type === "text") {
174 + process.stdout.write(block.text);
175 + }
176 + }
177 + }
178 + }
179 + } catch (error) {
180 + console.error("\n[Error]:", error instanceof Error ? error.message : error);
181 + }
182 + process.stdout.write("\n");
183 +}
184 +
185 +readline.close();
186 +```
187 +</Tab>
188 +</Tabs>
189 +
190 +## Usage with direct tools
191 +
192 +### Setup
193
194 <Tabs items={["Python", "TypeScript"]}>
195 <Tab value="Python">
@@ -55,7 +236,7 @@ const anthropic = new Anthropic();
236 </Tab>
237 </Tabs>
238
58 -## Usage
239 +### Usage
240
241 <Tabs items={["Python", "TypeScript"]}>
242 <Tab value="Python">
@@ -112,108 +293,3 @@ console.log(res[0].content);
293 ```
294 </Tab>
295 </Tabs>
115 -
116 -## Modifiers
117 -
118 -Modifiers are functions that can be used to intercept and optionally modify the schema, the tool call request and the response from the tool call.
119 -
120 -Anthropic provider modifiers are the standard framework modifiers. Read more here: [Modifying tool schemas](/docs/modify-tool-behavior/modifying-tool-schemas).
121 -
122 -## Usage: Direct MCP Servers
123 -
124 -You can also use Composio MCP servers directly with the Anthropic SDK.
125 -
126 -<Callout type="info">
127 -Composio MCP servers only support Streamable HTTP transport.
128 -</Callout>
129 -
130 -<Tabs items={["Python", "TypeScript"]}>
131 -<Tab value="Python">
132 -```python
133 -from anthropic import Anthropic
134 -from composio import Composio
135 -
136 -# Initialize clients
137 -composio = Composio()
138 -anthropic = Anthropic(api_key="your-anthropic-api-key")
139 -
140 -# Create MCP server with GitHub and Linear tools
141 -server = composio.mcp.create(
142 - name="dev-workflow-server",
143 - toolkits=[
144 - {"toolkit": "github", "auth_config": "ac_github_id"},
145 - {"toolkit": "linear", "auth_config": "ac_linear_id"}
146 - ],
147 - allowed_tools=["GITHUB_LIST_PRS", "GITHUB_CREATE_COMMENT", "LINEAR_CREATE_ISSUE"]
148 -)
149 -
150 -# Generate MCP instance for user
151 -instance = server.generate("user@example.com")
152 -
153 -# Use MCP with Anthropic to manage development workflow
154 -response = anthropic.beta.messages.create(
155 - model="claude-sonnet-4-5",
156 - system="You are a helpful assistant with access to GitHub and Linear tools. Use these tools to help manage development workflows. Do not ask for confirmation before using the tools.",
157 - max_tokens=1000,
158 - messages=[{
159 - "role": "user",
160 - "content": "Check my GitHub PRs for review comments, create Linear tasks for any requested changes, and update the PR descriptions with task links"
161 - }],
162 - mcp_servers=[{
163 - "type": "url",
164 - "url": instance['url'],
165 - "name": "composio-mcp-server"
166 - }],
167 - betas=["mcp-client-2025-04-04"] # Enable MCP beta
168 -)
169 -
170 -print(response.content)
171 -```
172 -</Tab>
173 -<Tab value="TypeScript">
174 -```typescript
175 -// @noErrors
176 -import Anthropic from '@anthropic-ai/sdk';
177 -import { Composio } from '@composio/core';
178 -
179 -// Initialize clients
180 -const composio = new Composio();
181 -const anthropic = new Anthropic({
182 - apiKey: process.env.ANTHROPIC_API_KEY,
183 -});
184 -
185 -// Create MCP server with Google Sheets tools
186 -const server = await composio.mcp.create(
187 - "analytics-server",
188 - {
189 - toolkits: [
190 - { toolkit: "googlesheets", authConfigId: "ac_sheets_id" }
191 - ],
192 - allowedTools: ["GOOGLESHEETS_GET_DATA", "GOOGLESHEETS_UPDATE_DATA", "GOOGLESHEETS_CREATE_SHEET"]
193 - }
194 -);
195 -
196 -// Generate MCP instance for user
197 -const instance = await server.generate("user@example.com");
198 -
199 -// Use MCP with Anthropic for spreadsheet operations
200 -const response = await anthropic.beta.messages.create({
201 - model: "claude-sonnet-4-5",
202 - system: "You are a helpful assistant with access to Google Sheets tools. Use these tools to analyze and manage spreadsheet data. Do not ask for confirmation before using the tools.",
203 - max_tokens: 1000,
204 - messages: [{
205 - role: "user",
206 - content: "Analyze the sales data in my Google Sheets 'Q4 Revenue' spreadsheet, calculate month-over-month growth, and add a new summary sheet with visualizations"
207 - }],
208 - mcp_servers: [{
209 - type: "url",
210 - url: instance.url,
211 - name: "composio-mcp-server"
212 - }],
213 - betas: ["mcp-client-2025-04-04"] // Enable MCP beta
214 -});
215 -
216 -console.log(response.content);
217 -```
218 -</Tab>
219 -</Tabs>
docs/content/docs/providers/google.mdx
-6
@@ -109,9 +109,3 @@ if (response.functionCalls && response.functionCalls.length > 0) {
109 </Tab>
110 </Tabs>
111
112 -## Modifiers
113 -
114 -Modifiers are functions that can be used to intercept and optionally **modify** the schema, the tool call request and the response from the tool call.
115 -
116 -OpenAI provider modifiers are the standard framework modifiers.
117 -Read more here: [Modifying tool schemas](/docs/modify-tool-behavior/modifying-tool-schemas)
docs/content/docs/providers/openai-agents.mdx
+319 -12
@@ -8,16 +8,331 @@ The OpenAI Agents Provider is a provider that formats the Composio tools into an
8
9 OpenAI Agents SDK is different from the OpenAI SDK. It helps build agentic AI apps in a lightweight, easy-to-use package with very few abstractions.
10
11 -<Tabs items={["Python", "TypeScript"]}>
11 +## Usage with Tools
12 +
13 +Use Composio Tool Router as a native tool with the OpenAI Agents SDK.
14 +
15 +### Installation
16 +
17 +<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
18 +<Tab value="Python">
19 +```bash
20 +pip install python-dotenv composio composio-openai-agents openai-agents
21 +```
22 +</Tab>
23 +<Tab value="TypeScript">
24 +```bash
25 +npm install @composio/core @composio/openai-agents @openai/agents
26 +```
27 +</Tab>
28 +</Tabs>
29 +
30 +### Usage
31 +
32 +Create a Tool Router session and use it as a native tool with OpenAI Agents SDK:
33 +
34 +<Callout type="info">
35 +- Set `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
36 +- Set `OPENAI_API_KEY` environment variable with your [OpenAI API key](https://platform.openai.com/api-keys).
37 +</Callout>
38 +
39 +<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
40 +<Tab value="Python">
41 +```python
42 +from dotenv import load_dotenv
43 +from composio import Composio
44 +from agents import Agent, Runner, SQLiteSession
45 +from composio_openai_agents import OpenAIAgentsProvider
46 +
47 +load_dotenv()
48 +
49 +# Initialize Composio with OpenAI Agents provider (API key from env var COMPOSIO_API_KEY)
50 +composio = Composio(provider=OpenAIAgentsProvider())
51 +
52 +# Unique identifier of the user
53 +user_id = "user_123"
54 +
55 +# Create a session and get native tools for the user
56 +session = composio.create(user_id=user_id)
57 +tools = session.tools()
58 +
59 +# Configure OpenAI agent with Composio tools
60 +agent = Agent(
61 + name="Personal Assistant",
62 + instructions="You are a helpful personal assistant. Use Composio tools to take action.",
63 + model="gpt-5.2",
64 + tools=tools,
65 +)
66 +
67 +# Memory for multi-turn conversation
68 +memory = SQLiteSession("conversation")
69 +
70 +# Execute an initial task
71 +print("Fetching GitHub issues from the Composio repository...\n")
72 +try:
73 + result = Runner.run_sync(
74 + starting_agent=agent,
75 + input="Fetch all the open GitHub issues on the @ComposioHQ/composio repository and group them by bugs/features/docs.",
76 + session=memory,
77 + )
78 + print(f"{result.final_output}\n")
79 +except Exception as e:
80 + print(f"[Error]: {e}")
81 +
82 +# Continue with interactive conversation
83 +print("\nWhat else would you like me to do? (Type 'exit' to exit)")
84 +
85 +while True:
86 + user_input = input("You: ").strip()
87 + if user_input.lower() == "exit":
88 + break
89 +
90 + print("Assistant: ", end="", flush=True)
91 + try:
92 + result = Runner.run_sync(starting_agent=agent, input=user_input, session=memory)
93 + print(f"{result.final_output}\n")
94 + except Exception as e:
95 + print(f"\n[Error]: {e}")
96 +```
97 +</Tab>
98 +<Tab value="TypeScript">
99 +```typescript
100 +import "dotenv/config";
101 +import { Composio } from "@composio/core";
102 +import { Agent, run, MemorySession } from "@openai/agents";
103 +import { OpenAIAgentsProvider } from "@composio/openai-agents";
104 +import { createInterface } from "readline/promises";
105 +
106 +// Initialize Composio with OpenAI Agents provider (API key from env var COMPOSIO_API_KEY)
107 +const composio = new Composio({ provider: new OpenAIAgentsProvider() });
108 +
109 +// Unique identifier of the user
110 +const userId = "user_123";
111 +
112 +// Create a session and get native tools for the user
113 +const session = await composio.create(userId);
114 +const tools = await session.tools();
115 +
116 +const agent = new Agent({
117 + name: "Personal Assistant",
118 + instructions: "You are a helpful personal assistant. Use Composio tools to take action.",
119 + model: "gpt-5.2",
120 + tools,
121 +});
122 +
123 +// Create a memory session for persistent multi-turn conversation
124 +const memory = new MemorySession();
125 +
126 +// Execute an initial task
127 +console.log("Fetching GitHub issues from the Composio repository...\n");
128 +try {
129 + const initialResult = await run(
130 + agent,
131 + "Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs.",
132 + { session: memory }
133 + );
134 + console.log(`${initialResult.finalOutput}\n`);
135 +} catch (error) {
136 + console.error("[Error]:", error instanceof Error ? error.message : error);
137 +}
138 +
139 +// Continue with interactive conversation
140 +const readline = createInterface({ input: process.stdin, output: process.stdout });
141 +
142 +console.log(`
143 +What else would you like me to do?
144 +(Type 'exit' to exit)
145 +`);
146 +
147 +
148 +while (true) {
149 + const input = (await readline.question("You: ")).trim();
150 + if (input.toLowerCase() === "exit") break;
151 +
152 + console.log("Assistant: ");
153 +
154 + try {
155 + const result = await run(agent, input, { session: memory });
156 + console.log(`${result.finalOutput}\n`);
157 + } catch (error) {
158 + console.error("\n[Error]:", error instanceof Error ? error.message : error);
159 + }
160 +}
161 +readline.close();
162 +```
163 +</Tab>
164 +</Tabs>
165 +
166 +## Usage with MCP
167 +
168 +Use Composio Tool Router with the OpenAI Agents SDK for a fully managed MCP experience.
169 +
170 +### Installation
171 +
172 +<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
173 +<Tab value="Python">
174 +```bash
175 +pip install python-dotenv composio openai-agents
176 +```
177 +</Tab>
178 +<Tab value="TypeScript">
179 +```bash
180 +npm install dotenv @composio/core @openai/agents zod@3
181 +```
182 +</Tab>
183 +</Tabs>
184 +
185 +### Usage
186 +
187 +Create a Tool Router session and execute tasks with OpenAI agents:
188 +
189 +<Callout type="info">
190 +- Set `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
191 +- Set `OPENAI_API_KEY` environment variable with your [OpenAI API key](https://platform.openai.com/api-keys).
192 +</Callout>
193 +
194 +<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
195 <Tab value="Python">
13 -## Setup
196 +```python
197 +from dotenv import load_dotenv
198 +from composio import Composio
199 +from agents import Agent, Runner, HostedMCPTool
200 +
201 +load_dotenv()
202 +
203 +# Initialize Composio (API key from env var COMPOSIO_API_KEY)
204 +composio = Composio()
205 +# Unique identifier of the user
206 +user_id = "user_123"
207 +
208 +# Create a Tool Router session for the user
209 +session = composio.create(user_id=user_id)
210 +
211 +# Configure OpenAI agent with Composio MCP server
212 +agent = Agent(
213 + name="Personal Assistant",
214 + instructions="You are a helpful personal assistant. Use Composio tools to take action.",
215 + model="gpt-5.2",
216 + tools=[
217 + HostedMCPTool(
218 + tool_config={
219 + "type": "mcp",
220 + "server_label": "composio",
221 + "server_url": session.mcp.url,
222 + "require_approval": "never",
223 + "headers": session.mcp.headers,
224 + }
225 + )
226 + ],
227 +)
228
229 +# Execute the task
230 +print("Fetching GitHub issues from the Composio repository @ComposioHQ/composio...\n")
231 +try:
232 + result = Runner.run_sync(
233 + starting_agent=agent,
234 + input="Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs.",
235 + )
236 + print(result.final_output)
237 +except Exception as e:
238 + print(f"[Error]: {e}")
239 +
240 +print("\n\n---")
241 +print("Tip: If prompted to authenticate, complete the auth flow and run again.")
242 +```
243 +</Tab>
244 +<Tab value="TypeScript">
245 +```typescript
246 +import "dotenv/config";
247 +import { Composio } from "@composio/core";
248 +import { Agent, hostedMcpTool, run, MemorySession } from "@openai/agents";
249 +import { createInterface } from "readline/promises";
250 +
251 +// Initialize Composio (API key from env var COMPOSIO_API_KEY or pass explicitly: { apiKey: "your-key" })
252 +const composio = new Composio();
253 +
254 +// Unique identifier of the user
255 +const userId = "user_123";
256 +
257 +// Create a tool router session for the user
258 +const session = await composio.create(userId);
259 +
260 +const agent = new Agent({
261 + name: "Personal Assistant",
262 + instructions: "You are a helpful personal assistant. Use Composio tools to take action.",
263 + model: "gpt-5.2",
264 + tools: [
265 + hostedMcpTool({
266 + serverLabel: "composio",
267 + serverUrl: session.mcp.url,
268 + headers: session.mcp.headers, // Authentication headers for the Composio MCP server
269 + }),
270 + ],
271 +});
272 +
273 +// Create a memory session for persistent multi-turn conversation
274 +const memory = new MemorySession();
275 +
276 +// Execute an initial task
277 +console.log("Fetching GitHub issues from the Composio repository...\n");
278 +try {
279 + const initialResult = await run(
280 + agent,
281 + "Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs.",
282 + { session: memory }
283 + );
284 + console.log(`${initialResult.finalOutput}\n`);
285 +} catch (error) {
286 + console.error("[Error]:", error instanceof Error ? error.message : error);
287 +}
288 +
289 +// Continue with interactive conversation
290 +const readline = createInterface({ input: process.stdin, output: process.stdout });
291 +
292 +console.log(`
293 +What else would you like me to do?
294 +(Type 'exit' to exit)
295 +`);
296 +
297 +while (true) {
298 + const input = (await readline.question("You: ")).trim();
299 + if (input.toLowerCase() === "exit") break;
300 +
301 + console.log("Assistant: ");
302 +
303 + try {
304 + const result = await run(agent, input, { session: memory });
305 + console.log(`${result.finalOutput}\n`);
306 + } catch (error) {
307 + console.error("\n[Error]:", error instanceof Error ? error.message : error);
308 + }
309 +}
310 +readline.close();
311 +```
312 +</Tab>
313 +</Tabs>
314 +
315 +## Usage with direct tools
316 +
317 +### Setup
318 +
319 +<Tabs items={["Python", "TypeScript"]}>
320 +<Tab value="Python">
321 ```bash
322 pip install composio openai-agents composio-openai-agents
323 ```
324 +</Tab>
325 +<Tab value="TypeScript">
326 +```bash
327 +npm install @composio/core @openai/agents @composio/openai-agents
328 +```
329 +</Tab>
330 +</Tabs>
331
19 -## Usage
332 +### Usage
333
334 +<Tabs items={["Python", "TypeScript"]}>
335 +<Tab value="Python">
336 ```python
337 import asyncio
338 from composio import Composio
@@ -40,7 +355,7 @@ agent = Agent(
355 async def main():
356 result = await Runner.run(
357 starting_agent=agent,
43 - input="Send an email to soham.g@composio.dev with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'",
358 + input="Send an email to soham.g@composio.dev with the subject 'Hello from composio' and the body 'Congratulations on sending your first email using AI Agents and Composio!'",
359 )
360 print(result.final_output)
361
@@ -48,14 +363,6 @@ asyncio.run(main())
363 ```
364 </Tab>
365 <Tab value="TypeScript">
51 -## Setup
52 -
53 -```bash
54 -npm install @composio/core @openai/agents @composio/openai-agents
55 -```
56 -
57 -## Usage
58 -
366 ```typescript
367 import { Composio } from "@composio/core";
368 import { Agent, run } from "@openai/agents";
docs/content/docs/providers/openai.mdx
-103
@@ -196,106 +196,3 @@ main();
196 ```
197 </Tab>
198 </Tabs>
199 -
200 -## Modifiers
201 -
202 -Modifiers are functions that can be used to intercept and optionally **modify** the schema, the tool call request and the response from the tool call.
203 -
204 -OpenAI provider modifiers are the standard framework modifiers.
205 -Read more here: [Modifying tool schemas](/docs/modify-tool-behavior/modifying-tool-schemas)
206 -
207 -## Usage: Direct MCP Servers
208 -
209 -You can also use Composio MCP servers directly with the OpenAI SDK.
210 -
211 -<Callout type="info">
212 -Composio MCP servers only support Streamable HTTP transport.
213 -</Callout>
214 -
215 -<Tabs items={["Python", "TypeScript"]}>
216 -<Tab value="Python">
217 -```python
218 -from openai import OpenAI
219 -from composio import Composio
220 -
221 -# Initialize clients
222 -composio = Composio()
223 -openai = OpenAI(api_key="your-openai-api-key")
224 -
225 -# Create MCP server with Google Sheets and Notion tools
226 -server = composio.mcp.create(
227 - name="data-docs-server",
228 - toolkits=[
229 - {"toolkit": "googlesheets", "auth_config": "ac_sheets_id"},
230 - {"toolkit": "notion", "auth_config": "ac_notion_id"}
231 - ],
232 - allowed_tools=["GOOGLESHEETS_GET_DATA", "GOOGLESHEETS_UPDATE_DATA", "NOTION_CREATE_PAGE"]
233 -)
234 -
235 -# Generate MCP instance for user
236 -instance = server.generate("user@example.com")
237 -
238 -# Use MCP with OpenAI for data management
239 -response = openai.responses.create(
240 - model="gpt-5",
241 - tools=[
242 - {
243 - "type": "mcp",
244 - "server_label": "composio-server",
245 - "server_description": "Composio MCP server with Google Sheets and Notion integrations",
246 - "server_url": instance['url'],
247 - "require_approval": "never",
248 - },
249 - ],
250 - input="Export the Q4 metrics from Google Sheets and create a comprehensive Notion page with charts and analysis",
251 -)
252 -
253 -print("OpenAI MCP Response:", response.output_text)
254 -```
255 -</Tab>
256 -<Tab value="TypeScript">
257 -```typescript
258 -// @noErrors
259 -import OpenAI from 'openai';
260 -import { Composio } from '@composio/core';
261 -
262 -// Initialize clients
263 -const composio = new Composio();
264 -const openai = new OpenAI({
265 - apiKey: process.env.OPENAI_API_KEY,
266 -});
267 -
268 -// Create MCP server with Linear and Notion tools
269 -const server = await composio.mcp.create(
270 - "project-docs-server",
271 - {
272 - toolkits: [
273 - { toolkit: "linear", authConfigId: "ac_linear_id" },
274 - { toolkit: "notion", authConfigId: "ac_notion_id" }
275 - ],
276 - allowedTools: ["LINEAR_LIST_ISSUES", "LINEAR_GET_ISSUE", "NOTION_CREATE_PAGE"]
277 - }
278 -);
279 -
280 -// Generate MCP instance for user
281 -const instance = await server.generate("user@example.com");
282 -
283 -// Use MCP with OpenAI for project documentation
284 -const response = await openai.responses.create({
285 - model: "gpt-5",
286 - tools: [
287 - {
288 - type: "mcp",
289 - server_label: "composio-server",
290 - server_description: "Composio MCP server with Linear and Notion integrations",
291 - server_url: instance.url,
292 - require_approval: "never",
293 - },
294 - ],
295 - input: "Find all completed Linear issues from this sprint and create a Notion page documenting the release notes",
296 -});
297 -
298 -console.log("OpenAI MCP Response:", response.output_text);
299 -```
300 -</Tab>
301 -</Tabs>
docs/content/docs/providers/vercel.mdx
+133 -3
@@ -8,7 +8,137 @@ Vercel AI SDK allows you to configure an optional async `execute` function that
8
9 The Vercel provider for Composio formats the Composio tools and adds this `execute` function to the tool calls.
10
11 -## Setup
11 +## Usage with Tools
12 +
13 +Use Composio Tool Router as a native tool with the Vercel AI SDK.
14 +
15 +### Installation
16 +
17 +```bash
18 +npm install @composio/core @composio/vercel ai @ai-sdk/anthropic
19 +```
20 +
21 +### Usage
22 +
23 +Create a Tool Router session and use it as a native tool with Vercel AI SDK:
24 +
25 +<Callout type="info">
26 +- Set `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
27 +- Set `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://console.anthropic.com/settings/keys).
28 +</Callout>
29 +
30 +```typescript
31 +import "dotenv/config";
32 +import { anthropic } from "@ai-sdk/anthropic";
33 +import { Composio } from "@composio/core";
34 +import { VercelProvider } from "@composio/vercel";
35 +import { stepCountIs, streamText } from "ai";
36 +
37 +// Initialize Composio with Vercel provider (API key from env var COMPOSIO_API_KEY)
38 +const composio = new Composio({ provider: new VercelProvider() });
39 +
40 +// Unique identifier of the user
41 +const userId = "user_123";
42 +
43 +// Create a session and get native tools for the user
44 +const session = await composio.create(userId);
45 +const tools = await session.tools();
46 +
47 +console.log("Fetching GitHub issues from the Composio repository...");
48 +
49 +// Stream the response with tool calling
50 +const stream = await streamText({
51 + system: "You are a helpful personal assistant. Use Composio tools to take action.",
52 + model: anthropic("claude-sonnet-4-5"),
53 + prompt: "Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs.",
54 + stopWhen: stepCountIs(10),
55 + onStepFinish: (step) => {
56 + for (const toolCall of step.toolCalls) {
57 + console.log(`[Using tool: ${toolCall.toolName}]`);
58 + }
59 + },
60 + tools,
61 +});
62 +
63 +for await (const textPart of stream.textStream) {
64 + process.stdout.write(textPart);
65 +}
66 +
67 +console.log("\n\n---");
68 +console.log("Tip: If prompted to authenticate, complete the auth flow and run again.");
69 +```
70 +
71 +## Usage with MCP
72 +
73 +Use Composio Tool Router with the Vercel AI SDK for a fully managed MCP experience.
74 +
75 +### Installation
76 +
77 +```bash
78 +npm install dotenv @composio/core ai @ai-sdk/anthropic @ai-sdk/mcp
79 +```
80 +
81 +### Usage
82 +
83 +Use Tool Router with Vercel AI SDK's `streamText` for completions:
84 +
85 +<Callout type="info">
86 +- Set `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
87 +- Set `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://platform.claude.com/settings/keys).
88 +</Callout>
89 +
90 +```typescript
91 +import "dotenv/config";
92 +import { anthropic } from "@ai-sdk/anthropic";
93 +import { experimental_createMCPClient as createMCPClient } from "@ai-sdk/mcp";
94 +import { Composio } from "@composio/core";
95 +import { stepCountIs, streamText } from "ai";
96 +
97 +// Initialize Composio (API key from env var COMPOSIO_API_KEY or pass explicitly: { apiKey: "your-key" })
98 +const composio = new Composio();
99 +
100 +// Unique identifier of the user
101 +const userId = "user_123";
102 +
103 +// Create a tool router session for the user
104 +const { mcp } = await composio.create(userId);
105 +
106 +// Create an MCP client to connect to the Composio tool router
107 +const client = await createMCPClient({
108 + transport: {
109 + type: "http",
110 + url: mcp.url,
111 + headers: mcp.headers, // Authentication headers for the Composio MCP server
112 + },
113 +});
114 +const tools = await client.tools();
115 +
116 +console.log("Summarizing your emails from today");
117 +
118 +const stream = await streamText({
119 + system: "You are a helpful personal assistant. Use Composio tools to take action.",
120 + model: anthropic("claude-sonnet-4-5"),
121 + prompt: "Summarize my emails from today",
122 + stopWhen: stepCountIs(10),
123 + onStepFinish: (step) => {
124 + for (const toolCall of step.toolCalls) {
125 + console.log(`[Using tool: ${toolCall.toolName}]`);
126 + }
127 + },
128 + tools,
129 +});
130 +
131 +for await (const textPart of stream.textStream) {
132 + process.stdout.write(textPart);
133 +}
134 +
135 +console.log("\n\n---");
136 +console.log("Tip: If prompted to authenticate, complete the auth flow and run again.")
137 +```
138 +
139 +## Usage with direct tools
140 +
141 +### Setup
142
143 Vercel AI SDK and the provider are only available for the TypeScript SDK.
144
@@ -29,7 +159,7 @@ const composio = new Composio({
159 });
160 ```
161
32 -## Usage
162 +### Usage
163
164 ```typescript
165 import { Composio } from '@composio/core';
@@ -49,7 +179,7 @@ const { text } = await generateText({
179 messages: [
180 {
181 role: "user",
52 - content: `Send an email to soham.g@composio.dev with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'`,
182 + content: `Send an email to soham.g@composio.dev with the subject 'Hello from composio' and the body 'Congratulations on sending your first email using AI Agents and Composio!'`,
183 },
184 ],
185 tools,
docs/content/docs/quickstart-tool-router.mdx renamed
+11 -14
@@ -1,5 +1,5 @@
1 ---
2 -title: Quickstart
2 +title: Quickstart (Tool Router)
3 description: Build an AI agent with access to 1000+ tools
4 keywords: [tutorial, setup, first agent]
5 ---
@@ -33,7 +33,7 @@ npm install dotenv @composio/core @anthropic-ai/claude-agent-sdk
33 <Step>
34 ### Create session and run agent
35
36 -[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
36 +[Sessions](/docs/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
37
38 <Callout type="info">
39 - Set `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
@@ -41,7 +41,7 @@ npm install dotenv @composio/core @anthropic-ai/claude-agent-sdk
41 - `userId` is your user's unique identifier. See [User Management](/docs/user-management) for details.
42 </Callout>
43
44 -When the agent needs authentication, it will prompt the user with a link to connect their account. If you want to customise the authentication flow and have more control over the user experience, see [Manual Authentication](/tool-router/manually-authenticating-users).
44 +When the agent needs authentication, it will prompt the user with a link to connect their account. If you want to customise the authentication flow and have more control over the user experience, see [Manual Authentication](/docs/authenticating-users/manually-authenticating).
45
46 <Tabs groupId="language" items={['Python', 'TypeScript']} persist>
47 <Tab value="Python">
@@ -228,7 +228,7 @@ npm install dotenv @composio/core @openai/agents zod@3
228 <Step>
229 ### Create session and run agent
230
231 -[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
231 +[Sessions](/docs/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
232
233 <Callout type="info">
234 - Set `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
@@ -236,7 +236,7 @@ npm install dotenv @composio/core @openai/agents zod@3
236 - `userId` is your user's unique identifier. See [User Management](/docs/user-management) for details.
237 </Callout>
238
239 -When the agent needs authentication, it will prompt the user with a link to connect their account. If you want to customise the authentication flow and have more control over the user experience, see [Manual Authentication](/tool-router/manually-authenticating-users).
239 +When the agent needs authentication, it will prompt the user with a link to connect their account. If you want to customise the authentication flow and have more control over the user experience, see [Manual Authentication](/docs/authenticating-users/manually-authenticating).
240
241 <Tabs groupId="language" items={['Python', 'TypeScript']} persist>
242 <Tab value="Python">
@@ -381,7 +381,7 @@ npm install dotenv @composio/core ai @ai-sdk/anthropic @ai-sdk/mcp
381 <Step>
382 ### Create session and run agent
383
384 -[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
384 +[Sessions](/docs/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
385
386 <Callout type="info">
387 - Set `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
@@ -389,7 +389,7 @@ npm install dotenv @composio/core ai @ai-sdk/anthropic @ai-sdk/mcp
389 - `userId` is your user's unique identifier. See [User Management](/docs/user-management) for details.
390 </Callout>
391
392 -When the agent needs authentication, it will prompt the user with a link to connect their account. If you want to customise the authentication flow and have more control over the user experience, see [Manual Authentication](/tool-router/manually-authenticating-users).
392 +When the agent needs authentication, it will prompt the user with a link to connect their account. If you want to customise the authentication flow and have more control over the user experience, see [Manual Authentication](/docs/authenticating-users/manually-authenticating).
393
394 ```typescript
395 import "dotenv/config";
@@ -687,19 +687,16 @@ When you run this agent, Tool Router:
687 ## Next steps
688
689 <Cards>
690 - <Card title="Session management" href="/tool-router/users-and-sessions">
690 + <Card title="Session management" href="/docs/users-and-sessions">
691 Learn about users, sessions, and how they work.
692 </Card>
693 - <Card title="Tools and toolkits" href="/tool-router/tools-and-toolkits">
693 + <Card title="Tools and toolkits" href="/docs/tools-and-toolkits">
694 Learn about tools, toolkits, and how to configure them.
695 </Card>
696 - <Card title="Manual authentication" href="/tool-router/manually-authenticating-users">
696 + <Card title="Manual authentication" href="/docs/authenticating-users/manually-authenticating">
697 Customise the authentication flow for your users.
698 </Card>
699 - <Card title="Using MCP" href="/tool-router/using-with-mcp-clients">
699 + <Card title="Using MCP" href="/docs/mcp">
700 Connect Tool Router to any MCP-compatible client.
701 </Card>
702 - <Card title="Using as a native tool" href="/tool-router/using-as-a-native-tool">
703 - Use Tool Router as a native tool with any AI framework.
704 - </Card>
702 </Cards>
docs/content/docs/quickstart.mdx
+5 -5
@@ -45,7 +45,7 @@ OPENAI_API_KEY=xxxxxxxxx
45 <Step>
46 ### Create session and run agent
47
48 -[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
48 +[Sessions](/docs/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
49
50 <Callout type="info">
51 Replace the sample user ID with your own user's identifier. See [User Management](/docs/user-management) for details.
@@ -174,7 +174,7 @@ ANTHROPIC_API_KEY=xxxxxxxxx
174 <Step>
175 ### Create session and run agent
176
177 -[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
177 +[Sessions](/docs/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
178
179 <Callout type="info">
180 Replace the sample user ID with your own user's identifier. See [User Management](/docs/user-management) for details.
@@ -300,7 +300,7 @@ OPENAI_API_KEY=xxxxxxxxx
300 <Step>
301 ### Create session and run agent
302
303 -[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
303 +[Sessions](/docs/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
304
305 <Callout type="info">
306 Replace the sample user ID with your own user's identifier. See [User Management](/docs/user-management) for details.
@@ -355,12 +355,12 @@ for await (const textPart of stream.textStream) {
355 <Cards>
356 <Card
357 title="Session management"
358 - href="/docs/tool-router/users-and-sessions"
358 + href="/docs/users-and-sessions"
359 description="Learn about users, sessions, and how they work."
360 />
361 <Card
362 title="Tools and toolkits"
363 - href="/docs/tool-router/tools-and-toolkits"
363 + href="/docs/tools-and-toolkits"
364 description="Learn about tools, toolkits, and how to configure them."
365 />
366 </Cards>
docs/content/docs/toolkits/fetching-tools-and-toolkits.mdx new
+5
@@ -0,0 +1,5 @@
1 +---
2 +title: Fetching tools and toolkits
3 +description: How to fetch and filter tools and toolkits for your AI agents
4 +---
5 +
docs/content/docs/toolkits/meta.json new
+6
@@ -0,0 +1,6 @@
1 +{
2 + "title": "Toolkits",
3 + "pages": [
4 + "fetching-tools-and-toolkits"
5 + ]
6 +}
docs/content/docs/tools-and-toolkits.mdx
+3 -3
@@ -4,7 +4,7 @@ description: Access 800+ toolkits through Tool Router
4 keywords: [available tools, browse toolkits]
5 ---
6
7 -Tool Router gives your agent access to most Composio toolkits by default. For details on configuring which toolkits are available in a session, see [Users and sessions](/tool-router/users-and-sessions#enabling-toolkits).
7 +Tool Router gives your agent access to most Composio toolkits by default. For details on configuring which toolkits are available in a session, see [Users and sessions](/docs/users-and-sessions#enabling-toolkits).
8
9 ## Toolkits and tools
10
@@ -50,7 +50,7 @@ for (const toolkit of toolkits) {
50 For details on browsing tools within toolkits and inspecting schemas, see [Fetching tools and schemas](/docs/fetching-tools).
51
52 <Callout type="info">
53 -Some toolkits require you to provide your own credentials. See [Using custom auth configs](/tool-router/using-custom-auth-configs).
53 +Some toolkits require you to provide your own credentials. See [Using custom auth configs](/docs/guides/using-custom-auth-configuration).
54 </Callout>
55
56 <Callout type="info">
@@ -77,7 +77,7 @@ const session = await composio.create("user_123");
77 </Tab>
78 </Tabs>
79
80 -Your agent can search and use tools from any toolkit. To restrict or configure which toolkits are available, see [Users and sessions](/tool-router/users-and-sessions#enabling-toolkits).
80 +Your agent can search and use tools from any toolkit. To restrict or configure which toolkits are available, see [Users and sessions](/docs/users-and-sessions#enabling-toolkits).
81
82 <Callout type="info">
83 Triggers can be used alongside Tool Router to respond to events in connected apps. See [Triggers](/docs/triggers) for setup instructions.
docs/content/docs/users-and-sessions.mdx
+3 -3
@@ -125,7 +125,7 @@ const session = await composio.create("user_123", {
125 </Tab>
126 </Tabs>
127
128 -See [White-labeling authentication](/tool-router/white-labeling-authentication) for branding, or [Using custom auth configs](/tool-router/using-custom-auth-configs) for toolkits that require your own credentials.
128 +See [White-labeling authentication](/docs/guides/white-labeling-authentication) for branding, or [Using custom auth configs](/docs/guides/using-custom-auth-configuration) for toolkits that require your own credentials.
129
130 ## Connected accounts
131
@@ -198,7 +198,7 @@ console.log(mcp.url);
198 </Tab>
199 </Tabs>
200
201 -For framework examples, see [Using with MCP clients](/tool-router/using-with-mcp-clients) or [Using as a native tool](/tool-router/using-as-a-native-tool).
201 +For framework examples, see the [Providers](/docs/providers) documentation.
202
203 ### tools()
204
@@ -252,7 +252,7 @@ const connectedAccount = await connectionRequest.waitForConnection();
252 </Tab>
253 </Tabs>
254
255 -For more details, see [Manually authenticating users](/tool-router/manually-authenticating-users).
255 +For more details, see [Manually authenticating users](/docs/authenticating-users/manually-authenticating).
256
257 ### toolkits()
258
docs/content/tool-router/index.mdx deleted
-23
@@ -1,23 +0,0 @@
1 ----
2 -title: Overview
3 -description: Give your AI agent access to thousands of tools through a unified interface
4 -keywords: [unified interface, meta-tools]
5 ----
6 -
7 -Tool Router is a unified interface that lets an agent **search**, **plan**, **authenticate**, and **execute** actions across thousands of Composio tools.
8 -
9 -Consider an agent that works across Gmail, Notion, Slack, Google Drive, and hundreds of other apps. The challenges:
10 -
11 -- **Search**: Identifying the right tool for the task
12 -- **Context Management**: Managing context for complex queries with large responses
13 -- **Authentication**: Handling authentication across all of them
14 -
15 -Tool Router exposes a set of meta-tools that handle all this complexity including search to discover the right tools, and a workbench to process results without flooding context.
16 -
17 -This is what powers complex agentic products like [Rube](https://rube.app).
18 -
19 -## Quick links
20 -
21 -- [Quickstart](/tool-router/quickstart): Build your first AI agent with Tool Router.
22 -- [Using with MCP clients](/tool-router/using-with-mcp-clients): Guides on how to use Tool Router MCP with popular MCP clients.
23 -- [Using as a native tool](/tool-router/using-as-a-native-tool): Guide on how to use Tool Router as a native tool with any AI framework.
docs/content/tool-router/meta.json deleted
-16
@@ -1,16 +0,0 @@
1 -{
2 - "title": "Tool Router",
3 - "pages": [
4 - "---Get Started---",
5 - "index",
6 - "quickstart",
7 - "---Guides---",
8 - "using-in-chat-authentication",
9 - "manually-authenticating-users",
10 - "managing-multiple-accounts",
11 - "white-labeling-authentication",
12 - "using-custom-auth-configs",
13 - "using-with-mcp-clients",
14 - "using-as-a-native-tool"
15 - ]
16 -}
docs/content/tool-router/migration-guide/beta-to-stable.mdx deleted
-113
@@ -1,113 +0,0 @@
1 ----
2 -title: Beta to Stable Migration
3 -description: Migrate from Tool Router beta to the stable version
4 -keywords: [upgrade, migrate, experimental, beta]
5 ----
6 -
7 -The stable version includes improved session management, multiple configuring options, and enhanced authentication capabilities.
8 -
9 -## The basics
10 -
11 -<Steps>
12 -<Step>
13 -### Upgrade composio package
14 -
15 -Upgrade to the latest stable version:
16 -
17 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
18 -<Tab value="Python">
19 -```bash
20 -pip install --upgrade composio
21 -```
22 -</Tab>
23 -<Tab value="TypeScript">
24 -```bash
25 -npm install @composio/core@latest
26 -```
27 -</Tab>
28 -</Tabs>
29 -</Step>
30 -
31 -<Step>
32 -### Update session creation
33 -
34 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
35 -<Tab value="Python">
36 -```python
37 -# Beta (before)
38 -session = composio.experimental.tool_router.create_session(
39 - user_id="user@example.com"
40 -)
41 -
42 -# Stable (after)
43 -session = composio.create(
44 - user_id="user@example.com"
45 -)
46 -```
47 -</Tab>
48 -<Tab value="TypeScript">
49 -```typescript
50 -// @noErrors
51 -// Beta (before)
52 -const session = await composio.experimental.toolRouter.createSession('user_123');
53 -
54 -// Stable (after)
55 -const session = await composio.create('user_123');
56 -```
57 -</Tab>
58 -</Tabs>
59 -</Step>
60 -
61 -<Step>
62 -### Moving users (optional)
63 -
64 -If you have existing users on tool router and you don't want them to authenticate again:
65 -- Tool Router will auto-detect auth configs and connected accounts it created (from the beta version).
66 -- If you have custom auth configs (not created by Tool Router):
67 - - Search for the Auth config for that connected account. See [Connected Accounts](/docs/connected-accounts) to fetch existing accounts programmatically.
68 - - While creating a session configure to use this Auth config.
69 - - You need to repeat this for each toolkit you want to enable for that session.
70 -
71 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
72 -<Tab value="Python">
73 -```python
74 -session = composio.create(
75 - user_id="user_123",
76 - auth_configs={
77 - "github": "ac_your_github_config",
78 - "slack": "ac_your_slack_config"
79 - }
80 -)
81 -```
82 -</Tab>
83 -<Tab value="TypeScript">
84 -```typescript
85 -import { Composio } from '@composio/core';
86 -const composio = new Composio({ apiKey: 'your_api_key' });
87 -// ---cut---
88 -const session = await composio.create('user_123',
89 - {
90 - authConfigs: {
91 - github: "ac_your_github_config",
92 - slack: "ac_your_slack_config",
93 - },
94 - }
95 -);
96 -```
97 -</Tab>
98 -</Tabs>
99 -</Step>
100 -
101 -<Step>
102 -### Explore new capabilities
103 -
104 -Check out these new features available in the stable version:
105 -
106 -- **[Native tools](/tool-router/using-as-a-native-tool)**: Use Tool Router with any AI framework
107 -- **Better [session](/tool-router/users-and-sessions) and [auth](/tool-router/authentication) config**
108 -- **[Multi-account support](/tool-router/managing-multiple-accounts)**: Manage multiple accounts per user seamlessly
109 -- **[Manual authentication](/tool-router/manually-authenticating-users)**: Control when and how users authenticate
110 -- **[Custom auth](/tool-router/using-custom-auth-configs)**: Support for toolkits that don't have composio managed auth
111 -- **[White labeling](/tool-router/white-labeling-authentication)**: Customize authentication screens with your branding
112 -</Step>
113 -</Steps>
docs/content/tool-router/migration-guide/meta.json deleted
-6
@@ -1,6 +0,0 @@
1 -{
2 - "title": "Migration Guides",
3 - "pages": [
4 - "beta-to-stable"
5 - ]
6 -}
docs/content/tool-router/using-as-a-native-tool.mdx deleted
-241
@@ -1,241 +0,0 @@
1 ----
2 -title: Using as a native tool
3 -description: Use Tool Router as a native tool with any AI framework
4 -keywords: [native tool, single tool, without mcp]
5 ----
6 -
7 -Tool Router can be used as a single native tool with any AI framework. The tool handles search, authentication, and execution internally.
8 -
9 -## Examples for popular frameworks
10 -
11 -Jump to examples for:
12 -- [OpenAI](#openai) - Python, TypeScript
13 -- [Vercel AI SDK](#vercel-ai-sdk) - TypeScript
14 -
15 -## OpenAI
16 -
17 -### Installation
18 -
19 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
20 -<Tab value="Python">
21 -```bash
22 -pip install python-dotenv composio composio-openai-agents openai-agents
23 -```
24 -</Tab>
25 -<Tab value="TypeScript">
26 -```bash
27 -npm install @composio/core @composio/openai-agents @openai/agents
28 -```
29 -</Tab>
30 -</Tabs>
31 -
32 -### Usage
33 -
34 -Create a Tool Router session and use it as a native tool with OpenAI Agents SDK:
35 -
36 -<Callout type="info">
37 -- Set your `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
38 -- Set your `OPENAI_API_KEY` environment variable with your [OpenAI API key](https://platform.openai.com/api-keys).
39 -</Callout>
40 -
41 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
42 -<Tab value="Python">
43 -```python
44 -from dotenv import load_dotenv
45 -from composio import Composio
46 -from agents import Agent, Runner, SQLiteSession
47 -from composio_openai_agents import OpenAIAgentsProvider
48 -
49 -load_dotenv()
50 -
51 -# Initialize Composio with OpenAI Agents provider (API key from env var COMPOSIO_API_KEY)
52 -composio = Composio(provider=OpenAIAgentsProvider())
53 -
54 -# Unique identifier of the user
55 -user_id = "user_123"
56 -
57 -# Create a session and get native tools for the user
58 -session = composio.create(user_id=user_id)
59 -tools = session.tools()
60 -
61 -# Configure OpenAI agent with Composio tools
62 -agent = Agent(
63 - name="Personal Assistant",
64 - instructions="You are a helpful personal assistant. Use Composio tools to take action.",
65 - model="gpt-5.2",
66 - tools=tools,
67 -)
68 -
69 -# Memory for multi-turn conversation
70 -memory = SQLiteSession("conversation")
71 -
72 -# Execute an initial task
73 -print("Fetching GitHub issues from the Composio repository...\n")
74 -try:
75 - result = Runner.run_sync(
76 - starting_agent=agent,
77 - input="Fetch all the open GitHub issues on the @ComposioHQ/composio repository and group them by bugs/features/docs.",
78 - session=memory,
79 - )
80 - print(f"{result.final_output}\n")
81 -except Exception as e:
82 - print(f"[Error]: {e}")
83 -
84 -# Continue with interactive conversation
85 -print("\nWhat else would you like me to do? (Type 'exit' to exit)")
86 -
87 -while True:
88 - user_input = input("You: ").strip()
89 - if user_input.lower() == "exit":
90 - break
91 -
92 - print("Assistant: ", end="", flush=True)
93 - try:
94 - result = Runner.run_sync(starting_agent=agent, input=user_input, session=memory)
95 - print(f"{result.final_output}\n")
96 - except Exception as e:
97 - print(f"\n[Error]: {e}")
98 -```
99 -</Tab>
100 -<Tab value="TypeScript">
101 -```typescript
102 -import "dotenv/config";
103 -import { Composio } from "@composio/core";
104 -import { Agent, run, MemorySession } from "@openai/agents";
105 -import { OpenAIAgentsProvider } from "@composio/openai-agents";
106 -import { createInterface } from "readline/promises";
107 -
108 -// Initialize Composio with OpenAI Agents provider (API key from env var COMPOSIO_API_KEY)
109 -const composio = new Composio({ provider: new OpenAIAgentsProvider() });
110 -
111 -// Unique identifier of the user
112 -const userId = "user_123";
113 -
114 -// Create a session and get native tools for the user
115 -const session = await composio.create(userId);
116 -const tools = await session.tools();
117 -
118 -const agent = new Agent({
119 - name: "Personal Assistant",
120 - instructions: "You are a helpful personal assistant. Use Composio tools to take action.",
121 - model: "gpt-5.2",
122 - tools,
123 -});
124 -
125 -// Create a memory session for persistent multi-turn conversation
126 -const memory = new MemorySession();
127 -
128 -// Execute an initial task
129 -console.log("Fetching GitHub issues from the Composio repository...\n");
130 -try {
131 - const initialResult = await run(
132 - agent,
133 - "Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs.",
134 - { session: memory }
135 - );
136 - console.log(`${initialResult.finalOutput}\n`);
137 -} catch (error) {
138 - console.error("[Error]:", error instanceof Error ? error.message : error);
139 -}
140 -
141 -// Continue with interactive conversation
142 -const readline = createInterface({ input: process.stdin, output: process.stdout });
143 -
144 -console.log(`
145 -What else would you like me to do?
146 -(Type 'exit' to exit)
147 -`);
148 -
149 -
150 -while (true) {
151 - const input = (await readline.question("You: ")).trim();
152 - if (input.toLowerCase() === "exit") break;
153 -
154 - console.log("Assistant: ");
155 -
156 - try {
157 - const result = await run(agent, input, { session: memory });
158 - console.log(`${result.finalOutput}\n`);
159 - } catch (error) {
160 - console.error("\n[Error]:", error instanceof Error ? error.message : error);
161 - }
162 -}
163 -readline.close();
164 -```
165 -</Tab>
166 -</Tabs>
167 -
168 -## Vercel AI SDK
169 -
170 -### Installation
171 -
172 -```bash
173 -npm install @composio/core @composio/vercel ai @ai-sdk/anthropic
174 -```
175 -
176 -### Usage
177 -
178 -Create a Tool Router session and use it as a native tool with Vercel AI SDK:
179 -
180 -<Callout type="info">
181 -- Set your `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
182 -- Set your `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://console.anthropic.com/settings/keys).
183 -</Callout>
184 -
185 -```typescript
186 -import "dotenv/config";
187 -import { anthropic } from "@ai-sdk/anthropic";
188 -import { Composio } from "@composio/core";
189 -import { VercelProvider } from "@composio/vercel";
190 -import { stepCountIs, streamText } from "ai";
191 -
192 -// Initialize Composio with Vercel provider (API key from env var COMPOSIO_API_KEY)
193 -const composio = new Composio({ provider: new VercelProvider() });
194 -
195 -// Unique identifier of the user
196 -const userId = "user_123";
197 -
198 -// Create a session and get native tools for the user
199 -const session = await composio.create(userId);
200 -const tools = await session.tools();
201 -
202 -console.log("Fetching GitHub issues from the Composio repository...");
203 -
204 -// Stream the response with tool calling
205 -const stream = await streamText({
206 - system: "You are a helpful personal assistant. Use Composio tools to take action.",
207 - model: anthropic("claude-sonnet-4-5"),
208 - prompt: "Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs.",
209 - stopWhen: stepCountIs(10),
210 - onStepFinish: (step) => {
211 - for (const toolCall of step.toolCalls) {
212 - console.log(`[Using tool: ${toolCall.toolName}]`);
213 - }
214 - },
215 - tools,
216 -});
217 -
218 -for await (const textPart of stream.textStream) {
219 - process.stdout.write(textPart);
220 -}
221 -
222 -console.log("\n\n---");
223 -console.log("Tip: If prompted to authenticate, complete the auth flow and run again.");
224 -```
225 -
226 -## Next steps
227 -
228 -<Cards>
229 - <Card title="Quickstart" href="/tool-router/quickstart">
230 - See both MCP and native tool in action
231 - </Card>
232 - <Card title="Using with MCP" href="/tool-router/using-with-mcp-clients">
233 - Use Tool Router with MCP-compatible clients
234 - </Card>
235 - <Card title="Authentication" href="/tool-router/authentication">
236 - Learn about authentication options
237 - </Card>
238 - <Card title="Session management" href="/tool-router/users-and-sessions">
239 - Configure sessions for your users
240 - </Card>
241 -</Cards>
docs/content/tool-router/using-with-mcp-clients.mdx deleted
-406
@@ -1,406 +0,0 @@
1 ----
2 -title: Using with MCP clients
3 -description: Use Tool Router as an MCP server with any MCP client
4 -keywords: [mcp server, http transport]
5 ----
6 -
7 -Every Tool Router session provides a unique MCP server URL. This URL exposes the exact session you created - with the specific user, toolkits, and auth configs you configured. Any MCP client that supports HTTP transport can connect using just the URL and your API key.
8 -
9 -## Examples for popular frameworks
10 -
11 -Jump to examples for:
12 -- [Claude Agent SDK](#claude-agent-sdk) - Python, TypeScript
13 -- [OpenAI Agents SDK](#openai-agents-sdk) - Python, TypeScript
14 -- [Vercel AI SDK](#vercel-ai-sdk) - TypeScript
15 -
16 -## Claude Agent SDK
17 -
18 -### Installation
19 -
20 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
21 -<Tab value="Python">
22 -```bash
23 -pip install python-dotenv composio claude-agent-sdk
24 -```
25 -</Tab>
26 -<Tab value="TypeScript">
27 -```bash
28 -npm install dotenv @composio/core @anthropic-ai/claude-agent-sdk
29 -```
30 -</Tab>
31 -</Tabs>
32 -
33 -### Usage
34 -
35 -Create a Tool Router session and execute tasks with Claude:
36 -
37 -<Callout type="info">
38 -- Set your `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
39 -- Set your `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://platform.claude.com/settings/keys).
40 -</Callout>
41 -
42 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
43 -<Tab value="Python">
44 -```python
45 -import asyncio
46 -from dotenv import load_dotenv
47 -from claude_agent_sdk.client import ClaudeSDKClient
48 -from claude_agent_sdk.types import (
49 - ClaudeAgentOptions,
50 - AssistantMessage,
51 - TextBlock,
52 - ToolUseBlock,
53 -)
54 -from composio import Composio
55 -
56 -load_dotenv()
57 -
58 -# Initialize Composio (API key from env var COMPOSIO_API_KEY or pass explicitly)
59 -composio = Composio()
60 -
61 -# Unique identifier of the user
62 -user_id = "user_123"
63 -# Create a tool router session for the user
64 -session = composio.create(user_id=user_id)
65 -
66 -# Configure Claude with Composio MCP server
67 -options = ClaudeAgentOptions(
68 - system_prompt=(
69 - "You are a helpful assistant with access to external tools. "
70 - "Always use the available tools to complete user requests."
71 - ),
72 - mcp_servers={
73 - "composio": {
74 - "type": "http",
75 - "url": session.mcp.url,
76 - "headers": session.mcp.headers, # Authentication headers for the Composio MCP server
77 - }
78 - },
79 - permission_mode="bypassPermissions", # Auto-approve tools (demo only)
80 -)
81 -
82 -async def main():
83 - print("""
84 -What task would you like me to help you with?
85 -I can use tools like Gmail, GitHub, Linear, Notion, and more.
86 -(Type 'exit' to exit)
87 -Example tasks:
88 - • 'Summarize my emails from today'
89 - • 'List all open issues on the composio github repository and create a notion page with the issues'
90 -""")
91 -
92 - async with ClaudeSDKClient(options) as client:
93 - # Multi-turn conversation with agentic tool calling
94 - while True:
95 - user_input = input("\nYou: ").strip()
96 - if user_input.lower() == "exit":
97 - break
98 -
99 - print("\nClaude: ", end="", flush=True)
100 - try:
101 - await client.query(user_input)
102 - async for msg in client.receive_response():
103 - if isinstance(msg, AssistantMessage):
104 - for block in msg.content:
105 - if isinstance(block, ToolUseBlock):
106 - print(f"\n[Using tool: {block.name}]", end="")
107 - elif isinstance(block, TextBlock):
108 - print(block.text, end="", flush=True)
109 - except Exception as e:
110 - print(f"\n[Error]: {e}")
111 -
112 -if __name__ == "__main__":
113 - asyncio.run(main())
114 -```
115 -</Tab>
116 -<Tab value="TypeScript">
117 -```typescript
118 -import "dotenv/config";
119 -import { query, type Options } from "@anthropic-ai/claude-agent-sdk";
120 -import { Composio } from "@composio/core";
121 -import { createInterface } from "readline/promises";
122 -
123 -// Initialize Composio (API key from env var COMPOSIO_API_KEY or pass explicitly: { apiKey: "your-key" })
124 -const composio = new Composio();
125 -
126 -// Unique identifier of the user
127 -const userId = "user_123";
128 -
129 -// Create a tool router session for the user
130 -const session = await composio.create(userId);
131 -
132 -const options: Options = {
133 - systemPrompt: `You are a helpful assistant with access to external tools. ` +
134 - `Always use the available tools to complete user requests.`,
135 - mcpServers: {
136 - composio: {
137 - type: "http",
138 - url: session.mcp.url,
139 - headers: session.mcp.headers // Authentication headers for the Composio MCP server
140 - },
141 - },
142 - permissionMode: "bypassPermissions", // Auto-approve tools (demo only - use "default" in production)
143 -};
144 -
145 -// Set up interactive terminal input/output for the conversation
146 -const readline = createInterface({ input: process.stdin, output: process.stdout });
147 -
148 -console.log(`
149 -What task would you like me to help you with?
150 -I can use tools like Gmail, GitHub, Linear, Notion, and more.
151 -(Type 'exit' to exit)
152 -Example tasks:
153 - • 'Summarize my emails from today'
154 - • 'List all open issues on the composio github repository and create a notion page with the issues'
155 -`);
156 -
157 -let isFirstQuery = true;
158 -
159 -// Multi-turn conversation with agentic tool calling
160 -while (true) {
161 - const answer = await readline.question('You: ');
162 - const input = answer.trim();
163 - if (input.toLowerCase() === "exit") break;
164 -
165 - process.stdout.write("Claude: ");
166 -
167 - const queryOptions = isFirstQuery ? options : { ...options, continue: true };
168 - isFirstQuery = false;
169 -
170 - try {
171 - for await (const stream of query({ prompt: input, options: queryOptions })) {
172 - // Only process assistant messages (the SDK also sends result/error messages)
173 - if (stream.type === "assistant") {
174 - const { content } = stream.message;
175 - for (const block of content) {
176 - if (block.type === "tool_use") {
177 - process.stdout.write(`\n[Using tool: ${block.name}]`);
178 - } else if (block.type === "text") {
179 - process.stdout.write(block.text);
180 - }
181 - }
182 - }
183 - }
184 - } catch (error) {
185 - console.error("\n[Error]:", error instanceof Error ? error.message : error);
186 - }
187 - process.stdout.write("\n");
188 -}
189 -
190 -readline.close();
191 -```
192 -</Tab>
193 -</Tabs>
194 -
195 -## OpenAI Agents SDK
196 -
197 -### Installation
198 -
199 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
200 -<Tab value="Python">
201 -```bash
202 -pip install python-dotenv composio openai-agents
203 -```
204 -</Tab>
205 -<Tab value="TypeScript">
206 -```bash
207 -npm install dotenv @composio/core @openai/agents zod@3
208 -```
209 -</Tab>
210 -</Tabs>
211 -
212 -### Usage
213 -
214 -Create a Tool Router session and execute tasks with OpenAI agents:
215 -
216 -<Callout type="info">
217 -- Set `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
218 -- Set `OPENAI_API_KEY` environment variable with your [OpenAI API key](https://platform.openai.com/api-keys).
219 -</Callout>
220 -
221 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
222 -<Tab value="Python">
223 -```python
224 -from dotenv import load_dotenv
225 -from composio import Composio
226 -from agents import Agent, Runner, HostedMCPTool
227 -
228 -load_dotenv()
229 -
230 -# Initialize Composio (API key from env var COMPOSIO_API_KEY)
231 -composio = Composio()
232 -# Unique identifier of the user
233 -user_id = "user_123"
234 -
235 -# Create a Tool Router session for the user
236 -session = composio.create(user_id=user_id)
237 -
238 -# Configure OpenAI agent with Composio MCP server
239 -agent = Agent(
240 - name="Personal Assistant",
241 - instructions="You are a helpful personal assistant. Use Composio tools to take action.",
242 - model="gpt-5.2",
243 - tools=[
244 - HostedMCPTool(
245 - tool_config={
246 - "type": "mcp",
247 - "server_label": "composio",
248 - "server_url": session.mcp.url,
249 - "require_approval": "never",
250 - "headers": session.mcp.headers,
251 - }
252 - )
253 - ],
254 -)
255 -
256 -# Execute the task
257 -print("Fetching GitHub issues from the Composio repository @ComposioHQ/composio...\n")
258 -try:
259 - result = Runner.run_sync(
260 - starting_agent=agent,
261 - input="Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs.",
262 - )
263 - print(result.final_output)
264 -except Exception as e:
265 - print(f"[Error]: {e}")
266 -
267 -print("\n\n---")
268 -print("Tip: If prompted to authenticate, complete the auth flow and run again.")
269 -```
270 -</Tab>
271 -<Tab value="TypeScript">
272 -```typescript
273 -import "dotenv/config";
274 -import { Composio } from "@composio/core";
275 -import { Agent, hostedMcpTool, run, MemorySession } from "@openai/agents";
276 -import { createInterface } from "readline/promises";
277 -
278 -// Initialize Composio (API key from env var COMPOSIO_API_KEY or pass explicitly: { apiKey: "your-key" })
279 -const composio = new Composio();
280 -
281 -// Unique identifier of the user
282 -const userId = "user_123";
283 -
284 -// Create a tool router session for the user
285 -const session = await composio.create(userId);
286 -
287 -const agent = new Agent({
288 - name: "Personal Assistant",
289 - instructions: "You are a helpful personal assistant. Use Composio tools to take action.",
290 - model: "gpt-5.2",
291 - tools: [
292 - hostedMcpTool({
293 - serverLabel: "composio",
294 - serverUrl: session.mcp.url,
295 - headers: session.mcp.headers, // Authentication headers for the Composio MCP server
296 - }),
297 - ],
298 -});
299 -
300 -// Create a memory session for persistent multi-turn conversation
301 -const memory = new MemorySession();
302 -
303 -// Execute an initial task
304 -console.log("Fetching GitHub issues from the Composio repository...\n");
305 -try {
306 - const initialResult = await run(
307 - agent,
308 - "Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs.",
309 - { session: memory }
310 - );
311 - console.log(`${initialResult.finalOutput}\n`);
312 -} catch (error) {
313 - console.error("[Error]:", error instanceof Error ? error.message : error);
314 -}
315 -
316 -// Continue with interactive conversation
317 -const readline = createInterface({ input: process.stdin, output: process.stdout });
318 -
319 -console.log(`
320 -What else would you like me to do?
321 -(Type 'exit' to exit)
322 -`);
323 -
324 -while (true) {
325 - const input = (await readline.question("You: ")).trim();
326 - if (input.toLowerCase() === "exit") break;
327 -
328 - console.log("Assistant: ");
329 -
330 - try {
331 - const result = await run(agent, input, { session: memory });
332 - console.log(`${result.finalOutput}\n`);
333 - } catch (error) {
334 - console.error("\n[Error]:", error instanceof Error ? error.message : error);
335 - }
336 -}
337 -readline.close();
338 -```
339 -</Tab>
340 -</Tabs>
341 -
342 -## Vercel AI SDK
343 -
344 -### Installation
345 -
346 -```bash
347 -npm install dotenv @composio/core ai @ai-sdk/anthropic @ai-sdk/mcp
348 -```
349 -
350 -### Usage
351 -
352 -Use Tool Router with Vercel AI SDK's `generateText` for single completions:
353 -
354 -<Callout type="info">
355 -- Set `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
356 -- Set `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://platform.claude.com/settings/keys).
357 -</Callout>
358 -
359 -```typescript
360 -import "dotenv/config";
361 -import { anthropic } from "@ai-sdk/anthropic";
362 -import { experimental_createMCPClient as createMCPClient } from "@ai-sdk/mcp";
363 -import { Composio } from "@composio/core";
364 -import { stepCountIs, streamText } from "ai";
365 -
366 -// Initialize Composio (API key from env var COMPOSIO_API_KEY or pass explicitly: { apiKey: "your-key" })
367 -const composio = new Composio();
368 -
369 -// Unique identifier of the user
370 -const userId = "user_123";
371 -
372 -// Create a tool router session for the user
373 -const { mcp } = await composio.create(userId);
374 -
375 -// Create an MCP client to connect to the Composio tool router
376 -const client = await createMCPClient({
377 - transport: {
378 - type: "http",
379 - url: mcp.url,
380 - headers: mcp.headers, // Authentication headers for the Composio MCP server
381 - },
382 -});
383 -const tools = await client.tools();
384 -
385 -console.log("Summarizing your emails from today");
386 -
387 -const stream = await streamText({
388 - system: "You are a helpful personal assistant. Use Composio tools to take action.",
389 - model: anthropic("claude-sonnet-4-5"),
390 - prompt: "Summarize my emails from today",
391 - stopWhen: stepCountIs(10),
392 - onStepFinish: (step) => {
393 - for (const toolCall of step.toolCalls) {
394 - console.log(`[Using tool: ${toolCall.toolName}]`);
395 - }
396 - },
397 - tools,
398 -});
399 -
400 -for await (const textPart of stream.textStream) {
401 - process.stdout.write(textPart);
402 -}
403 -
404 -console.log("\n\n---");
405 -console.log("Tip: If prompted to authenticate, complete the auth flow and run again.")
406 -```
docs/lib/layout.shared.tsx
-5
@@ -39,11 +39,6 @@ export function baseOptions(): BaseLayoutProps {
39 url: '/docs',
40 active: 'nested-url',
41 },
42 - {
43 - text: 'Tool Router',
44 - url: '/tool-router',
45 - active: 'nested-url',
46 - },
42 {
43 text: 'Toolkits',
44 url: '/toolkits',
docs/lib/source.ts
+1 -7
@@ -1,4 +1,4 @@
1 -import { docs, toolRouter, reference, examples, toolkits, changelog } from 'fumadocs-mdx:collections/server';
1 +import { docs, reference, examples, toolkits, changelog } from 'fumadocs-mdx:collections/server';
2 import { type InferPageType, loader, multiple } from 'fumadocs-core/source';
3 import { lucideIconsPlugin } from 'fumadocs-core/source/lucide-icons';
4 import { openapi } from './openapi';
@@ -11,12 +11,6 @@ export const source = loader({
11 plugins: [lucideIconsPlugin()],
12 });
13
14 -export const toolRouterSource = loader({
15 - baseUrl: '/tool-router',
16 - source: toolRouter.toFumadocsSource(),
17 - plugins: [lucideIconsPlugin()],
18 -});
19 -
14 // Combined reference source with MDX pages and OpenAPI-generated pages
15 const openapiPages = await openapiSource(openapi, {
16 groupBy: 'tag',
docs/next.config.mjs
+42 -1
@@ -30,9 +30,19 @@ const config = {
30 destination: '/docs',
31 permanent: true,
32 },
33 + {
34 + source: '/tool-router',
35 + destination: '/docs/quickstart',
36 + permanent: true,
37 + },
38 {
39 source: '/tool-router/overview',
35 - destination: '/tool-router',
40 + destination: '/docs/quickstart',
41 + permanent: true,
42 + },
43 + {
44 + source: '/tool-router/quickstart',
45 + destination: '/docs/quickstart-tool-router',
46 permanent: true,
47 },
48 // Core concepts moved from tool-router to docs
@@ -56,6 +66,37 @@ const config = {
66 destination: '/docs/tools-and-toolkits',
67 permanent: true,
68 },
69 + // Authentication pages moved from tool-router to docs
70 + {
71 + source: '/tool-router/using-in-chat-authentication',
72 + destination: '/docs/authenticating-users/in-chat-authentication',
73 + permanent: true,
74 + },
75 + {
76 + source: '/tool-router/manually-authenticating-users',
77 + destination: '/docs/authenticating-users/manually-authenticating',
78 + permanent: true,
79 + },
80 + {
81 + source: '/tool-router/using-custom-auth-configs',
82 + destination: '/docs/guides/using-custom-auth-configuration',
83 + permanent: true,
84 + },
85 + {
86 + source: '/docs/authenticating-users/using-custom-auth-configs',
87 + destination: '/docs/guides/using-custom-auth-configuration',
88 + permanent: true,
89 + },
90 + {
91 + source: '/tool-router/white-labeling-authentication',
92 + destination: '/docs/guides/white-labeling-authentication',
93 + permanent: true,
94 + },
95 + {
96 + source: '/tool-router/managing-multiple-accounts',
97 + destination: '/docs/guides/managing-multiple-connected-accounts',
98 + permanent: true,
99 + },
100 // Provider redirects (old fern URLs -> new docs URLs)
101 {
102 source: '/providers/openai',
docs/scripts/validate-links.ts
+1 -7
@@ -7,7 +7,6 @@ import {
7 import type { InferPageType } from 'fumadocs-core/source';
8 import {
9 source,
10 - toolRouterSource,
10 referenceSource,
11 examplesSource,
12 toolkitsSource,
@@ -15,7 +14,6 @@ import {
14
15 type AnySource =
16 | typeof source
18 - | typeof toolRouterSource
17 | typeof referenceSource
18 | typeof examplesSource
19 | typeof toolkitsSource;
@@ -29,10 +27,6 @@ async function checkLinks() {
27 value: { slug: page.slugs },
28 hashes: getHeadings(page),
29 })),
32 - 'tool-router/[[...slug]]': toolRouterSource.getPages().map((page) => ({
33 - value: { slug: page.slugs },
34 - hashes: getHeadings(page),
35 - })),
30 'reference/[[...slug]]': referenceSource.getPages().map((page) => ({
31 value: { slug: page.slugs },
32 hashes: getHeadings(page),
@@ -80,7 +74,7 @@ function getHeadings({ data }: InferPageType<AnySource>): string[] {
74 }
75
76 async function getFiles(): Promise<FileObject[]> {
83 - const sources = [source, toolRouterSource, referenceSource, examplesSource, toolkitsSource];
77 + const sources = [source, referenceSource, examplesSource, toolkitsSource];
78 const allFiles: FileObject[] = [];
79
80 for (const src of sources) {
docs/source.config.ts
-10
@@ -31,16 +31,6 @@ export const docs = defineDocs({
31 },
32 });
33
34 -export const toolRouter = defineDocs({
35 - dir: 'content/tool-router',
36 - docs: {
37 - schema: docsSchema,
38 - },
39 - meta: {
40 - schema: metaSchema,
41 - },
42 -});
43 -
34 // Reference docs use defineCollections with custom mdxOptions to exclude twoslash
35 // (SDK reference docs are auto-generated and don't need type checking)
36 export const reference = defineDocs({