Find answers from the community

Updated 14 hours ago

Integrate MCP tools into LlamaIndex

At a glance

A community member has written a blog post and provided an end-to-end example demonstrating how to convert the MCP (Model Context Protocol) tool to the LlamaIndex tool. The post has generated interest from other community members, with some expressing difficulties in integrating MCP with LlamaIndex in the past. The community members have discussed the provided demo code, which simplifies the integration process by having LlamaIndex implement the ToolAdapter. One community member is considering contributing an MCPToolSpec to the LlamaIndex framework, which would allow for easier integration of MCP tools. Another community member has already started working on implementing support for MCP tools in the LlamaIndex project.

Useful resources
hi everyone , I wrote a blog and end-to-end example showing how to convert the MCP (Model Context Protocol) tool to the ready-to-use LlamaIndex tool, hope you guys like it! https://psiace.me/posts/integrate-mcp-tools-into-llamaindex/
P
L
0
13 comments
When MCP first came out, I wanted to integrate it with llama-index officially, but all their docs/guides made zero sense (for example, the server and client needing to start in the same process/script ??)

Will be giving this a read!
Their official example is not clear enough, you can check out the demo code I provided. Essentially, LlamaIndex just needs to implement the ToolAdapter and doesn't need to care about the rest.
I might use this code to contribute some kind of MCPToolSpec to the framework πŸ™‚ It would be very cool if you could do something like

pip install llama-index-tools-mcp

Plain Text
from llama_index.tools.mcp import MCPToolSpec

tool_spec = MCPToolSpec(url, allowed_tools=["tool_name1", tool_name2"])

tools = tool_spec.to_tool_list()
agent = AgentWorkflow.from_tools_or_functions(tools)
Sounds good, I might check it out later. I use llamaindex at work and have recently started trying to integrate mcp.
cc @Logan M https://github.com/run-llama/llama_index/pull/17795 I've roughly implemented a simple version for initially providing support for mcp tools.
awesome! I will review this later today. Appreciate you getting that in so quickly
oh wait so there's mcp support now?
And it supports SSE!
Now let's see that sse auth support
Add a reply
Sign up and join the conversation on Discord