Discover and Integrate External Tools
LlamaIndex tool that lets agents find MCP servers by natural-language request through a separately hosted MCP Discovery server.
0.14.24Add to Favorites
Why it matters
Dynamically discover and integrate external tools into your LlamaIndex agents by querying a Model Context Protocol (MCP) Discovery server. Enables agents to find and utilize new functionalities autonomously.
Outcomes
What it gets done
Query MCP Discovery servers for available tools.
Retrieve tool metadata and descriptions.
Integrate discovered tools into LlamaIndex agents.
Enable agents to find tools based on natural language queries.
Source
Get it from source
Spark does not host a copy of it.
Open sourceReports
Agent outcome reports
No reports yet
Capabilities
Tools your agent gets
Query MCP servers to discover available tools based on natural language descriptions
Overview
LlamaIndex Tool: MCP Discovery
A LlamaIndex tool that lets agents query an MCP Discovery server to find MCP servers from a natural-language request. It is a client only and needs a self-hosted discovery server. Use it when an agent should discover MCP servers dynamically and you can host an MCP Discovery server. It does not work without one.
What it does
LlamaIndex Tool: MCP Discovery lets LlamaIndex agents query a Model Context Protocol (MCP) Discovery server to find and retrieve other tools dynamically. An agent describes what it needs in natural language, and the tool returns recommended MCP servers that can do it. The README example asks the agent to find a server that can send Slack notifications.
The tool is a client only. It is emphatic that this integration does not work out of the box: it requires a separately deployed MCP Discovery server, which you must self-host locally or deploy to your own cloud, and it assumes an existing, reachable server.
The features listed are autonomous tool discovery from natural-language descriptions, async operations built on aiohttp, seamless integration with LlamaIndex agents through BaseToolSpec, and graceful error handling with informative messages.
When to use - and when NOT to
Use it when you want an agent to discover MCP servers it does not yet know about instead of hard-coding a tool list. Do not use it if you cannot run or reach an MCP Discovery server, because the tool cannot function without one.
The requirements are Python 3.9 or later, llama-index-core 0.13.0 or later and aiohttp 3.8.0 or later.
Inputs and outputs
The input is a natural-language request handled through the discover_tools function that the tool exposes to the agent. You create MCPDiscoveryTool with an api_url for the discovery API, call to_tool_list to get FunctionTools, and pass them to an agent such as ReActAgent. Install the package with:
pip install llama-index-tools-mcp-discovery
The API is expected to return the standard MCP Discovery schema: a list of recommendations, each with server, name, npm_package, install_command, confidence, description, category and github_url, plus total_found and query_time_ms. To save context window space, the tool summarizes this JSON into a concise string containing only the name, server and category, so the model can choose a tool without being overwhelmed by installation details.
Integrations
For the discovery server it lists three environment variables: SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY and OPENAI_API_KEY. The server itself is deployed from the yksanjo/mcp-discovery repository, cloned and installed with npm. The client side integrates with LlamaIndex agents through BaseToolSpec. For development, the README provides make test, make lint and make format, and an examples directory holds more usage examples.
Who it's for
It is for developers building LlamaIndex agents that need to find MCP servers on demand and who are able to host their own MCP Discovery server.
Source README
LlamaIndex Tool: MCP Discovery
This tool allows LlamaIndex agents to query a Model Context Protocol (MCP) Discovery server to find and retrieve other tools dynamically.
⚠️ Important Note
This MCP Discovery integration does not work out of the box.
It requires a separately deployed MCP Discovery server, which you must self-host locally or deploy to your own cloud.
This tool acts only as a client and assumes an existing, reachable MCP Discovery server.
Required Environment Variables
SUPABASE_URL=your-supabase-url
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
OPENAI_API_KEY=your-openai-api-key
Deploying the MCP Discovery Server
git clone https://github.com/yksanjo/mcp-discovery.git
cd mcp-discovery
npm install
Features
- 🔍 Autonomous Tool Discovery: Query MCP servers to discover available tools based on natural language descriptions
- ⚡ Async Operations: Built with
aiohttpfor high-performance async operations - 🤖 Seamless Integration: Works directly with LlamaIndex agents via
BaseToolSpec - 🛡️ Error Handling: Graceful error handling with informative messages
Requirements
- Python >= 3.9
- llama-index-core >= 0.13.0
- aiohttp >= 3.8.0
Installation
pip install llama-index-tools-mcp-discovery
Usage
from llama_index.tools.mcp_discovery import MCPDiscoveryTool
from llama_index.core.agent import ReActAgent
# Initialize the tool with the MCP Discovery API
tool_spec = MCPDiscoveryTool(
api_url="https://mcp-discovery-two.vercel.app/api/v1/discover"
)
# Convert the spec to a list of FunctionTools
tools = tool_spec.to_tool_list()
# Create an agent with the discovery tool
agent = ReActAgent.from_tools(tools, verbose=True)
# The agent can now use the 'discover_tools' function to find MCP servers it needs
agent.chat("Find me a server that can send Slack notifications")
API Response Format
This tool uses the standard MCP Discovery response schema as defined in the MCP Discovery. The API should return responses following this format:
{
"recommendations": [
{
"server": "filesystem-server",
"name": "Filesystem Server",
"npm_package": "@modelcontextprotocol/server-filesystem",
"install_command": "npx -y @modelcontextprotocol/server-filesystem",
"confidence": 0.85,
"description": "Secure file operations for MCP...",
"category": "development",
"github_url": "https://github.com/modelcontextprotocol/servers"
}
],
"total_found": 10,
"query_time_ms": 52
}
Note: To optimize context window usage, the tool summarizes the raw JSON into a concise string containing only the name, server, and category. This allows the LLM to efficiently evaluate and select the best tool without being overwhelmed by installation metadata.
Examples
See the examples directory for more usage examples.
Development
Run tests:
make test
Run linters:
make lint
Format code:
make format
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.