Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
quickstart changes
Sushmithamallesh1648d300cbf5
diff --git a/fern/pages/src/tool-router/quickstart.mdx b/fern/pages/src/tool-router/quickstart.mdxindex aef9fb899..4833b6c7d 100644--- a/fern/pages/src/tool-router/quickstart.mdx+++ b/fern/pages/src/tool-router/quickstart.mdx@@ -9,264 +9,304 @@ hide-nav-links: falseBuild an agent that summarizes your Gmail inbox.<Tabs>-<Tab title="OpenAI (Python)">+<Tab title="OpenAI (TypeScript)"><Steps><Step title="Install Composio SDK">```bash-pip install composio openai-agents composio-openai-agents+npm install @composio/core @openai/agents```</Step>-<Step title="Create session for user">-Sessions are ephemeral, user-scoped and manage connections and tools for that user. See [Session Management](/docs/user-management) and [Configuring Toolkits](/tool-router/configuring-toolkits).+<Step title="Create session and run agent">+[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.<Info>-`your-api-key`: Your Composio API key from the [dashboard](https://platform.composio.dev/?next_page=/settings).-`pg-user-550e8400-e29b-41d4`: The [ID of the user](/docs/user-management) in your system.+Replace `your-composio-api-key` with your Composio API key from the [settings](https://platform.composio.dev/?next_page=/settings) page.</Info>-```python-from composio import Composio-from composio_openai_agents import OpenAIAgentsProvider-composio = Composio(- api_key="your-api-key",- provider=OpenAIAgentsProvider()-)+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).-# Create a session for a user-session = composio.create(user_id="pg-user-550e8400-e29b-41d4")-```-</Step>+```typescript+import { Composio } from "@composio/core";+import { Agent, run, hostedMcpTool } from "@openai/agents";-<Step title="Run agent">-When the agent needs authentication, it will prompt the user to connect. To pre-authenticate users, see [Manual Authentication](/tool-router/manual-authentication).-```python-from agents import Agent, Runner+const composio = new Composio({ apiKey: "your-composio-api-key" });-agent = Agent(- name="Personal Assistant",- instructions="You are a helpful personal assistant.",- tools=session.tools()-)+console.log("Creating Tool Router session...");+const { mcp } = await composio.create("pg-user-550e8400-e29b-41d4");+console.log(`Tool Router session created: ${mcp.url}`);-result = Runner.run_sync(- agent,- "Summarize all the emails in my Gmail inbox today"-)-print(result.final_output)+const agent = new Agent({+ name: "Personal Assistant",+ instructions: "You are a helpful personal assistant.",+ tools: [+ hostedMcpTool({+ serverLabel: "composio",+ serverUrl: mcp.url,+ headers: {+ "x-api-key": "your-composio-api-key",+ },+ }),+ ],+});++console.log("Running the Open AI agent to fetch gmail inbox")+const result = await run(+ agent,+ "Summarize all the emails in my Gmail inbox today"+);+console.log(result.finalOutput);```-To use OpenAI Agents SDK with Tool Router MCP instead, see [Using with MCP Clients](/tool-router/using-with-mcp-clients#openai).+<Info>+`pg-user-550e8400-e29b-41d4` is a placeholder for your user's ID. See [User Management](/docs/user-management) for details.+</Info>++To use OpenAI Agents SDK with Tool Router as native tools instead, see [Using as Native Tools](/tool-router/using-as-native-tools#openai).</Step></Steps></Tab>-<Tab title="OpenAI (TypeScript)">+<Tab title="Vercel AI SDK"><Steps><Step title="Install Composio SDK">```bash-npm install @composio/core @composio/openai-agents @openai/agents+npm install @composio/core ai @ai-sdk/openai @ai-sdk/mcp```</Step>-<Step title="Create session for user">-Sessions are ephemeral, user-scoped and manage connections and tools for that user. See [Session Management](/docs/user-management) and [Configuring Toolkits](/tool-router/configuring-toolkits).+<Step title="Create session and run agent">+[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.<Info>-`your-api-key`: Your Composio API key from the [dashboard](https://platform.composio.dev/?next_page=/settings).-`pg-user-550e8400-e29b-41d4`: The [ID of the user](/docs/user-management) in your system.+Replace `your-composio-api-key` with your Composio API key from the [settings](https://platform.composio.dev/?next_page=/settings) page.</Info>++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).+```typescript+import { openai } from "@ai-sdk/openai";+import { experimental_createMCPClient as createMCPClient } from "@ai-sdk/mcp";import { Composio } from "@composio/core";-import { OpenAIAgentsProvider } from "@composio/openai-agents";+import { stepCountIs, streamText } from "ai";-const composio = new Composio({- apiKey: "your-api-key",- provider: new OpenAIAgentsProvider(),-});+const composio = new Composio({ apiKey: "your-composio-api-key" });-// Create a session for a user-const { tools } = await composio.create("pg-user-550e8400-e29b-41d4");-```-</Step>+console.log("Creating Tool Router session...");+const { mcp } = await composio.create("pg-user-550e8400-e29b-41d4");+console.log(`Tool Router session created: ${mcp.url}`);++const client = await createMCPClient({+ transport: {+ type: "http",+ url: mcp.url,+ headers: {+ "x-api-key": "your-composio-api-key",+ },+ },+});-<Step title="Run agent">-When the agent needs authentication, it will prompt the user to connect. To pre-authenticate users, see [Manual Authentication](/tool-router/manual-authentication).-```typescript-import { Agent, run } from "@openai/agents";+const tools = await client.tools();-const agent = new Agent({- name: "Personal Assistant",- instructions: "You are a helpful personal assistant.",- tools: await tools(),+const stream = await streamText({+ model: openai("gpt-5"),+ prompt: "Summarize all the emails in my Gmail inbox today",+ stopWhen: stepCountIs(10),+ onStepFinish: (step) => {+ if (step.toolCalls.length > 0) {+ for (const toolCall of step.toolCalls) {+ console.log(`Executed ${toolCall.toolName}`);+ }+ }+ },+ tools,});-const result = await run(- agent,- "Summarize all the emails in my Gmail inbox today"-);-console.log(result.finalOutput);+for await (const textPart of stream.textStream) {+ process.stdout.write(textPart);+}```-To use OpenAI Agents SDK with Tool Router MCP instead, see [Using with MCP Clients](/tool-router/using-with-mcp-clients#openai).+<Info>+`pg-user-550e8400-e29b-41d4` is a placeholder for your user's ID. See [User Management](/docs/user-management) for details.+</Info>++To use Vercel AI SDK with Tool Router as native tools instead, see [Using as Native Tools](/tool-router/using-as-native-tools#vercel).</Step></Steps></Tab>-<Tab title="Anthropic (Python)">+{/* <Tab title="Anthropic (TypeScript)"><Steps><Step title="Install Composio SDK">```bash-pip install composio anthropic-agents+npm install @composio/core @anthropic-ai/claude-agent-sdk```</Step>-<Step title="Create session for user">-Sessions are ephemeral, user-scoped and manage connections and tools for that user. See [Session Management](/docs/user-management) and [Configuring Toolkits](/tool-router/configuring-toolkits).+<Step title="Create session and run agent">+[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.<Info>-`your-api-key`: Your Composio API key from the [dashboard](https://platform.composio.dev/?next_page=/settings).-`pg-user-550e8400-e29b-41d4`: The [ID of the user](/docs/user-management) in your system.+Replace `your-composio-api-key` with your Composio API key from the [settings](https://platform.composio.dev/?next_page=/settings) page.</Info>-```python-from composio import Composio-composio = Composio(api_key="your-api-key")+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).-# Create a session for a user-session = composio.create(user_id="pg-user-550e8400-e29b-41d4")-```-</Step>+```typescript+import { Composio } from "@composio/core";+import { query } from "@anthropic-ai/claude-agent-sdk";-<Step title="Run agent">-When the agent needs authentication, it will prompt the user to connect. To pre-authenticate users, see [Manual Authentication](/tool-router/manual-authentication).-```python-from anthropic_agents import Agent, run+const composio = new Composio({ apiKey: "your-composio-api-key" });-agent = Agent(- name="Personal Assistant",- instructions="You are a helpful personal assistant.",- mcp_servers=[session.mcp.url]-)+console.log("Creating Tool Router session...");+const { mcp } = await composio.create("pg-user-550e8400-e29b-41d4");+console.log(`Tool Router session created: ${mcp.url}`);-result = run(- agent,- "Summarize all the emails in my Gmail inbox today"-)-print(result.final_output)+console.log("Waiting for agent response...");+for await (const message of query({+ prompt: "Summarize all the emails in my Gmail inbox today",+ options: {+ systemPrompt: "You are a helpful personal assistant.",+ mcpServers: {+ composio: {+ type: "http",+ url: mcp.url,+ headers: { "x-api-key": "your-composio-api-key" },+ },+ },+ },+})) {+ if (message.type === "result" && message.subtype === "success") {+ console.log(message.result);+ }+}```+<Info>+`pg-user-550e8400-e29b-41d4` is a placeholder for your user's ID. See [User Management](/docs/user-management) for details.+</Info>+To use Anthropic Agents SDK with Tool Router as native tools instead, see [Using as Native Tools](/tool-router/using-as-native-tools#anthropic).</Step></Steps></Tab>-<Tab title="Anthropic (TypeScript)">+<Tab title="OpenAI (Python)"><Steps><Step title="Install Composio SDK">```bash-npm install @composio/core @anthropic-ai/agent+pip install composio openai-agents```</Step>-<Step title="Create session for user">-Sessions are ephemeral, user-scoped and manage connections and tools for that user. See [Session Management](/docs/user-management) and [Configuring Toolkits](/tool-router/configuring-toolkits).+<Step title="Create session and run agent">+[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.<Info>-`your-api-key`: Your Composio API key from the [dashboard](https://platform.composio.dev/?next_page=/settings).-`pg-user-550e8400-e29b-41d4`: The [ID of the user](/docs/user-management) in your system.+Replace `your-composio-api-key` with your Composio API key from the [settings](https://platform.composio.dev/?next_page=/settings) page.</Info>-```typescript-import { Composio } from "@composio/core";-const composio = new Composio({ apiKey: "your-api-key" });+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).-// Create a session for a user-const { mcp } = await composio.create("pg-user-550e8400-e29b-41d4");-```-</Step>+```python+from composio import Composio+from agents import Agent, Runner, HostedMCPTool-<Step title="Run agent">-When the agent needs authentication, it will prompt the user to connect. To pre-authenticate users, see [Manual Authentication](/tool-router/manual-authentication).-```typescript-import { Agent, run } from "@anthropic-ai/agent";+composio = Composio(api_key="your-composio-api-key")-const agent = new Agent({- name: "Personal Assistant",- instructions: "You are a helpful personal assistant.",- mcpServers: [mcp.url],-});+session = composio.create(user_id="pg-user-550e8400-e29b-41d4")-const result = await run(- agent,- "Summarize all the emails in my Gmail inbox today"-);-console.log(result.finalOutput);+agent = Agent(+ name="Personal Assistant",+ instructions="You are a helpful personal assistant.",+ tools=[+ HostedMCPTool(+ tool_config={+ "type": "mcp",+ "server_label": "composio",+ "server_url": session.mcp.url,+ "require_approval": "never",+ "headers": {+ "x-api-key": "your-composio-api-key",+ },+ }+ )+ ],+)++result = Runner.run_sync(+ agent,+ "Summarize all the emails in my Gmail inbox today"+)+print(result.final_output)```-To use Anthropic Agents SDK with Tool Router as native tools instead, see [Using as Native Tools](/tool-router/using-as-native-tools#anthropic).+<Info>+`pg-user-550e8400-e29b-41d4` is a placeholder for your user's ID. See [User Management](/docs/user-management) for details.+</Info>++To use OpenAI Agents SDK with Tool Router as native tools instead, see [Using as Native Tools](/tool-router/using-as-native-tools#openai).</Step></Steps></Tab>-<Tab title="Vercel AI SDK">+<Tab title="Anthropic (Python)"><Steps><Step title="Install Composio SDK">```bash-npm install @composio/core @composio/vercel ai @ai-sdk/openai+pip install composio anthropic-agents```</Step>-<Step title="Create session for user">-Sessions are ephemeral, user-scoped and manage connections and tools for that user. See [Session Management](/docs/user-management) and [Configuring Toolkits](/tool-router/configuring-toolkits).+<Step title="Create session and run agent">+[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.<Info>-`your-api-key`: Your Composio API key from the [dashboard](https://platform.composio.dev/?next_page=/settings).-`pg-user-550e8400-e29b-41d4`: The [ID of the user](/docs/user-management) in your system.+Replace `your-composio-api-key` with your Composio API key from the [settings](https://platform.composio.dev/?next_page=/settings) page.</Info>-```typescript-import { Composio } from "@composio/core";-import { VercelProvider } from "@composio/vercel";-const composio = new Composio({- apiKey: "your-api-key",- provider: new VercelProvider(),-});+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).-// Create a session for a user-const { tools } = await composio.create("pg-user-550e8400-e29b-41d4");-```-</Step>+```python+from composio import Composio+from anthropic_agents import Agent, run-<Step title="Run agent">-When the agent needs authentication, it will prompt the user to connect. To pre-authenticate users, see [Manual Authentication](/tool-router/manual-authentication).-```typescript-import { generateText } from "ai";-import { openai } from "@ai-sdk/openai";+composio = Composio(api_key="your-composio-api-key")-const result = await generateText({- model: openai("gpt-4o"),- tools: await tools(),- prompt: "Summarize all the emails in my Gmail inbox today",-});+session = composio.create(user_id="pg-user-550e8400-e29b-41d4")-console.log(result.text);+agent = Agent(+ name="Personal Assistant",+ instructions="You are a helpful personal assistant.",+ mcp_servers=[session.mcp.url]+)++result = run(+ agent,+ "Summarize all the emails in my Gmail inbox today"+)+print(result.final_output)```-To use Vercel AI SDK with Tool Router MCP instead, see [Using with MCP Clients](/tool-router/using-with-mcp-clients#vercel).+<Info>+`pg-user-550e8400-e29b-41d4` is a placeholder for your user's ID. See [User Management](/docs/user-management) for details.+</Info>++To use Anthropic Agents SDK with Tool Router as native tools instead, see [Using as Native Tools](/tool-router/using-as-native-tools#anthropic).</Step></Steps>-</Tab>+</Tab> */}</Tabs>## What just happened?@@ -277,16 +317,19 @@ When you ran this agent, Tool Router handled everything behind the scenes:2. **[Authentication](/tool-router/authentication)** - Prompted you to connect your Gmail account3. **[Execution](/tool-router/tool-execution)** - Fetched your emails and processed results efficiently-All you wrote was a prompt. Tool Router figured out the rest.+All you wrote was a prompt. Tool Router handled the rest!## Next steps-<CardGroup cols={3}>- <Card title="Configure toolkits" href="/tool-router/configuring-toolkits">- Enable or disable specific apps for your session.+<CardGroup cols={2}>+ <Card title="Session management" href="/tool-router/users-and-sessions">+ Learn about users, sessions, and how they work.+ </Card>+ <Card title="Tools and toolkits" href="/tool-router/tools-and-toolkits">+ Learn about tools, toolkits, and how to configure them.</Card>- <Card title="Manual authentication" href="/tool-router/manual-authentication">- Pre-authenticate users before running the agent.+ <Card title="Manual authentication" href="/tool-router/manually-authenticating-users">+ Customise the authentication flow for your users.</Card><Card title="Using MCP" href="/tool-router/using-with-mcp-clients">Connect Tool Router to any MCP-compatible client.