Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
md 64 lines 2.51 KB
Rendered Raw
1 # @composio/claude-agent-sdk
2
3 Composio provider for the [Claude Agent SDK](https://platform.claude.com/docs/en/agent-sdk/overview) (`@anthropic-ai/claude-agent-sdk`). It wraps Composio tools as in-process MCP tools that Claude agents can call.
4
5 ## Installation
6
7 ```bash
8 npm install @composio/core @composio/claude-agent-sdk @anthropic-ai/claude-agent-sdk
9 ```
10
11 Set two environment variables:
12
13 - `COMPOSIO_API_KEY` from the [Composio dashboard](https://dashboard.composio.dev/settings)
14 - `ANTHROPIC_API_KEY` from [Anthropic](https://console.anthropic.com/settings/keys)
15
16 ## Quickstart
17
18 Create a session for your user, serve its tools through an SDK MCP server, and query Claude:
19
20 ```typescript
21 import { Composio } from '@composio/core';
22 import { ClaudeAgentSDKProvider } from '@composio/claude-agent-sdk';
23 import { createSdkMcpServer, query } from '@anthropic-ai/claude-agent-sdk';
24
25 const composio = new Composio({ provider: new ClaudeAgentSDKProvider() });
26
27 // Each session is scoped to one of your users
28 const session = await composio.create('user_123');
29 const tools = await session.tools();
30
31 const customServer = createSdkMcpServer({
32 name: 'composio',
33 version: '1.0.0',
34 tools,
35 });
36
37 for await (const stream of query({
38 prompt: 'Summarize my emails from today',
39 options: {
40 mcpServers: { composio: customServer },
41 permissionMode: 'bypassPermissions',
42 },
43 })) {
44 if (stream.type === 'assistant') {
45 for (const block of stream.message.content) {
46 if (block.type === 'text') process.stdout.write(block.text);
47 }
48 }
49 }
50 ```
51
52 For multi-turn conversations, store `session.sessionId` and reuse it with `composio.use(sessionId)` instead of creating a new session each turn.
53
54 ## How it works
55
56 The Claude Agent SDK provides tools to agents through MCP (Model Context Protocol) servers. `ClaudeAgentSDKProvider` converts each Composio tool definition into an MCP tool and routes execution back through Composio, so `createSdkMcpServer` can serve them in process; no separate server to run.
57
58 Each tool's input schema is built as a Zod v4 schema, which the SDK turns back into the JSON Schema the model sees. The provider carries `format`, `contentEncoding`, `contentMediaType`, and `type: "integer"` through that round trip, and validates tool-call arguments as the other Zod-based providers do. It requires zod 4.1.13 or newer.
59
60 ## Links
61
62 - [Composio quickstart](https://docs.composio.dev/docs/quickstart)
63 - [Composio documentation](https://docs.composio.dev)
64 - [Claude Agent SDK documentation](https://platform.claude.com/docs/en/agent-sdk/overview)