How to integrate Intercom MCP with LlamaIndex

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Intercom logo
LlamaIndex logo
divider

Introduction

This guide walks you through connecting Intercom to LlamaIndex using the Composio tool router. By the end, you'll have a working Intercom agent that can add tag 'vip' to contact john doe, assign open conversation #123 to support team, create note for contact emily about refund through natural language commands.

This guide will help you understand how to give your LlamaIndex agent real control over a Intercom account through Composio's Intercom MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

Also integrate Intercom with

TL;DR

Here's what you'll learn:
  • Set your OpenAI and Composio API keys
  • Install LlamaIndex and Composio packages
  • Create a Composio Tool Router session for Intercom
  • Connect LlamaIndex to the Intercom MCP server
  • Build a Intercom-powered agent using LlamaIndex
  • Interact with Intercom through natural language

What is LlamaIndex?

LlamaIndex is a data framework for building LLM applications. It provides tools for connecting LLMs to external data sources and services through agents and tools.

Key features include:

  • ReAct Agent: Reasoning and acting pattern for tool-using agents
  • MCP Tools: Native support for Model Context Protocol
  • Context Management: Maintain conversation context across interactions
  • Async Support: Built for async/await patterns

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

The Intercom MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Intercom account. It provides structured and secure access to your customer engagement platform, so your agent can perform actions like managing conversations, tagging contacts, creating articles, and updating company records on your behalf.

  • Conversation management and assignment: Let your agent assign conversations to teams or admins, create new conversations, and close them when resolved, streamlining your support workflow.
  • Contact tagging and note creation: Effortlessly tag contacts with relevant labels or add detailed notes for context, making customer follow-ups more organized and actionable.
  • Automated company and contact updates: Enable your agent to attach contacts to companies, create or update company records, and keep your Intercom data clean and up to date.
  • Article and collection creation: Let your agent publish new articles or create help center collections to expand your self-serve support resources without manual effort.
  • Subscription and message preferences management: Allow your agent to add or manage subscriptions for contacts, helping you personalize communication and respect user preferences automatically.

Supported Tools & Triggers

