Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
mcp client fixes
Sushmithamallesh committed
Dec 15, 2025 at 16:38 UTC
8725d71f68819a3aae5bd5636327af8eef3be549
13 files changed
+200
-162
fern/docs.yml
-6
@@ -298,12 +298,6 @@ navigation:
298
- page: Tools and Toolkits
299
path: pages/dist/tool-router/tools-and-toolkits.mdx
300
slug: tools-and-toolkits
301
- - page: Tool Search
302
- path: pages/dist/tool-router/tool-search.mdx
303
- slug: tool-search
304
- - page: Tool Execution and Workbench
305
- path: pages/dist/tool-router/tool-execution-and-workbench.mdx
306
- slug: tool-execution-and-workbench
301
- section: Guides
302
icon: fa-light fa-book
303
skip-slug: true
fern/pages/src/tool-router/quickstart.mdx
+26
-26
@@ -9,16 +9,16 @@ hide-nav-links: false
9
Build an interactive agent with access to 1000+ tools.
10
11
<Tabs>
12
-<Tab title="OpenAI Agents SDK">
12
+<Tab title="Claude Agent SDK">
13
14
<Steps>
15
<Step title="Install">
16
<CodeGroup>
17
```bash title="Python" for="python"
18
-pip install composio openai-agents
18
+pip install composio claude-agent-sdk
19
```
20
```bash title="TypeScript" for="typescript"
21
-npm install @composio/core @openai/agents
21
+npm install @composio/core @anthropic-ai/claude-agent-sdk
22
```
23
</CodeGroup>
24
</Step>
@@ -28,29 +28,33 @@ npm install @composio/core @openai/agents
28
29
<Info>
30
- Set your `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
31
-- Set your `OPENAI_API_KEY` environment variable with your [OpenAI API key](https://platform.openai.com/api-keys).
31
+- Set your `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://platform.claude.com/settings/keys).
32
- `userId` is your user's unique identifier. See [User Management](/docs/user-management) for details.
33
</Info>
34
35
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).
36
37
<CodeGroup>
38
-<SnippetCode src="fern/snippets/tool-router/python/quickstart-openai.py" title="Python" for="python" />
39
-<SnippetCode src="fern/snippets/tool-router/typescript/quickstart-openai.ts" title="TypeScript" for="typescript" />
38
+<SnippetCode src="fern/snippets/tool-router/python/quickstart-claude.py" title="Python" for="python" />
39
+<SnippetCode src="fern/snippets/tool-router/typescript/quickstart-claude.ts" title="TypeScript" for="typescript" />
40
</CodeGroup>
41
-
41
</Step>
42
</Steps>
43
44
</Tab>
45
47
-<Tab title="Vercel AI SDK">
46
+<Tab title="OpenAI Agents SDK">
47
48
<Steps>
50
-<Step title="Install Composio SDK">
51
-```bash
52
-npm install @composio/core ai @ai-sdk/anthropic @ai-sdk/mcp
49
+<Step title="Install">
50
+<CodeGroup>
51
+```bash title="Python" for="python"
52
+pip install composio openai-agents
53
+```
54
+```bash title="TypeScript" for="typescript"
55
+npm install @composio/core @openai/agents
56
```
57
+</CodeGroup>
58
</Step>
59
60
<Step title="Create session and run agent">
@@ -58,30 +62,29 @@ npm install @composio/core ai @ai-sdk/anthropic @ai-sdk/mcp
62
63
<Info>
64
- Set your `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
61
-- Set your `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://platform.claude.com/settings/keys).
65
+- Set your `OPENAI_API_KEY` environment variable with your [OpenAI API key](https://platform.openai.com/api-keys).
66
- `userId` is your user's unique identifier. See [User Management](/docs/user-management) for details.
67
</Info>
68
69
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).
70
67
-<SnippetCode src="fern/snippets/tool-router/typescript/quickstart-vercel.ts" />
71
+<CodeGroup>
72
+<SnippetCode src="fern/snippets/tool-router/python/quickstart-openai.py" title="Python" for="python" />
73
+<SnippetCode src="fern/snippets/tool-router/typescript/quickstart-openai.ts" title="TypeScript" for="typescript" />
74
+</CodeGroup>
75
+
76
</Step>
77
</Steps>
78
79
</Tab>
80
73
-<Tab title="Claude Agent SDK">
81
+<Tab title="Vercel AI SDK">
82
83
<Steps>
76
-<Step title="Install">
77
-<CodeGroup>
78
-```bash title="Python" for="python"
79
-pip install composio claude-agent-sdk
80
-```
81
-```bash title="TypeScript" for="typescript"
82
-npm install @composio/core @anthropic-ai/claude-agent-sdk
84
+<Step title="Install Composio SDK">
85
+```bash
86
+npm install @composio/core ai @ai-sdk/anthropic @ai-sdk/mcp
87
```
84
-</CodeGroup>
88
</Step>
89
90
<Step title="Create session and run agent">
@@ -95,10 +98,7 @@ npm install @composio/core @anthropic-ai/claude-agent-sdk
98
99
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).
100
98
-<CodeGroup>
99
-<SnippetCode src="fern/snippets/tool-router/python/quickstart-claude.py" title="Python" for="python" />
100
-<SnippetCode src="fern/snippets/tool-router/typescript/quickstart-claude.ts" title="TypeScript" for="typescript" />
101
-</CodeGroup>
101
+<SnippetCode src="fern/snippets/tool-router/typescript/quickstart-vercel.ts" />
102
</Step>
103
</Steps>
104
fern/pages/src/tool-router/using-with-mcp-clients.mdx
+16
-19
@@ -10,67 +10,66 @@ Every Tool Router session provides a unique MCP server URL. This URL exposes the
10
## Examples for popular frameworks
11
12
Jump to examples for:
13
-- [OpenAI Agents SDK](#openai-agents-sdk) - Python, TypeScript
13
- [Claude Agent SDK](#claude-agent-sdk) - Python, TypeScript
14
+- [OpenAI Agents SDK](#openai-agents-sdk) - Python, TypeScript
15
- [Vercel AI SDK](#vercel-ai-sdk) - TypeScript
16
17
-## OpenAI Agents SDK
17
+## Claude Agent SDK
18
19
### Installation
20
21
<CodeGroup>
22
```bash title="Python" for="python"
23
-pip install composio openai-agents
23
+pip install composio claude-agent-sdk
24
```
25
```bash title="TypeScript" for="typescript"
26
-npm install @composio/core @openai/agents
26
+npm install @composio/core @anthropic-ai/claude-agent-sdk
27
```
28
</CodeGroup>
29
30
### Usage
31
32
-Create a Tool Router session and execute tasks with OpenAI agents:
32
+Create a Tool Router session and execute tasks with Claude:
33
34
<Info>
35
- Set your `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
36
-- Set your `OPENAI_API_KEY` environment variable with your [OpenAI API key](https://platform.openai.com/api-keys).
36
+- Set your `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://platform.claude.com/settings/keys).
37
</Info>
38
39
<CodeGroup>
40
-<SnippetCode src="fern/snippets/tool-router/python/mcp-openai.py" title="Python" for="python" />
41
-<SnippetCode src="fern/snippets/tool-router/typescript/mcp-openai.ts" title="TypeScript" for="typescript" />
40
+<SnippetCode src="fern/snippets/tool-router/python/mcp-claude.py" title="Python" for="python" />
41
+<SnippetCode src="fern/snippets/tool-router/typescript/mcp-claude.ts" title="TypeScript" for="typescript" />
42
</CodeGroup>
43
44
-## Claude Agent SDK
44
+## OpenAI Agents SDK
45
46
### Installation
47
48
<CodeGroup>
49
```bash title="Python" for="python"
50
-pip install composio claude-agent-sdk
50
+pip install composio openai-agents
51
```
52
```bash title="TypeScript" for="typescript"
53
-npm install @composio/core @anthropic-ai/claude-agent-sdk
53
+npm install @composio/core @openai/agents
54
```
55
</CodeGroup>
56
57
### Usage
58
59
-Create a Tool Router session and execute tasks with Claude:
59
+Create a Tool Router session and execute tasks with OpenAI agents:
60
61
<Info>
62
- Set your `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
63
-- Set your `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://platform.claude.com/settings/keys).
63
+- Set your `OPENAI_API_KEY` environment variable with your [OpenAI API key](https://platform.openai.com/api-keys).
64
</Info>
65
66
<CodeGroup>
67
-<SnippetCode src="fern/snippets/tool-router/python/mcp-claude.py" title="Python" for="python" />
68
-<SnippetCode src="fern/snippets/tool-router/typescript/mcp-claude.ts" title="TypeScript" for="typescript" />
67
+<SnippetCode src="fern/snippets/tool-router/python/mcp-openai.py" title="Python" for="python" />
68
+<SnippetCode src="fern/snippets/tool-router/typescript/mcp-openai.ts" title="TypeScript" for="typescript" />
69
</CodeGroup>
70
71
## Vercel AI SDK
72
73
-
73
### Installation
74
75
```bash
@@ -86,6 +85,4 @@ Use Tool Router with Vercel AI SDK's `generateText` for single completions:
85
- Set your `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://platform.claude.com/settings/keys).
86
</Info>
87
89
-<SnippetCode src="fern/snippets/tool-router/typescript/mcp-vercel.ts" />
90
-
91
-
88
+<SnippetCode src="fern/snippets/tool-router/typescript/mcp-vercel.ts" />
\ No newline at end of file
fern/snippets/tool-router/python/mcp-claude.py
+36
-30
@@ -1,10 +1,13 @@
1
-# Execute AI tasks with Claude using Composio Tool Router
1
+# Fetch GitHub issues and organize them in a Google Sheet using Claude
2
3
import asyncio
4
+import os
5
+from dotenv import load_dotenv
6
from claude_agent_sdk.client import ClaudeSDKClient
5
-from claude_agent_sdk.types import ClaudeAgentOptions
7
+from claude_agent_sdk.types import ClaudeAgentOptions, AssistantMessage, TextBlock, ToolUseBlock
8
from composio import Composio
7
-import os
9
+
10
+load_dotenv()
11
12
# Initialize Composio and create a Tool Router session
13
composio = Composio(api_key=os.environ["COMPOSIO_API_KEY"])
@@ -13,7 +16,7 @@ session = composio.create(user_id=user_id)
16
17
# Configure Claude with Composio MCP server
18
options = ClaudeAgentOptions(
16
- system_prompt="You are a helpful assistant with access to external tools. Always use the available tools to complete user requests instead of just explaining how to do them.",
19
+ system_prompt="You are a helpful assistant with access to external tools. Always use the available tools to complete user requests.",
20
mcp_servers={
21
"composio": {
22
"type": "http",
@@ -25,36 +28,39 @@ options = ClaudeAgentOptions(
28
)
29
30
28
-async def execute_task(task: str):
29
- """Execute a single task using Claude with MCP tools"""
31
+async def main():
32
+ print("Starting Claude agent with Composio Tool Router...\n")
33
+
34
async with ClaudeSDKClient(options) as client:
31
- # Send the task to Claude
32
- await client.query(task)
35
+ # Initial task
36
+ query = "Fetch all open issues from the composio/composio GitHub repository and create a Google Sheet with issue number, title, labels, and author"
37
+
38
+ print(f"Task: {query}\n")
39
+ print("Claude: ", end="")
40
34
- # Collect the complete response
35
- response = ""
41
+ await client.query(query)
42
async for msg in client.receive_response():
37
- if hasattr(msg, 'message'):
38
- for block in msg.message.content:
39
- if block.type == "text":
40
- response += block.text
43
+ if isinstance(msg, AssistantMessage):
44
+ for block in msg.content:
45
+ if isinstance(block, ToolUseBlock):
46
+ print(f"\n[🔧 Using tool: {block.name}]")
47
+ elif isinstance(block, TextBlock):
48
+ print(block.text, end="")
49
+ print("\n")
50
42
- return response
43
-
44
-
45
-# Example usage
46
-async def main():
47
- # Execute a task that requires tools
48
- result = await execute_task(
49
- "Get the top story from Hacker News and summarize it"
50
- )
51
- print(result)
52
-
53
- # Execute another task
54
- result = await execute_task(
55
- "Create a GitHub issue in composio/composio repo about improving documentation"
56
- )
57
- print(result)
51
+ # If authentication is needed, Claude will provide a link
52
+ # You can paste it back or type 'quit' to exit
53
+ user_input = input("\nYou (confirm connection or new task or quit): ").strip()
54
+
55
+ if user_input.lower() not in ("quit", "exit") and user_input:
56
+ await client.query(user_input)
57
+ print("\nClaude: ", end="")
58
+ async for msg in client.receive_response():
59
+ if isinstance(msg, AssistantMessage):
60
+ for block in msg.content:
61
+ if isinstance(block, TextBlock):
62
+ print(block.text, end="")
63
+ print()
64
65
66
if __name__ == "__main__":
fern/snippets/tool-router/python/mcp-openai.py
+4
@@ -1,9 +1,13 @@
1
# An agent that fetches and categorizes GitHub issues using OpenAI and Composio Tool Router
2
3
import os
4
+from dotenv import load_dotenv
5
from composio import Composio
6
from agents import Agent, Runner, HostedMCPTool, ModelSettings
7
8
+# Load environment variables from .env file
9
+load_dotenv()
10
+
11
composio_api_key = os.environ["COMPOSIO_API_KEY"]
12
user_id = "user_123" # Your user's unique identifier
13
fern/snippets/tool-router/python/quickstart-claude.py
+5
-1
@@ -1,4 +1,6 @@
1
import asyncio
2
+import os
3
+from dotenv import load_dotenv
4
from claude_agent_sdk.client import ClaudeSDKClient
5
from claude_agent_sdk.types import (
6
ClaudeAgentOptions,
@@ -8,7 +10,9 @@ from claude_agent_sdk.types import (
10
ToolUseBlock
11
)
12
from composio import Composio
11
-import os
13
+
14
+# Load environment variables from .env file
15
+load_dotenv()
16
17
# Initialize Composio and create a Tool Router session
18
composio = Composio(api_key=os.environ["COMPOSIO_API_KEY"])
fern/snippets/tool-router/python/quickstart-openai.py
+4
@@ -1,7 +1,11 @@
1
import os
2
+from dotenv import load_dotenv
3
from composio import Composio
4
from agents import Agent, Runner, HostedMCPTool, ModelSettings
5
6
+# Load environment variables from .env file
7
+load_dotenv()
8
+
9
composio_api_key = os.environ.get("COMPOSIO_API_KEY")
10
user_id = "user_123" # Your user's unique identifier
11
fern/snippets/tool-router/typescript/mcp-claude.ts
+55
-27
@@ -1,9 +1,14 @@
1
-// Execute AI tasks with Claude using Composio Tool Router
1
+// Fetch GitHub issues and organize them in a Google Sheet using Claude
2
3
+import "dotenv/config"; // Load environment variables from .env file
4
import { query, type Options } from "@anthropic-ai/claude-agent-sdk";
5
import { Composio } from "@composio/core";
6
+import { createInterface } from "readline/promises";
7
6
-const composioApiKey = process.env.COMPOSIO_API_KEY!;
8
+const composioApiKey = process.env.COMPOSIO_API_KEY;
9
+if (!composioApiKey) {
10
+ console.warn("⚠️ Warning: COMPOSIO_API_KEY not set - Claude won't be able to use Composio tools");
11
+}
12
const userId = "user_123"; // Your user's unique identifier
13
14
// Initialize Composio and create a Tool Router session
@@ -12,7 +17,7 @@ const session = await composio.create(userId);
17
18
// Configure Claude with Composio MCP server
19
const options: Options = {
15
- systemPrompt: "You are a helpful assistant with access to external tools. Always use the available tools to complete user requests instead of just explaining how to do them.",
20
+ systemPrompt: "You are a helpful assistant with access to external tools. Always use the available tools to complete user requests.",
21
mcpServers: {
22
composio: {
23
type: "http",
@@ -24,39 +29,62 @@ const options: Options = {
29
allowDangerouslySkipPermissions: true,
30
};
31
27
-/**
28
- * Execute a single task using Claude with MCP tools
29
- */
30
-async function executeTask(task: string): Promise<string> {
31
- let response = "";
32
+async function main() {
33
+ console.log("Starting Claude agent with Composio Tool Router...\n");
34
+
35
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
36
+
37
+ // Initial task
38
+ const task = "Fetch all open issues from the composio/composio GitHub repository and create a Google Sheet with issue number, title, labels, and author";
39
+
40
+ console.log(`Task: ${task}\n`);
41
+
42
+ let isFirstQuery = true;
43
33
- // Send the task to Claude and collect the response
44
for await (const msg of query({ prompt: task, options })) {
45
if (msg.type === "assistant") {
46
for (const block of msg.message.content) {
37
- if (block.type === "text") {
38
- response += block.text;
47
+ if (block.type === "tool_use") {
48
+ console.log(`\n[🔧 Using tool: ${block.name}]`);
49
+ } else if (block.type === "text") {
50
+ process.stdout.write(block.text);
51
}
52
}
53
+ } else if (msg.type === "result" && msg.subtype === "success") {
54
+ console.log(`\n${msg.result}\n`);
55
}
56
}
57
+ console.log("\n");
58
44
- return response;
45
-}
46
-
47
-// Example usage
48
-async function main() {
49
- // Execute a task that requires tools
50
- let result = await executeTask(
51
- "Get the top story from Hacker News and summarize it"
52
- );
53
- console.log(result);
54
-
55
- // Execute another task
56
- result = await executeTask(
57
- "Create a GitHub issue in composio/composio repo about improving documentation"
58
- );
59
- console.log(result);
59
+ isFirstQuery = false;
60
+
61
+ // If authentication is needed, Claude will provide a link
62
+ console.log("\nOptions:");
63
+ console.log(" - Type 'quit' to exit");
64
+ console.log(" - Say 'connected' or enter a new task\n");
65
+
66
+ const userInput = await rl.question("You: ");
67
+
68
+ if (userInput.toLowerCase() !== "quit" && userInput.toLowerCase() !== "exit" && userInput) {
69
+ const queryOptions = isFirstQuery ? options : { ...options, continue: true };
70
+
71
+ for await (const msg of query({ prompt: userInput, options: queryOptions })) {
72
+ if (msg.type === "assistant") {
73
+ for (const block of msg.message.content) {
74
+ if (block.type === "tool_use") {
75
+ console.log(`\n[🔧 Using tool: ${block.name}]`);
76
+ } else if (block.type === "text") {
77
+ process.stdout.write(block.text);
78
+ }
79
+ }
80
+ } else if (msg.type === "result" && msg.subtype === "success") {
81
+ console.log(`\n${msg.result}\n`);
82
+ }
83
+ }
84
+ console.log();
85
+ }
86
+
87
+ rl.close();
88
}
89
90
main().catch(console.error);
\ No newline at end of file
fern/snippets/tool-router/typescript/mcp-openai.ts
+2
-1
@@ -1,9 +1,10 @@
1
// An agent that fetches and categorizes GitHub issues using OpenAI and Composio Tool Router
2
3
+import "dotenv/config"; // Load environment variables from .env file
4
import { Composio } from "@composio/core";
5
import { Agent, hostedMcpTool, run } from "@openai/agents";
6
6
-const composioApiKey = process.env.COMPOSIO_API_KEY!;
7
+const composioApiKey = process.env.COMPOSIO_API_KEY;
8
const userId = "user_123"; // Your user's unique identifier
9
10
// Initialize Composio and create a Tool Router session
fern/snippets/tool-router/typescript/mcp-vercel.ts
+36
-47
@@ -1,54 +1,43 @@
1
-// Generate text completions with Vercel AI SDK using Composio Tool Router
2
-
1
+import "dotenv/config"; // Load environment variables from .env file
2
+import { anthropic } from "@ai-sdk/anthropic";
3
+import { experimental_createMCPClient as createMCPClient } from "@ai-sdk/mcp";
4
import { Composio } from "@composio/core";
4
-import { createAnthropic } from "@ai-sdk/anthropic";
5
-import { createMCPClient } from "@ai-sdk/mcp";
6
-import { generateText } from "ai";
7
-
8
-const composioApiKey = process.env.COMPOSIO_API_KEY!;
9
-const userId = "user_123"; // Your user's unique identifier
5
+import { stepCountIs, streamText } from "ai";
6
+const composioApiKey = process.env.COMPOSIO_API_KEY;
7
+const userId = "user-1234"; // Your user's unique identifier
8
11
-// Initialize Composio and create a Tool Router session
9
const composio = new Composio({ apiKey: composioApiKey });
13
-const session = await composio.create(userId);
10
15
-// Create MCP client connected to Composio
16
-const mcpClient = await createMCPClient({
17
- type: "http",
18
- url: session.mcp.url,
19
- headers: { "x-api-key": composioApiKey },
11
+const { mcp } = await composio.create(userId);
12
+console.log(`Tool Router session created: ${mcp.url}`);
13
+
14
+const client = await createMCPClient({
15
+ transport: {
16
+ type: "http",
17
+ url: mcp.url,
18
+ headers: {
19
+ "x-api-key": composioApiKey,
20
+ },
21
+ },
22
});
23
22
-// Create Anthropic model
23
-const anthropic = createAnthropic();
24
-
25
-/**
26
- * Execute a task using Vercel AI SDK with MCP tools
27
- */
28
-async function executeTask(task: string) {
29
- const result = await generateText({
30
- model: anthropic("claude-3-5-sonnet-latest"),
31
- prompt: task,
32
- tools: mcpClient.tools,
33
- system: "You are a helpful assistant with access to external tools. Always use the available tools to complete user requests instead of just explaining how to do them.",
34
- });
35
-
36
- return result.text;
37
-}
38
-
39
-// Example usage
40
-async function main() {
41
- // Execute a task that requires tools
42
- let result = await executeTask(
43
- "Get the current weather in San Francisco"
44
- );
45
- console.log(result);
46
-
47
- // Execute another task with tools
48
- result = await executeTask(
49
- "Search for the latest news about AI and summarize the top 3 stories"
50
- );
51
- console.log(result);
52
-}
24
+const tools = await client.tools();
25
+
26
+const stream = await streamText({
27
+ system: "You are a helpful personal assistant. You should use composio MCP tools to take action.",
28
+ model: anthropic("claude-sonnet-4-5"),
29
+ prompt: "Summarize all the emails in my Gmail inbox today",
30
+ stopWhen: stepCountIs(10),
31
+ onStepFinish: (step) => {
32
+ if (step.toolCalls.length > 0) {
33
+ for (const toolCall of step.toolCalls) {
34
+ console.log(`Executed ${toolCall.toolName}`);
35
+ }
36
+ }
37
+ },
38
+ tools,
39
+});
40
54
-main().catch(console.error);
\ No newline at end of file
41
+for await (const textPart of stream.textStream) {
42
+ process.stdout.write(textPart);
43
+}
\ No newline at end of file
fern/snippets/tool-router/typescript/quickstart-claude.ts
+14
-5
@@ -1,16 +1,19 @@
1
+import "dotenv/config"; // Load environment variables from .env file
2
import { query, type Options } from "@anthropic-ai/claude-agent-sdk";
3
import { Composio } from "@composio/core";
4
import { createInterface } from "readline/promises";
5
5
-const composioApiKey = process.env.COMPOSIO_API_KEY!;
6
+const composioApiKey = process.env.COMPOSIO_API_KEY;
7
+if (!composioApiKey) {
8
+ console.warn("⚠️ Warning: COMPOSIO_API_KEY not set - Claude won't be able to use Composio tools");
9
+}
10
const userId = "user_123"; // Your user's unique identifier
11
12
const composio = new Composio({ apiKey: composioApiKey });
13
const session = await composio.create(userId);
14
15
const options: Options = {
12
- systemPrompt: "You are a helpful assistant with access to external tools. "
13
- + "Always use the available tools to complete user requests instead of just explaining how to do them.",
16
+ systemPrompt: "You are a helpful assistant with access to external tools. Always use the available tools to complete user requests instead of just explaining how to do them.",
17
mcpServers: {
18
composio: {
19
type: "http",
@@ -24,14 +27,20 @@ const options: Options = {
27
28
const rl = createInterface({ input: process.stdin, output: process.stdout });
29
27
-console.log("Chat with Claude (type 'quit' to exit)\n");
30
+console.log("What task would you like me to help you with?");
31
+console.log("(Type 'quit' to exit)\n");
32
+
33
+let isFirstQuery = true;
34
35
while (true) {
36
const input = (await rl.question("You: ")).trim();
37
if (input.toLowerCase() === "quit" || input.toLowerCase() === "exit") break;
38
39
process.stdout.write("Claude: ");
34
- for await (const msg of query({ prompt: input, options })) {
40
+ const queryOptions = isFirstQuery ? options : { ...options, continue: true };
41
+ isFirstQuery = false;
42
+
43
+ for await (const msg of query({ prompt: input, options: queryOptions })) {
44
if (msg.type === "assistant") {
45
for (const block of msg.message.content) {
46
if (block.type === "tool_use") {
fern/snippets/tool-router/typescript/quickstart-openai.ts
+1
@@ -1,3 +1,4 @@
1
+import "dotenv/config"; // Load environment variables from .env file
2
import { Composio } from "@composio/core";
3
import { Agent, run, hostedMcpTool } from "@openai/agents";
4
import { createInterface } from "readline/promises";
fern/snippets/tool-router/typescript/quickstart-vercel.ts
+1
@@ -1,3 +1,4 @@
1
+import "dotenv/config"; // Load environment variables from .env file
2
import { anthropic } from "@ai-sdk/anthropic";
3
import { experimental_createMCPClient as createMCPClient } from "@ai-sdk/mcp";
4
import { Composio } from "@composio/core";