Integrate Composio tools with Claude Code Agents SDK via MCP
The Claude Agent SDK provider enables seamless integration of Composio tools with Claude Code Agents SDK, allowing you to use any Composio-supported tool (Gmail, Slack, GitHub, etc.) within your Claude agents.
import { Composio } from '@composio/core';import { ClaudeAgentSDKProvider } from '@composio/claude-agent-sdk';import { query, createSdkMcpServer } from '@anthropic-ai/claude-agent-sdk';// Initialize Composio with Claude Agent SDK providerconst composio = new Composio({ apiKey: process.env.COMPOSIO_API_KEY, provider: new ClaudeAgentSDKProvider(),});// Create a tool router sessionconst session = await composio.create('external_user_id');// Get tools from the sessionconst tools = await session.tools();// Create MCP server using Claude Agent SDK's createSdkMcpServerconst customServer = createSdkMcpServer({ name: 'composio', version: '1.0.0', tools: tools,});// Use with Claude Agent SDKfor await (const content of query({ prompt: 'Fetch my last email from gmail', options: { mcpServers: { composio: customServer }, permissionMode: 'bypassPermissions', },})) { if (content.type === 'assistant') { console.log('Claude:', content.message); }}console.log('✅ Received response from Claude');
// Create a session for a specific userconst session = await composio.toolRouter.createSession({ userId: '[email protected]',});// Get tools from the session (automatically handles authentication)const tools = await session.tools(['GITHUB_CREATE_ISSUE', 'GITHUB_LIST_REPOS']);// Create MCP server with session toolsconst mcpServer = createSdkMcpServer({ name: 'github-tools', version: '1.0.0', tools,});for await (const content of query({ prompt: 'Create an issue in my top starred repo', options: { mcpServers: { github: mcpServer }, },})) { if (content.type === 'assistant') { console.log(content.message); }}
The Claude Agent SDK uses MCP (Model Context Protocol) servers to provide tools to Claude agents. This provider:
Converts Composio tool definitions to MCP tool format
Creates an in-process MCP server using createSdkMcpServer()
Handles tool execution by routing calls through Composio’s execution layer
Manages authentication and connected accounts automatically
The Claude Agent SDK provider is built on top of Composio’s agentic provider base, which means it automatically handles tool wrapping and execution delegation.