> For the complete documentation index, see [llms.txt](https://docs.allmcp.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.allmcp.co/documentation/agent-frameworks/llama-index.md).

# LlamaIndex

Use AllMCP tools in LlamaIndex agents via the MCP tool spec.

<a href="/pages/uBaUeZYQpupBMd5c1BY0" class="button secondary" data-icon="layer-group">All frameworks</a> <a href="/pages/QJVxDLqxIz5KMCH5afbE" class="button secondary" data-icon="table-cells">Browse providers</a>

***

## Setup

{% stepper %}
{% step %}

#### Install the packages

{% code title="install" %}

```bash
pip install llama-index-tools-mcp llama-index-llms-anthropic
```

{% endcode %}
{% endstep %}

{% step %}

#### Wire up the agent

{% code title="agent.py" overflow="wrap" %}

```python
import asyncio
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec
from llama_index.llms.anthropic import Anthropic
from llama_index.core.agent.workflow import ReActAgent


async def main():
    mcp_client = BasicMCPClient(
        command_or_url="https://go.allmcp.co/mcp/",
        headers={"X-API-Key": "YOUR_API_KEY"},
    )

    tool_spec = McpToolSpec(client=mcp_client)
    tools = await tool_spec.to_tool_list_async()

    llm = Anthropic(model="claude-sonnet-4-6")
    agent = ReActAgent(tools=tools, llm=llm)

    response = await agent.run("List my open deals in Bitrix24")
    print(response)


asyncio.run(main())
```

{% endcode %}
{% endstep %}
{% endstepper %}

{% hint style="info" %}
**Native MCP support.** LlamaIndex talks to AllMCP through the `McpToolSpec` tool spec, so your provider tools are available to the agent with no extra adapter code.
{% endhint %}

***

## Filtering tools

AllMCP exposes many tools. You can filter to only the ones you need:

{% code title="filter\_tools.py" overflow="wrap" %}

```python
all_tools = await tool_spec.to_tool_list_async()

# Keep only Bitrix24 tools
bitrix_tools = [t for t in all_tools if t.metadata.name.startswith("bitrix24_")]

agent = ReActAgent(tools=bitrix_tools, llm=llm)
```

{% endcode %}

***

## Using with FunctionAgent

{% code title="function\_agent.py" overflow="wrap" %}

```python
from llama_index.core.agent.workflow import FunctionAgent

agent = FunctionAgent(tools=tools, llm=llm)
response = await agent.run("What Google Sheets do I have access to?")
```

{% endcode %}

***

## Multi-user setup

{% code title="multi\_user.py" overflow="wrap" %}

```python
def make_tools_for_user(user_id: str):
    client = BasicMCPClient(
        command_or_url=f"https://go.allmcp.co/mcp/?user_id={user_id}",
        headers={"X-API-Key": "YOUR_API_KEY"},
    )
    return McpToolSpec(client=client)
```

{% endcode %}

{% hint style="info" %}
**One key, many users.** Append `?user_id=<id>` to the endpoint so each of your users works with their own connected accounts while you keep a single `X-API-Key`.
{% endhint %}

***

## Async workflow

{% code title="async\_workflow\.py" overflow="wrap" %}

```python
async def answer_question(user_id: str, question: str) -> str:
    spec = make_tools_for_user(user_id)
    tools = await spec.to_tool_list_async()
    agent = ReActAgent(tools=tools, llm=Anthropic(model="claude-sonnet-4-6"))
    return str(await agent.run(question))
```

{% endcode %}

***

## See also

{% content-ref url="/pages/uBaUeZYQpupBMd5c1BY0" %}
[Overview](/documentation/agent-frameworks/frameworks.md)
{% endcontent-ref %}

{% content-ref url="/pages/QJVxDLqxIz5KMCH5afbE" %}
[All Providers](/documentation/providers/providers.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.allmcp.co/documentation/agent-frameworks/llama-index.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
