# How to integrate Kommo MCP with OpenAI Agents SDK

```json
{
  "title": "How to integrate Kommo MCP with OpenAI Agents SDK",
  "toolkit": "Kommo",
  "toolkit_slug": "kommo",
  "framework": "OpenAI Agents SDK",
  "framework_slug": "open-ai-agents-sdk",
  "url": "https://composio.dev/toolkits/kommo/framework/open-ai-agents-sdk",
  "markdown_url": "https://composio.dev/toolkits/kommo/framework/open-ai-agents-sdk.md",
  "updated_at": "2026-05-12T10:16:59.233Z"
}
```

## Introduction

This guide walks you through connecting Kommo to the OpenAI Agents SDK using the Composio tool router. By the end, you'll have a working Kommo agent that can add a new lead with contact info, list all companies created this week, create a follow-up task for a lead through natural language commands.
This guide will help you understand how to give your OpenAI Agents SDK agent real control over a Kommo account through Composio's Kommo MCP server.
Before we dive in, let's take a quick look at the key ideas and tools involved.

## Also integrate Kommo with

- [Claude Agent SDK](https://composio.dev/toolkits/kommo/framework/claude-agents-sdk)
- [Claude Code](https://composio.dev/toolkits/kommo/framework/claude-code)
- [Claude Cowork](https://composio.dev/toolkits/kommo/framework/claude-cowork)
- [Codex](https://composio.dev/toolkits/kommo/framework/codex)
- [OpenClaw](https://composio.dev/toolkits/kommo/framework/openclaw)
- [Hermes](https://composio.dev/toolkits/kommo/framework/hermes-agent)
- [CLI](https://composio.dev/toolkits/kommo/framework/cli)
- [Google ADK](https://composio.dev/toolkits/kommo/framework/google-adk)
- [LangChain](https://composio.dev/toolkits/kommo/framework/langchain)
- [Vercel AI SDK](https://composio.dev/toolkits/kommo/framework/ai-sdk)
- [Mastra AI](https://composio.dev/toolkits/kommo/framework/mastra-ai)
- [LlamaIndex](https://composio.dev/toolkits/kommo/framework/llama-index)
- [CrewAI](https://composio.dev/toolkits/kommo/framework/crew-ai)

## TL;DR

Here's what you'll learn:
- Get and set up your OpenAI and Composio API keys
- Install the necessary dependencies
- Initialize Composio and create a Tool Router session for Kommo
- Configure an AI agent that can use Kommo as a tool
- Run a live chat session where you can ask the agent to perform Kommo operations

## What is OpenAI Agents SDK?

The OpenAI Agents SDK is a lightweight framework for building AI agents that can use tools and maintain conversation state. It provides a simple interface for creating agents with hosted MCP tool support.
Key features include:
- Hosted MCP Tools: Connect to external services through hosted MCP endpoints
- SQLite Sessions: Persist conversation history across interactions
- Simple API: Clean interface with Agent, Runner, and tool configuration
- Streaming Support: Real-time response streaming for interactive applications

## What is the Kommo MCP server, and what's possible with it?

The Kommo MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Kommo CRM account. It provides structured and secure access to your customer data, so your agent can perform actions like creating leads, managing contacts, tracking companies, organizing pipelines, and automating tasks on your behalf.
- Lead and pipeline management: Automatically create new leads, list existing leads, and organize them within your sales pipelines, helping you stay on top of every sales opportunity.
- Contact and company handling: Effortlessly add or list contacts and companies, making it simple for your agent to keep your CRM up to date and accessible.
- Task automation and tracking: Let your agent create tasks for follow-ups, reminders, or next steps, so nothing falls through the cracks in your customer relationships.
- Pipeline stage and custom field access: Retrieve and list pipeline stages and custom fields, enabling your agent to analyze and optimize your sales processes with tailored data.
- Business process automation: Leverage structured tools to automate repetitive actions like updating records or filtering data, saving you time and reducing manual effort.

## Supported Tools

| Tool slug | Name | Description |
|---|---|---|
| `KOMMO_ADD_AI_SOURCE_FILE` | Add AI Source File | Tool to add a knowledge source file to Kommo AI. Use when you need to upload a file (like documentation, policies, or knowledge base articles) to be used by the Kommo AI agent or suggested reply feature. |
| `KOMMO_CREATE_COMPANY` | Create Kommo Companies | Action to add one or more companies into the Kommo account. |
| `KOMMO_CREATE_CONTACT` | Create Kommo Contact | Action to create one or more contacts in Kommo CRM. |
| `KOMMO_CREATE_LEAD` | Create Kommo Lead | Action to create a lead in Kommo CRM. |
| `KOMMO_CREATE_TASK` | Create Kommo Task | Action to create a task in Kommo CRM. |
| `KOMMO_DELETE_FILES` | Delete Kommo Files | Tool to delete files (move to trash) in Kommo. Use when you need to remove files from the Kommo account. |
| `KOMMO_GET_ACCOUNT` | Get Kommo Account | Tool to get account information including user data, custom fields, task types, user groups, amojo rights, and integration status. Use when you need to retrieve account-level details from Kommo CRM. |
| `KOMMO_GET_COMPANY` | Get Kommo Company | Tool to get a company by its ID from Kommo CRM. Use when you need to retrieve detailed information about a specific company including its name, responsible user, and optionally embedded data like contacts, leads, or catalog elements. |
| `KOMMO_GET_CONTACT` | Get Kommo Contact | Tool to get a specific contact by its ID from Kommo CRM. Use when you need to retrieve detailed information about a particular contact. |
| `KOMMO_GET_CUSTOM_FIELD` | Get Kommo Custom Field | Tool to retrieve a custom field by its ID from Kommo CRM. Use when you need detailed information about a specific custom field including its type, settings, and enum values. |
| `KOMMO_GET_EVENT` | Get Kommo Event | Tool to get a specific event by its ID from Kommo CRM. Use when you need to retrieve detailed information about a particular event, including before/after state changes for entities. |
| `KOMMO_GET_FIELD_GROUP` | Get Kommo Field Group | Tool to retrieve a custom field group by its ID from Kommo CRM. Use when you need to get details about a specific field group including its fields and metadata. |
| `KOMMO_GET_FILE_LINKS` | Get File Links | Tool to get entities associated with a file in Kommo. Use when you need to find which leads, contacts, companies, or catalog elements are linked to a specific file. |
| `KOMMO_GET_INCOMING_LEADS_SUMMARY` | Get Incoming Leads Summary | Tool to retrieve summary statistics for incoming (unsorted) leads in Kommo CRM. Use when you need aggregate metrics like total count, acceptance/decline rates, average processing time, and breakdown by lead source category. |
| `KOMMO_GET_LEAD` | Get Kommo Lead | Tool to get a lead by its ID from Kommo CRM. Use when you need to retrieve detailed information about a specific lead including its status, price, responsible user, and optionally embedded data like contacts, catalog elements, or loss reasons. |
| `KOMMO_GET_LOSS_REASON` | Get Kommo Loss Reason | Tool to retrieve a specific loss reason by its ID from Kommo CRM. Use when you need detailed information about a particular loss reason, such as its name, sort order, and timestamps. |
| `KOMMO_GET_PIPELINE` | Get Kommo Pipeline | Tool to get a pipeline by its ID from Kommo CRM. Use when you need to retrieve details about a specific pipeline including its stages. |
| `KOMMO_GET_PIPELINE_STATUS` | Get Kommo Pipeline Status | Tool to get a specific pipeline stage by its ID from Kommo CRM. Use when you need to retrieve detailed information about a particular stage within a pipeline. |
| `KOMMO_GET_TASK` | Get Kommo Task | Tool to retrieve a task by its ID from Kommo CRM. Use when you need to fetch details of a specific task. |
| `KOMMO_GET_USER` | Get Kommo User | Tool to retrieve user data by its ID from Kommo CRM. Use when you need to fetch details about a specific user including their name, email, role, group, and access rights. |
| `KOMMO_GET_WIDGET` | Get Kommo Widget Info | Tool to get detailed information about a widget by its code. Use when you need to retrieve widget metadata, settings, version, or check if a widget is active in the account. |
| `KOMMO_IMPORT_PRODUCTS_TO_AI` | Import Products to AI | Tool to launch import of products from CRM to AI knowledge base. Use when you need to initiate the process of importing product data into the AI system for enhanced product recommendations and knowledge. |
| `KOMMO_LIST_CATALOGS` | List Kommo Catalogs | Tool to retrieve a list of catalogs (lists) from Kommo CRM. Use when you need to fetch available catalogs in the account. |
| `KOMMO_LIST_COMPANIES` | List Kommo Companies | Action to list Kommo companies with various filter options. |
| `KOMMO_LIST_CONTACTS` | List Kommo Contacts | Action to list contacts in Kommo CRM. |
| `KOMMO_LIST_CONVERSATIONS` | List Kommo Conversations | Tool to get a list of conversations from Kommo CRM. Use when you need to retrieve conversations with pagination support. |
| `KOMMO_LIST_CUSTOM_FIELDS` | List Kommo Custom Fields | Action to list custom fields in Kommo CRM. |
| `KOMMO_LIST_ENTITY_FILES` | List Entity Files | Tool to retrieve a list of files attached to an entity in Kommo CRM. Use when you need to see all files (documents, images, PDFs, etc.) that have been uploaded to a specific lead, contact, or company. |
| `KOMMO_LIST_ENTITY_LINKS` | List Kommo Entity Links | Tool to get a list of entities linked to a specific entity in Kommo. Use when you need to retrieve contacts, companies, or leads linked to another entity. |
| `KOMMO_LIST_ENTITY_NOTES` | List Kommo Entity Notes | Tool to get a list of all notes for an entity type (leads, contacts, or companies) in Kommo CRM. Use when you need to retrieve notes across all entities of a specific type, not just for a single entity. |
| `KOMMO_LIST_ENTITY_TAGS` | List Kommo Entity Tags | Tool to get a list of tags for an entity type (leads, contacts, or companies). Use when you need to retrieve available tags for a specific entity type in Kommo CRM. |
| `KOMMO_LIST_EVENTS` | List Kommo Events | Tool to get a list of events from Kommo CRM with filtering options. Use when you need to retrieve events history, track changes to entities (leads, contacts, companies), or monitor specific event types like status changes, field updates, or assignment changes. |
| `KOMMO_LIST_EVENT_TYPES` | List Kommo Event Types | Tool to get a list of all available event types in Kommo CRM. Use when you need to see what event types can be used for filtering events or configuring webhooks. |
| `KOMMO_LIST_FIELD_GROUPS` | List Kommo Field Groups | Tool to get a list of custom field groups for an entity type in Kommo CRM. Use when you need to retrieve field group information to organize custom fields. |
| `KOMMO_LIST_FILES` | List Kommo Files | Tool to retrieve a list of files from Kommo Drive. Use when you need to search, filter, or browse files stored in the Kommo CRM system. Supports filtering by name, extension, size, date, creator, and other criteria. |
| `KOMMO_LIST_INCOMING_LEADS` | List Incoming Leads | Tool to get a list of incoming leads (unsorted) from Kommo with filtering and pagination. Use when you need to retrieve unprocessed leads that haven't been sorted into pipelines yet. Supports filtering by category (sip, mail, forms, chats), UID, and pipeline ID. |
| `KOMMO_LIST_LEADS` | List Kommo Leads | Action to list leads in Kommo CRM. |
| `KOMMO_LIST_LEADS_PIPELINES` | List Kommo Lead Pipelines | Action to list lead pipelines in Kommo CRM. |
| `KOMMO_LIST_LOSS_REASONS` | List Kommo Loss Reasons | Action to list loss reasons for leads in Kommo CRM. Use when you need to retrieve all available loss reasons that can be assigned to lost leads. |
| `KOMMO_LIST_NOTES_BY_ENTITY` | List Kommo Notes By Entity | Tool to get notes for a specific entity by its ID in Kommo CRM. Use when you need to retrieve all notes associated with a lead, contact, or company. |
| `KOMMO_LIST_PIPELINE_STAGES` | List Kommo Pipeline Stages | Action to list stages of a pipeline in Kommo CRM. |
| `KOMMO_LIST_ROLES` | List Kommo User Roles | Tool to get a list of user roles in Kommo CRM. Use when you need to retrieve available user roles and their permissions. |
| `KOMMO_LIST_SOURCES` | List Kommo Lead Sources | Tool to get a list of lead sources in Kommo CRM. Use when you need to retrieve all available lead sources that can be assigned to leads. |
| `KOMMO_LIST_TASKS` | List Kommo Tasks | Action to list tasks in Kommo CRM. |
| `KOMMO_LIST_TEMPLATES` | List Kommo Templates | Tool to get a list of message templates in Kommo CRM. Use when you need to retrieve chat response templates that can be utilized in cards and bots. |
| `KOMMO_LIST_USERS` | List Kommo Users | Tool to get a list of users from Kommo CRM with pagination support. Use when you need to retrieve all users in the account or paginate through the users list. |
| `KOMMO_LIST_WEBHOOKS` | List Kommo Webhooks | Tool to get a list of registered webhooks for the Kommo account. Use when you need to view all webhook configurations and their settings. |
| `KOMMO_LIST_WEBSITE_BUTTONS` | List Kommo Website Buttons | Tool to get a list of website chat button (CRM Plugin) objects from Kommo. Use when you need to retrieve all configured website chat buttons in the account. Supports pagination for large result sets. |
| `KOMMO_LIST_WIDGETS` | List Kommo Widgets | Tool to get a list of installed widgets in Kommo. Use when you need to see which widgets are installed and their current status in the account. |
| `KOMMO_UPDATE_COMPANY` | Update Kommo Company | Action to update a single company in Kommo CRM. |
| `KOMMO_UPDATE_CONTACT` | Update Kommo Contact | Action to update contact information in Kommo CRM by contact ID. |
| `KOMMO_UPDATE_LEAD` | Update Kommo Lead | Action to update an existing lead in Kommo CRM. Allows modifying lead properties including name, price, pipeline stage, responsible user, tags, and custom fields. Requires the lead ID to be specified. |
| `KOMMO_UPDATE_TASK` | Update Kommo Task | Action to update a task in Kommo CRM. |

## Supported Triggers

None listed.

## Creating MCP Server - Stand-alone vs Composio SDK

The Kommo MCP server is an implementation of the Model Context Protocol that connects your AI agent to Kommo. It provides structured and secure access so your agent can perform Kommo operations on your behalf through a secure, permission-based interface.
With Composio's managed implementation, you don't have to create your own developer app. For production, if you're building an end product, we recommend using your own credentials. The managed server helps you prototype fast and go from 0-1 faster.

## Step-by-step Guide

### 1. Prerequisites

Before starting, make sure you have:
- Composio API Key and OpenAI API Key
- Primary know-how of OpenAI Agents SDK
- A live Kommo project
- Some knowledge of Python or Typescript

### 1. Getting API Keys for OpenAI and Composio

OpenAI API Key
- Go to the [OpenAI dashboard](https://platform.openai.com/settings/organization/api-keys) and create an API key. You'll need credits to use the models, or you can connect to another model provider.
- Keep the API key safe.
Composio API Key
- Log in to the [Composio dashboard](https://dashboard.composio.dev?utm_source=toolkits&utm_medium=framework_docs).
- Go to Settings and copy your API key.

### 2. Install dependencies

Install the Composio SDK and the OpenAI Agents SDK.
```python
pip install composio_openai_agents openai-agents python-dotenv
```

```typescript
npm install @composio/openai-agents @openai/agents dotenv
```

### 3. Set up environment variables

Create a .env file and add your OpenAI and Composio API keys.
```bash
OPENAI_API_KEY=sk-...your-api-key
COMPOSIO_API_KEY=your-api-key
USER_ID=composio_user@gmail.com
```

### 4. Import dependencies

What's happening:
- You're importing all necessary libraries.
- The Composio and OpenAIAgentsProvider classes are imported to connect your OpenAI agent to Composio tools like Kommo.
```python
import asyncio
import os
from dotenv import load_dotenv

from composio import Composio
from composio_openai_agents import OpenAIAgentsProvider
from agents import Agent, Runner, HostedMCPTool, SQLiteSession
```

```typescript
import 'dotenv/config';
import { Composio } from '@composio/core';
import { OpenAIAgentsProvider } from '@composio/openai-agents';
import { Agent, hostedMcpTool, run, OpenAIConversationsSession } from '@openai/agents';
import * as readline from 'readline';
```

### 5. Set up the Composio instance

No description provided.
```python
load_dotenv()

api_key = os.getenv("COMPOSIO_API_KEY")
user_id = os.getenv("USER_ID")

if not api_key:
    raise RuntimeError("COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key")

# Initialize Composio
composio = Composio(api_key=api_key, provider=OpenAIAgentsProvider())
```

```typescript
dotenv.config();

const composioApiKey = process.env.COMPOSIO_API_KEY;
const userId = process.env.USER_ID;

if (!composioApiKey) {
  throw new Error('COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key');
}
if (!userId) {
  throw new Error('USER_ID is not set');
}

// Initialize Composio
const composio = new Composio({
  apiKey: composioApiKey,
  provider: new OpenAIAgentsProvider(),
});
```

### 6. Create a Tool Router session

What is happening:
- You give the Tool Router the user id and the toolkits you want available. Here, it is only kommo.
- The router checks the user's Kommo connection and prepares the MCP endpoint.
- The returned session.mcp.url is the MCP URL that your agent will use to access Kommo.
- This approach keeps things lightweight and lets the agent request Kommo tools only when needed during the conversation.
```python
# Create a Kommo Tool Router session
session = composio.create(
    user_id=user_id,
    toolkits=["kommo"]
)

mcp_url = session.mcp.url
```

```typescript
// Create Tool Router session for Kommo
const session = await composio.create(userId as string, {
  toolkits: ['kommo'],
});
const mcpUrl = session.mcp.url;
```

### 7. Configure the agent

No description provided.
```python
# Configure agent with MCP tool
agent = Agent(
    name="Assistant",
    model="gpt-5",
    instructions=(
        "You are a helpful assistant that can access Kommo. "
        "Help users perform Kommo operations through natural language."
    ),
    tools=[
        HostedMCPTool(
            tool_config={
                "type": "mcp",
                "server_label": "tool_router",
                "server_url": mcp_url,
                "headers": {"x-api-key": api_key},
                "require_approval": "never",
            }
        )
    ],
)
```

```typescript
// Configure agent with MCP tool
const agent = new Agent({
  name: 'Assistant',
  model: 'gpt-5',
  instructions:
    'You are a helpful assistant that can access Kommo. Help users perform Kommo operations through natural language.',
  tools: [
    hostedMcpTool({
      serverLabel: 'tool_router',
      serverUrl: mcpUrl,
      headers: { 'x-api-key': composioApiKey },
      requireApproval: 'never',
    }),
  ],
});
```

### 8. Start chat loop and handle conversation

No description provided.
```python
print("\nComposio Tool Router session created.")

chat_session = SQLiteSession("conversation_openai_toolrouter")

print("\nChat started. Type your requests below.")
print("Commands: 'exit', 'quit', or 'q' to end\n")

async def main():
    try:
        result = await Runner.run(
            agent,
            "What can you help me with?",
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")
    except Exception as e:
        print(f"Error: {e}\n")

    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in {"exit", "quit", "q"}:
            print("Goodbye!")
            break

        result = await Runner.run(
            agent,
            user_input,
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")

asyncio.run(main())
```

```typescript
// Keep conversation state across turns
const conversationSession = new OpenAIConversationsSession();

// Simple CLI
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  prompt: 'You: ',
});

console.log('\nComposio Tool Router session created.');
console.log('\nChat started. Type your requests below.');
console.log("Commands: 'exit', 'quit', or 'q' to end\n");

try {
  const first = await run(agent, 'What can you help me with?', { session: conversationSession });
  console.log(`Assistant: ${first.finalOutput}\n`);
} catch (e) {
  console.error('Error:', e instanceof Error ? e.message : e, '\n');
}

rl.prompt();

rl.on('line', async (userInput) => {
  const text = userInput.trim();

  if (['exit', 'quit', 'q'].includes(text.toLowerCase())) {
    console.log('Goodbye!');
    rl.close();
    process.exit(0);
  }

  if (!text) {
    rl.prompt();
    return;
  }

  try {
    const result = await run(agent, text, { session: conversationSession });
    console.log(`\nAssistant: ${result.finalOutput}\n`);
  } catch (e) {
    console.error('Error:', e instanceof Error ? e.message : e, '\n');
  }

  rl.prompt();
});

rl.on('close', () => {
  console.log('\n👋 Session ended.');
  process.exit(0);
});
```

## Complete Code

```python
import asyncio
import os
from dotenv import load_dotenv

from composio import Composio
from composio_openai_agents import OpenAIAgentsProvider
from agents import Agent, Runner, HostedMCPTool, SQLiteSession

load_dotenv()

api_key = os.getenv("COMPOSIO_API_KEY")
user_id = os.getenv("USER_ID")

if not api_key:
    raise RuntimeError("COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key")

# Initialize Composio
composio = Composio(api_key=api_key, provider=OpenAIAgentsProvider())

# Create Tool Router session
session = composio.create(
    user_id=user_id,
    toolkits=["kommo"]
)
mcp_url = session.mcp.url

# Configure agent with MCP tool
agent = Agent(
    name="Assistant",
    model="gpt-5",
    instructions=(
        "You are a helpful assistant that can access Kommo. "
        "Help users perform Kommo operations through natural language."
    ),
    tools=[
        HostedMCPTool(
            tool_config={
                "type": "mcp",
                "server_label": "tool_router",
                "server_url": mcp_url,
                "headers": {"x-api-key": api_key},
                "require_approval": "never",
            }
        )
    ],
)

print("\nComposio Tool Router session created.")

chat_session = SQLiteSession("conversation_openai_toolrouter")

print("\nChat started. Type your requests below.")
print("Commands: 'exit', 'quit', or 'q' to end\n")

async def main():
    try:
        result = await Runner.run(
            agent,
            "What can you help me with?",
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")
    except Exception as e:
        print(f"Error: {e}\n")

    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in {"exit", "quit", "q"}:
            print("Goodbye!")
            break

        result = await Runner.run(
            agent,
            user_input,
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")

asyncio.run(main())
```

```typescript
import 'dotenv/config';
import { Composio } from '@composio/core';
import { OpenAIAgentsProvider } from '@composio/openai-agents';
import { Agent, hostedMcpTool, run, OpenAIConversationsSession } from '@openai/agents';
import * as readline from 'readline';

const composioApiKey = process.env.COMPOSIO_API_KEY;
const userId = process.env.USER_ID;

if (!composioApiKey) {
  throw new Error('COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key');
}
if (!userId) {
  throw new Error('USER_ID is not set');
}

// Initialize Composio
const composio = new Composio({
  apiKey: composioApiKey,
  provider: new OpenAIAgentsProvider(),
});

async function main() {
  // Create Tool Router session
  const session = await composio.create(userId as string, {
    toolkits: ['kommo'],
  });
  const mcpUrl = session.mcp.url;

  // Configure agent with MCP tool
  const agent = new Agent({
    name: 'Assistant',
    model: 'gpt-5',
    instructions:
      'You are a helpful assistant that can access Kommo. Help users perform Kommo operations through natural language.',
    tools: [
      hostedMcpTool({
        serverLabel: 'tool_router',
        serverUrl: mcpUrl,
        headers: { 'x-api-key': composioApiKey },
        requireApproval: 'never',
      }),
    ],
  });

  // Keep conversation state across turns
  const conversationSession = new OpenAIConversationsSession();

  // Simple CLI
  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    prompt: 'You: ',
  });

  console.log('\nComposio Tool Router session created.');
  console.log('\nChat started. Type your requests below.');
  console.log("Commands: 'exit', 'quit', or 'q' to end\n");

  try {
    const first = await run(agent, 'What can you help me with?', { session: conversationSession });
    console.log(`Assistant: ${first.finalOutput}\n`);
  } catch (e) {
    console.error('Error:', e instanceof Error ? e.message : e, '\n');
  }

  rl.prompt();

  rl.on('line', async (userInput) => {
    const text = userInput.trim();

    if (['exit', 'quit', 'q'].includes(text.toLowerCase())) {
      console.log('Goodbye!');
      rl.close();
      process.exit(0);
    }

    if (!text) {
      rl.prompt();
      return;
    }

    try {
      const result = await run(agent, text, { session: conversationSession });
      console.log(`\nAssistant: ${result.finalOutput}\n`);
    } catch (e) {
      console.error('Error:', e instanceof Error ? e.message : e, '\n');
    }

    rl.prompt();
  });

  rl.on('close', () => {
    console.log('\nSession ended.');
    process.exit(0);
  });
}

main().catch((err) => {
  console.error('Fatal error:', err);
  process.exit(1);
});
```

## Conclusion

This was a starter code for integrating Kommo MCP with OpenAI Agents SDK to build a functional AI agent that can interact with Kommo.
Key features:
- Hosted MCP tool integration through Composio's Tool Router
- SQLite session persistence for conversation history
- Simple async chat loop for interactive testing
You can extend this by adding more toolkits, implementing custom business logic, or building a web interface around the agent.

## How to build Kommo MCP Agent with another framework

- [Claude Agent SDK](https://composio.dev/toolkits/kommo/framework/claude-agents-sdk)
- [Claude Code](https://composio.dev/toolkits/kommo/framework/claude-code)
- [Claude Cowork](https://composio.dev/toolkits/kommo/framework/claude-cowork)
- [Codex](https://composio.dev/toolkits/kommo/framework/codex)
- [OpenClaw](https://composio.dev/toolkits/kommo/framework/openclaw)
- [Hermes](https://composio.dev/toolkits/kommo/framework/hermes-agent)
- [CLI](https://composio.dev/toolkits/kommo/framework/cli)
- [Google ADK](https://composio.dev/toolkits/kommo/framework/google-adk)
- [LangChain](https://composio.dev/toolkits/kommo/framework/langchain)
- [Vercel AI SDK](https://composio.dev/toolkits/kommo/framework/ai-sdk)
- [Mastra AI](https://composio.dev/toolkits/kommo/framework/mastra-ai)
- [LlamaIndex](https://composio.dev/toolkits/kommo/framework/llama-index)
- [CrewAI](https://composio.dev/toolkits/kommo/framework/crew-ai)

## Related Toolkits

- [Hubspot](https://composio.dev/toolkits/hubspot) - HubSpot is an all-in-one marketing, sales, and customer service platform. It lets teams nurture leads, automate outreach, and track every customer interaction in one place.
- [Pipedrive](https://composio.dev/toolkits/pipedrive) - Pipedrive is a sales management platform offering pipeline visualization, lead tracking, and workflow automation. It helps sales teams keep deals moving forward efficiently and never miss a follow-up.
- [Salesforce](https://composio.dev/toolkits/salesforce) - Salesforce is a leading CRM platform that helps businesses manage sales, service, and marketing. It centralizes customer data, enabling teams to drive growth and build strong relationships.
- [Apollo](https://composio.dev/toolkits/apollo) - Apollo is a CRM and lead generation platform that helps businesses discover contacts and manage sales pipelines. Use it to streamline customer outreach and track your deals from one place.
- [Attio](https://composio.dev/toolkits/attio) - Attio is a customizable CRM and workspace for managing your team's relationships and workflows. It helps teams organize contacts, automate tasks, and collaborate more efficiently.
- [Acculynx](https://composio.dev/toolkits/acculynx) - AccuLynx is a cloud-based roofing business management software for contractors. It streamlines project tracking, lead management, and document sharing.
- [Addressfinder](https://composio.dev/toolkits/addressfinder) - Addressfinder is a data quality platform for verifying addresses, emails, and phone numbers. It helps you ensure accurate customer and contact data every time.
- [Affinity](https://composio.dev/toolkits/affinity) - Affinity is a relationship intelligence CRM that helps private capital investors find, manage, and close more deals. It streamlines deal flow and surfaces key connections to help you win opportunities.
- [Agencyzoom](https://composio.dev/toolkits/agencyzoom) - AgencyZoom is a sales and performance platform built for P&C insurance agencies. It helps agents boost sales, retain clients, and analyze producer results in one place.
- [Bettercontact](https://composio.dev/toolkits/bettercontact) - Bettercontact is a smart contact enrichment tool for finding emails and phone numbers. It helps boost lead generation with automated, waterfall search across multiple sources.
- [Blackbaud](https://composio.dev/toolkits/blackbaud) - Blackbaud provides cloud-based software for nonprofits, schools, and healthcare institutions. It streamlines fundraising, donor management, and mission-driven operations.
- [Brilliant directories](https://composio.dev/toolkits/brilliant_directories) - Brilliant Directories is an all-in-one platform for building and managing online membership communities and business directories. It streamlines listings, member management, and engagement tools into a single, easy interface.
- [Capsule crm](https://composio.dev/toolkits/capsule_crm) - Capsule CRM is a user-friendly CRM platform for managing contacts and sales pipelines. It helps businesses organize relationships and streamline their sales process efficiently.
- [Centralstationcrm](https://composio.dev/toolkits/centralstationcrm) - CentralStationCRM is an easy-to-use CRM software focused on collaboration and long-term customer relationships. It helps teams manage contacts, deals, and communications all in one place.
- [Clientary](https://composio.dev/toolkits/clientary) - Clientary is a platform for managing clients, invoices, projects, proposals, and more. It streamlines client work and saves you serious admin time.
- [Close](https://composio.dev/toolkits/close) - Close is a CRM platform built for sales teams, combining calling, email automation, and predictive dialers. It streamlines sales workflows and boosts productivity with all-in-one communication tools.
- [Dropcontact](https://composio.dev/toolkits/dropcontact) - Dropcontact is a B2B email finder and data enrichment service for professionals. It delivers verified email addresses and enriches contact info with up-to-date data.
- [Dynamics365](https://composio.dev/toolkits/dynamics365) - Dynamics 365 is Microsoft's platform combining CRM, ERP, and productivity apps. It streamlines sales, marketing, service, and operations in one place.
- [Espocrm](https://composio.dev/toolkits/espocrm) - EspoCRM is an open-source web application for managing customer relationships. It helps businesses organize contacts, track leads, and streamline their sales process.
- [Fireberry](https://composio.dev/toolkits/fireberry) - Fireberry is a CRM platform that streamlines customer and sales management. It helps businesses organize contacts, automate sales, and integrate with other business tools.

## Frequently Asked Questions

### What are the differences in Tool Router MCP and Kommo MCP?

With a standalone Kommo MCP server, the agents and LLMs can only access a fixed set of Kommo tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Kommo and many other apps based on the task at hand, all through a single MCP endpoint.

### Can I use Tool Router MCP with OpenAI Agents SDK?

Yes, you can. OpenAI Agents SDK fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Kommo tools.

### Can I manage the permissions and scopes for Kommo while using Tool Router?

Yes, absolutely. You can configure which Kommo scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

### How safe is my data with Composio Tool Router?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Kommo data and credentials are handled as safely as possible.

---
[See all toolkits](https://composio.dev/toolkits) · [Composio docs](https://docs.composio.dev/llms.txt)