Tools
Add subscription to a contactYou can add a specific subscription to a contact.
Add tag to contactTool to add a tag to a contact in Intercom.
Archive contactTool to archive a single contact in Intercom.
Assign conversationAssigns a conversation to a specific admin or team in Intercom.
Attach contact to companyTool to attach a contact to a company in Intercom.
Attach contact to conversationTool to attach a contact participant to a conversation on behalf of admin or contact.
Attach tag to conversationTool to add a tag to a specific conversation in Intercom.
Attach tag to ticketTool to add a tag to a ticket in Intercom.
Block contactTool to block a single contact in Intercom.
Cancel data exportTool to cancel an active content data export job.
Close conversationCloses a conversation in Intercom, marking it as resolved.
Create a collectionYou can create a new collection by making a POST request to `https://api.
Create an articleYou can create a new article by making a POST request to `https://api.
Create a noteYou can add a note to a single contact.
Create contactTool to create a new contact in Intercom workspace.
Create content import sourceTool to create a new content import source for the Fin Content Library.
Create conversationCreates a new conversation in Intercom.
Create data attributeTool to create a custom data attribute for contacts or companies.
Create data eventTool to submit a data event to Intercom to track user activities.
Create data exportTool to initiate an async data export job for message content.
Create external pageTool to create an external page in Fin Content Library or update an existing page by external ID.
Create help center sectionTool to create a new help center section within a collection.
Create internal articleTool to create a new internal article for team knowledge sharing.
Create or update a companyYou can create or update a company.
Create or update tagTool to create or update a tag, and optionally tag/untag companies or tag contacts.
Create ticketTool to create a ticket in Intercom to track customer requests and issues.
Create a ticket typeTool to create a new ticket type that defines the data structure for tracking customer requests.
Create ticket type attributeTool to create a new attribute for a ticket type in Intercom.
Create event summariesTool to create event summaries for a user to track event occurrences.
Delete a collectionYou can delete a single collection by making a DELETE request to `https://api.
Delete a companyYou can delete a single company.
Delete an articleYou can delete a single article by making a DELETE request to `https://api.
Delete a tagTool to delete a tag from Intercom workspace.
Delete a visitorTool to delete a visitor from the Intercom workspace.
Delete a contactTool to delete a contact from the Intercom workspace.
Delete content import sourceTool to delete a content import source and all its external pages.
Delete external pageTool to delete an external page from content library and AI answers.
Delete internal articleTool to delete a single internal article by ID.
Delete ticketTool to delete a ticket from the Intercom system.
Detach a contact from tagTool to remove a tag from a specific contact in Intercom.
Detach contact from companyTool to detach a contact from a company in Intercom.
Detach tag from conversationTool to remove a tag from a specific conversation in Intercom.
Detach tag from ticketTool to remove a tag from a ticket in Intercom.
Download data exportTool to download content data export from Intercom.
Enqueue create ticketTool to enqueue ticket creation for asynchronous processing.
Find a tagTool to retrieve details for a specific tag by its ID.
Get a contactYou can fetch the details of a single contact.
Get content import sourceTool to retrieve a content import source by its ID.
Get conversationRetrieves a specific conversation by ID with all messages and details.
Get entity countsTool to retrieve summary counts for Intercom app entities including companies, users, leads, tags, segments, and conversations.
Get custom object instance by external IDTool to retrieve a custom object instance by its external_id.
Get external pageTool to retrieve an external page from Fin Content Library by ID.
Get ticketTool to retrieve a ticket from Intercom.
Get a ticket typeTool to retrieve details for a specific ticket type by its ID.
Identify an adminYou can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology).
Retrieve job statusTool to retrieve the status of job execution.
List all activity logsYou can get a log of activities by all admins in an app.
List all adminsYou can fetch a list of admins for a given workspace.
List all articlesYou can fetch a list of all articles by making a GET request to `https://api.
List all collectionsYou can fetch a list of all collections by making a GET request to `https://api.
List all companiesYou can list companies.
List all help centersYou can list all Help Centers by making a GET request to `https://api.
List all macrosTool to fetch a list of all macros (saved replies) in your workspace for use in automating responses.
List all notesYou can fetch a list of notes that are associated to a contact.
List attached companies for contactYou can fetch a list of companies that are associated to a contact.
List attached contactsYou can fetch a list of all contacts that belong to a company.
List attached segments for companiesYou can fetch a list of all segments that belong to a company.
List attached segments for contactYou can fetch a list of segments that are associated to a contact.
List away status reasonsTool to retrieve all away status reasons for a workspace including deleted ones.
List callsTool to list all phone calls from Intercom with pagination support.
List calls with transcriptsTool to retrieve calls by conversation IDs with transcripts when available.
List company notesTool to list all notes associated with a specific company.
List all contactsTool to list all contacts (users or leads) in your Intercom workspace with pagination support.
List content import sourcesTool to retrieve all content import sources for the workspace.
List conversationsLists all conversations from Intercom with pagination support.
List data attributesTool to list all data attributes for contacts, companies, and conversations.
List data eventsTool to retrieve a log of data events belonging to a customer.
List external pagesTool to list all external pages from Fin Content Library.
List help center sectionsTool to fetch a list of all help center sections in descending order by updated_at.
List internal articlesFetches one page of internal articles from Intercom.
List all news itemsTool to fetch a list of all news items from Intercom.
List all segmentsTool to retrieve all segments defined within a workspace for filtering and categorizing contacts.
List subscriptions for a contactYou can fetch a list of subscription types that are attached to a contact.
List subscription typesTool to list all subscription types available in the workspace.
List all tagsTool to fetch all tags for the workspace.
List tags attached to a contactYou can fetch a list of all tags that are attached to a specific contact.
List all teamsTool to retrieve all teams within a workspace.
List all ticket statesTool to fetch all ticket states for the workspace.
List all ticket typesTool to retrieve all ticket types for the workspace.
Merge a lead and a userYou can merge a contact with a `role` of `lead` into a contact with a `role` of `user`.
Register Fin Voice callTool to register a Fin Voice call with Intercom.
Remove subscription from a contactYou can remove a specific subscription from a contact.
Remove tag from a contactYou can remove tag from a specific contact.
Reopen conversationReopens a closed conversation in Intercom.
Reply to ticketTool to reply to a ticket with a message from admin or contact, or with a note for admins.
Reply to conversationSends a reply to an existing conversation in Intercom.
Retrieve a collectionYou can fetch the details of a single collection by making a GET request to `https://api.
Retrieve a company by idYou can fetch a single company.
Retrieve a help centerYou can fetch the details of a single Help Center by making a GET request to `https://api.
Retrieve job statusTool to retrieve the status of a data export job.
Retrieve a macroTool to fetch a single macro (saved reply) by its ID.
Retrieve an adminYou can retrieve the details of a single admin.
Retrieve an articleYou can fetch the details of a single article by making a GET request to `https://api.
Retrieve a segmentTool to retrieve details for a single segment by its ID.
Retrieve companiesYou can fetch a single company by passing in `company_id` or `name`.
Retrieve internal articleTool to retrieve an internal article by ID from Intercom.
Retrieve noteTool to retrieve details of a single note by its identifier.
Retrieve a teamTool to retrieve detailed information about a specific team by ID.
Retrieve visitor with user IDTool to retrieve a specific visitor's details using their user_id.
Scroll over all companiesThe `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply.
Search contactsTool to search for contacts using query filters with operators.
Search conversationsSearches for conversations using query string with support for filtering and sorting
Search for articlesYou can search for articles by making a GET request to `https://api.
Search internal articlesSearches one page of internal articles in Intercom.
Search ticketsTool to search tickets in Intercom by filtering attribute values.
Set admin to awayTool to set an admin to away status in Intercom.
Set an admin to awayYou can set an Admin as away for the Inbox.
Show callTool to retrieve a single call by ID from Intercom.
Show call transcriptTool to get call transcript by call ID.
Show contact by external IDTool to retrieve a contact by their external ID.
Unarchive contactTool to unarchive a previously archived contact in Intercom.
Update a collectionYou can update the details of a single collection by making a PUT request to `https://api.
Update a companyYou can update a single company using the Intercom provisioned `id`.
Update a contactYou can update an existing contact (ie.
Update an articleYou can update the details of a single article by making a PUT request to `https://api.
Update contactTool to update an existing contact in Intercom.
Update content import sourceTool to update an existing content import source in Fin Content Library.
Update data attributeTool to update an existing data attribute in Intercom.
Update external pageTool to update an existing external page in Fin Content Library.
Update internal articleTool to update an internal article with new title, body, author or owner information.
Update ticketTool to update an existing ticket in Intercom.
Update a ticket typeTool to update an existing ticket type in the workspace.
Update ticket type attributeTool to update an existing attribute for a ticket type.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Prerequisites

