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
migration and mutli tuen quickstart
Sushmithamalleshd684eb0c32b8
diff --git a/fern/pages/src/tool-router/migration/tool-router-beta-to-stable.mdx b/fern/pages/src/tool-router/migration/tool-router-beta-to-stable.mdxindex 8c7683133..7adab6395 100644--- a/fern/pages/src/tool-router/migration/tool-router-beta-to-stable.mdx+++ b/fern/pages/src/tool-router/migration/tool-router-beta-to-stable.mdx@@ -44,10 +44,12 @@ The stable version includes improved session management, multiple configuring op</CodeGroup></Step><Step title="Moving users (optional)">- If you have existing users on tool router and you don't want them to authenticate again:- - Search for the Auth config created by Tool Router for that connected account. See [Connected Accounts](/docs/connected-accounts) to fetch existing accounts programmatically.- - While creating a session configure to use this Auth config.- - You need to repeat this for each toolkit you want to enable for that session.+ If you have existing users on tool router and you don't want them to authenticate again:+ - Tool Router will auto-detect auth configs and connected accounts it created(from the beta version).+ - If you have custom auth configs (not created by Tool Router):+ - Search for the Auth config for that connected account. See [Connected Accounts](/docs/connected-accounts) to fetch existing accounts programmatically.+ - While creating a session configure to use this Auth config.+ - You need to repeat this for each toolkit you want to enable for that session.<CodeGroup>```python title="Python" for="python"session = composio.create(diff --git a/fern/snippets/tool-router/python/quickstart-mcp-openai.py b/fern/snippets/tool-router/python/quickstart-mcp-openai.pyindex d02a8b222..8d9071660 100644--- a/fern/snippets/tool-router/python/quickstart-mcp-openai.py+++ b/fern/snippets/tool-router/python/quickstart-mcp-openai.py@@ -1,16 +1,15 @@import osfrom dotenv import load_dotenvfrom composio import Composio-from agents import Agent, Runner, HostedMCPTool, ModelSettings+from agents import Agent, Runner, HostedMCPTool, SQLiteSession-# Load environment variables from .env fileload_dotenv()composio_api_key = os.environ.get("COMPOSIO_API_KEY")user_id = "user_123" # Your user's unique identifiercomposio = Composio(api_key=composio_api_key)-session = composio.create(user_id=user_id)+composio_session = composio.create(user_id=user_id)agent = Agent(name="Personal Assistant",@@ -21,7 +20,7 @@ agent = Agent(tool_config={"type": "mcp","server_label": "composio",- "server_url": session.mcp.url,+ "server_url": composio_session.mcp.url,"require_approval": "never","headers": {"x-api-key": composio_api_key},}@@ -29,11 +28,21 @@ agent = Agent(],)+# Create a session for multi-turn conversation memory+conversation_session = SQLiteSession(user_id)+print("Assistant: What would you like me to do today?\n")while True:user_input = input("> ")if user_input == "exit":break- result = Runner.run_sync(starting_agent=agent, input=user_input)++ result = Runner.run_sync(+ starting_agent=agent,+ input=user_input,+ session=conversation_session+ )+print(f"Assistant: {result.final_output}\n")+diff --git a/fern/snippets/tool-router/typescript/quickstart-mcp-openai.ts b/fern/snippets/tool-router/typescript/quickstart-mcp-openai.tsindex 8ac06aeb3..6feffa94d 100644--- a/fern/snippets/tool-router/typescript/quickstart-mcp-openai.ts+++ b/fern/snippets/tool-router/typescript/quickstart-mcp-openai.ts@@ -1,6 +1,6 @@import "dotenv/config"; // Load environment variables from .env fileimport { Composio } from "@composio/core";-import { Agent, run, hostedMcpTool } from "@openai/agents";+import { Agent, run, hostedMcpTool, MemorySession } from "@openai/agents";import { createInterface } from "readline/promises";const composioApiKey = process.env.COMPOSIO_API_KEY;@@ -24,12 +24,15 @@ const agent = new Agent({],});+// Create a session for persistent multi-turn conversation memory+const session = new MemorySession();+const rl = createInterface({ input: process.stdin, output: process.stdout });console.log("Assistant: What would you like me to do today?\n");while (true) {const input = await rl.question("> ");if (input === "exit") break;- const result = await run(agent, input);+ const result = await run(agent, input, { session });console.log(`Assistant: ${result.finalOutput}\n`);}rl.close();