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

claude agent sdk

Sushmithamallesh committed Dec 14, 2025 at 22:28 UTC 0fb9ab7f1c829381e6562ab3f8c34e7705cb5fb4
3 files changed +135
fern/pages/src/tool-router/quickstart.mdx
+34
@@ -68,6 +68,40 @@ When the agent needs authentication, it will prompt the user with a link to conn
68 </Step>
69 </Steps>
70
71 +</Tab>
72 +
73 +<Tab title="Claude Agent SDK">
74 +
75 +<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
83 +```
84 +</CodeGroup>
85 +</Step>
86 +
87 +<Step title="Create session and run agent">
88 +[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
89 +
90 +<Info>
91 +- Set your `COMPOSIO_API_KEY` environment variable with your API key from [Settings](https://platform.composio.dev/?next_page=/settings).
92 +- Set your `ANTHROPIC_API_KEY` environment variable with your [Anthropic API key](https://platform.claude.com/settings/keys).
93 +- `userId` is your user's unique identifier. See [User Management](/docs/user-management) for details.
94 +</Info>
95 +
96 +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).
97 +
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>
102 +</Step>
103 +</Steps>
104 +
105 </Tab>
106 </Tabs>
107
fern/snippets/tool-router/python/quickstart-claude.py new
+52
@@ -0,0 +1,52 @@
1 +import asyncio
2 +from claude_agent_sdk.client import ClaudeSDKClient
3 +from claude_agent_sdk.types import (
4 + ClaudeAgentOptions,
5 + ResultMessage,
6 + AssistantMessage,
7 + TextBlock,
8 + ToolUseBlock
9 +)
10 +from composio import Composio
11 +import os
12 +
13 +# Initialize Composio and create a Tool Router session
14 +composio = Composio(api_key=os.environ["COMPOSIO_API_KEY"])
15 +user_id = "user_123" # Your user's unique identifier
16 +session = composio.create(user_id=user_id)
17 +
18 +# Configure Claude with Composio MCP server
19 +options = ClaudeAgentOptions(
20 + 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.",
21 + mcp_servers={
22 + "composio": {
23 + "type": "http",
24 + "url": session.mcp.url,
25 + "headers": {"x-api-key": os.environ["COMPOSIO_API_KEY"]},
26 + }
27 + },
28 + permission_mode="bypassPermissions",
29 +)
30 +
31 +
32 +async def main():
33 + async with ClaudeSDKClient(options) as client:
34 + while True:
35 + user_input = input("You: ").strip()
36 + if user_input.lower() in ("quit", "exit"):
37 + break
38 +
39 + await client.query(user_input)
40 + async for msg in client.receive_response():
41 + if isinstance(msg, AssistantMessage):
42 + for block in msg.content:
43 + if isinstance(block, ToolUseBlock):
44 + print(f"[🔧 Using tool: {block.name}]")
45 + elif isinstance(block, TextBlock):
46 + print(block.text, end="")
47 + elif isinstance(msg, ResultMessage) and msg.result:
48 + print(f"\n{msg.result}\n")
49 +
50 +
51 +if __name__ == "__main__":
52 + asyncio.run(main())
\ No newline at end of file
fern/snippets/tool-router/typescript/quickstart-claude.ts new
+49
@@ -0,0 +1,49 @@
1 +import { query, type Options } from "@anthropic-ai/claude-agent-sdk";
2 +import { Composio } from "@composio/core";
3 +import { createInterface } from "readline/promises";
4 +
5 +const composioApiKey = process.env.COMPOSIO_API_KEY!;
6 +const userId = "user_123"; // Your user's unique identifier
7 +
8 +const composio = new Composio({ apiKey: composioApiKey });
9 +const session = await composio.create(userId);
10 +
11 +const options: Options = {
12 + 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.",
13 + mcpServers: {
14 + composio: {
15 + type: "http",
16 + url: session.mcp.url,
17 + headers: { "x-api-key": composioApiKey }
18 + },
19 + },
20 + permissionMode: "bypassPermissions",
21 + allowDangerouslySkipPermissions: true,
22 +};
23 +
24 +const rl = createInterface({ input: process.stdin, output: process.stdout });
25 +
26 +console.log("Chat with Claude (type 'quit' to exit)\n");
27 +
28 +while (true) {
29 + const input = (await rl.question("You: ")).trim();
30 + if (input.toLowerCase() === "quit" || input.toLowerCase() === "exit") break;
31 +
32 + process.stdout.write("Claude: ");
33 + for await (const msg of query({ prompt: input, options })) {
34 + if (msg.type === "assistant") {
35 + for (const block of msg.message.content) {
36 + if (block.type === "tool_use") {
37 + console.log(`\n[🔧 Using tool: ${block.name}]`);
38 + } else if (block.type === "text") {
39 + process.stdout.write(block.text);
40 + }
41 + }
42 + } else if (msg.type === "result" && msg.subtype === "success") {
43 + console.log(`\n[Tool Result: ${msg.result}]`);
44 + }
45 + }
46 + console.log();
47 +}
48 +
49 +rl.close();
\ No newline at end of file