Before you begin, make sure you have:
  • Python 3.8/Node 16 or higher installed
  • A Composio account with the API key
  • An OpenAI API key
  • A Intercom account and project
  • Basic familiarity with async Python/Typescript

Getting API Keys for OpenAI, Composio, and Intercom

OpenAI API key (OPENAI_API_KEY)
  • Go to the OpenAI dashboard
  • Create an API key if you don't have one
  • Assign it to OPENAI_API_KEY in .env
Composio API key and user ID
  • Log into the Composio dashboard
  • Copy your API key from Settings
    • Use this as COMPOSIO_API_KEY
  • Pick a stable user identifier (email or ID)
    • Use this as COMPOSIO_USER_ID

Installing dependencies

pip install composio-llamaindex llama-index llama-index-llms-openai llama-index-tools-mcp python-dotenv

Create a new Python project and install the necessary dependencies:

  • composio-llamaindex: Composio's LlamaIndex integration
  • llama-index: Core LlamaIndex framework
  • llama-index-llms-openai: OpenAI LLM integration
  • llama-index-tools-mcp: MCP client for LlamaIndex
  • python-dotenv: Environment variable management

Set environment variables

bash
OPENAI_API_KEY=your-openai-api-key
COMPOSIO_API_KEY=your-composio-api-key
COMPOSIO_USER_ID=your-user-id

Create a .env file in your project root:

These credentials will be used to:

  • Authenticate with OpenAI's GPT-5 model
  • Connect to Composio's Tool Router
  • Identify your Composio user session for Intercom access

