Creativity · MCP — integration
Using MCP Servers in LlamaIndex
LlamaIndex supports MCP servers as first-class tool sources through its `llama-index-tools-mcp` package. Any MCP server — stdio, SSE, or streamable HTTP — becomes a set of FunctionTool objects you can hand to a LlamaIndex Agent or Workflow. It's the fastest way to bring MCP tools (filesystem, Postgres, Slack, etc.) into a LlamaIndex RAG or agent pipeline without writing custom tool wrappers.
MCP facts
- Kind
- integration
- Ecosystem
- anthropic-mcp
- Language
- Python
- Transports
- stdio, http, sse
Capabilities
- BasicMCPClient connects to an MCP server
- McpToolSpec converts the server's tool list to LlamaIndex FunctionTools
- Drop tools into AgentWorkflow or ReActAgent
Install
pip install llama-index llama-index-tools-mcp Configuration
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.anthropic import Anthropic
client = BasicMCPClient(
command_or_url="npx",
args=["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
)
tool_spec = McpToolSpec(client=client)
tools = await tool_spec.to_tool_list_async()
agent = FunctionAgent(llm=Anthropic(model="claude-opus-4-7"), tools=tools) Frequently asked questions
What does LlamaIndex's MCP integration do?
It introspects an MCP server's tools and exposes each one as a LlamaIndex FunctionTool. Your agent or workflow calls them like any other tool; the integration handles MCP session lifecycle.
Can I use it with streaming HTTP MCP servers?
Yes. Pass an http:// or https:// URL to BasicMCPClient instead of a command+args, and the adapter uses the HTTP transport with SSE.
Does it work with LlamaIndex Workflows?
Yes. The tools are standard LlamaIndex tools, so you can register them on AgentWorkflow or use them inside custom Workflow event handlers.
Sources
- llama-index-tools-mcp — accessed 2026-04-20
- LlamaIndex docs — accessed 2026-04-20