Skip to content

LlamaIndex

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

All frameworks Browse providers
  1. Install the packages

    install
    pip install llama-index-tools-mcp llama-index-llms-anthropic
  2. Wire up the agent

    agent.py
    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())

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

filter_tools.py
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)

function_agent.py
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?")

multi_user.py
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)

async_workflow.py
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))