Import modules

import asyncio
import os
import dotenv

from composio import Composio
from composio_llamaindex import LlamaIndexProvider
from llama_index.core.agent.workflow import ReActAgent
from llama_index.core.workflow import Context
from llama_index.llms.openai import OpenAI
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec

dotenv.load_dotenv()

Create a new file called intercom_llamaindex_agent.py and import the required modules:

Key imports:

  • asyncio: For async/await support
  • Composio: Main client for Composio services
  • LlamaIndexProvider: Adapts Composio tools for LlamaIndex
  • ReActAgent: LlamaIndex's reasoning and action agent
  • BasicMCPClient: Connects to MCP endpoints
  • McpToolSpec: Converts MCP tools to LlamaIndex format

Load environment variables and initialize Composio

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not OPENAI_API_KEY:
    raise ValueError("OPENAI_API_KEY is not set in the environment")
if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set in the environment")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set in the environment")

What's happening:

This ensures missing credentials cause early, clear errors before the agent attempts to initialise.

Create a Tool Router session and build the agent function

async def build_agent() -> ReActAgent:
    composio_client = Composio(
        api_key=COMPOSIO_API_KEY,
        provider=LlamaIndexProvider(),
    )

    session = composio_client.create(
        user_id=COMPOSIO_USER_ID,
        toolkits=["intercom"],
    )

    mcp_url = session.mcp.url
    print(f"Composio MCP URL: {mcp_url}")

    mcp_client = BasicMCPClient(mcp_url, headers={"x-api-key": COMPOSIO_API_KEY})
    mcp_tool_spec = McpToolSpec(client=mcp_client)
    tools = await mcp_tool_spec.to_tool_list_async()

    llm = OpenAI(model="gpt-5")

    description = "An agent that uses Composio Tool Router MCP tools to perform Intercom actions."
    system_prompt = """
    You are a helpful assistant connected to Composio Tool Router.
    Use the available tools to answer user queries and perform Intercom actions.
    """
    return ReActAgent(tools=tools, llm=llm, description=description, system_prompt=system_prompt, verbose=True)

What's happening here:

  • We create a Composio client using your API key and configure it with the LlamaIndex provider
  • We then create a tool router MCP session for your user, specifying the toolkits we want to use (in this case, intercom)
  • The session returns an MCP HTTP endpoint URL that acts as a gateway to all your configured tools
  • LlamaIndex will connect to this endpoint to dynamically discover and use the available Intercom tools.
  • The MCP tools are mapped to LlamaIndex-compatible tools and plug them into the Agent.

Create an interactive chat loop

async def chat_loop(agent: ReActAgent) -> None:
    ctx = Context(agent)
    print("Type 'quit', 'exit', or Ctrl+C to stop.")

    while True:
        try:
            user_input = input("\nYou: ").strip()
        except (KeyboardInterrupt, EOFError):
            print("\nBye!")
            break

        if not user_input or user_input.lower() in {"quit", "exit"}:
            print("Bye!")
            break

        try:
            print("Agent: ", end="", flush=True)
            handler = agent.run(user_input, ctx=ctx)

            async for event in handler.stream_events():
                # Stream token-by-token from LLM responses
                if hasattr(event, "delta") and event.delta:
                    print(event.delta, end="", flush=True)
                # Show tool calls as they happen
                elif hasattr(event, "tool_name"):
                    print(f"\n[Using tool: {event.tool_name}]", flush=True)

            # Get final response
            response = await handler
            print()  # Newline after streaming
        except KeyboardInterrupt:
            print("\n[Interrupted]")
            continue
        except Exception as e:
            print(f"\nError: {e}")

What's happening here:

  • We're creating a direct terminal interface to chat with your Intercom database
  • The LLM's responses are streamed to the CLI for faster interaction.
  • The agent uses context to maintain conversation history
  • You can type 'quit' or 'exit' to stop the chat loop gracefully
  • Agent responses and any errors are displayed in a clear, readable format

Define the main entry point

async def main() -> None:
    agent = await build_agent()
    await chat_loop(agent)

if __name__ == "__main__":
    # Handle Ctrl+C gracefully
    signal.signal(signal.SIGINT, lambda s, f: (print("\nBye!"), exit(0)))
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print("\nBye!")

What's happening here:

  • We're orchestrating the entire application flow
  • The agent gets built with proper error handling
  • Then we kick off the interactive chat loop so you can start talking to Intercom

Run the agent

npx ts-node llamaindex-agent.ts

When prompted, authenticate and authorise your agent with Intercom, then start asking questions.

Complete Code

Here's the complete code to get you started with Intercom and LlamaIndex:

import asyncio
import os
import signal
import dotenv

from composio import Composio
from composio_llamaindex import LlamaIndexProvider
from llama_index.core.agent.workflow import ReActAgent
from llama_index.core.workflow import Context
from llama_index.llms.openai import OpenAI
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec

dotenv.load_dotenv()

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not OPENAI_API_KEY:
    raise ValueError("OPENAI_API_KEY is not set")
if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set")

async def build_agent() -> ReActAgent:
    composio_client = Composio(
        api_key=COMPOSIO_API_KEY,
        provider=LlamaIndexProvider(),
    )

    session = composio_client.create(
        user_id=COMPOSIO_USER_ID,
        toolkits=["intercom"],
    )

    mcp_url = session.mcp.url
    print(f"Composio MCP URL: {mcp_url}")

    mcp_client = BasicMCPClient(mcp_url, headers={"x-api-key": COMPOSIO_API_KEY})
    mcp_tool_spec = McpToolSpec(client=mcp_client)
    tools = await mcp_tool_spec.to_tool_list_async()

    llm = OpenAI(model="gpt-5")
    description = "An agent that uses Composio Tool Router MCP tools to perform Intercom actions."
    system_prompt = """
    You are a helpful assistant connected to Composio Tool Router.
    Use the available tools to answer user queries and perform Intercom actions.
    """
    return ReActAgent(
        tools=tools,
        llm=llm,
        description=description,
        system_prompt=system_prompt,
        verbose=True,
    );

async def chat_loop(agent: ReActAgent) -> None:
    ctx = Context(agent)
    print("Type 'quit', 'exit', or Ctrl+C to stop.")

    while True:
        try:
            user_input = input("\nYou: ").strip()
        except (KeyboardInterrupt, EOFError):
            print("\nBye!")
            break

        if not user_input or user_input.lower() in {"quit", "exit"}:
            print("Bye!")
            break

        try:
            print("Agent: ", end="", flush=True)
            handler = agent.run(user_input, ctx=ctx)

            async for event in handler.stream_events():
                # Stream token-by-token from LLM responses
                if hasattr(event, "delta") and event.delta:
                    print(event.delta, end="", flush=True)
                # Show tool calls as they happen
                elif hasattr(event, "tool_name"):
                    print(f"\n[Using tool: {event.tool_name}]", flush=True)

            # Get final response
            response = await handler
            print()  # Newline after streaming
        except KeyboardInterrupt:
            print("\n[Interrupted]")
            continue
        except Exception as e:
            print(f"\nError: {e}")

async def main() -> None:
    agent = await build_agent()
    await chat_loop(agent)

if __name__ == "__main__":
    # Handle Ctrl+C gracefully
    signal.signal(signal.SIGINT, lambda s, f: (print("\nBye!"), exit(0)))
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print("\nBye!")

Conclusion

You've successfully connected Intercom to LlamaIndex through Composio's Tool Router MCP layer. Key takeaways:
  • Tool Router dynamically exposes Intercom tools through an MCP endpoint
  • LlamaIndex's ReActAgent handles reasoning and orchestration; Composio handles integrations
  • The agent becomes more capable without increasing prompt size
  • Async Python provides clean, efficient execution of agent workflows
You can easily extend this to other toolkits like Gmail, Notion, Stripe, GitHub, and more by adding them to the toolkits parameter.

How to build Intercom MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Intercom MCP?

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

Can I use Tool Router MCP with LlamaIndex?

Yes, you can. LlamaIndex 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 Intercom tools.

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

Yes, absolutely. You can configure which Intercom 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 Intercom data and credentials are handled as safely as possible.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.