MCP Connector

Discover and Integrate External Tools

Query a self-hosted MCP Discovery server to find other MCP tools dynamically from a LlamaIndex agent.

Works with openaisupabase

76
Spark score
out of 100
Updated 8 days ago
Version 0.14.23

Add 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

01

Query MCP Discovery servers for available tools.

02

Retrieve tool metadata and descriptions.

03

Integrate discovered tools into LlamaIndex agents.

04

Enable agents to find tools based on natural language queries.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-tool-tools-mcp-discovery | bash

Capabilities

Tools your agent gets

discover_tools

Query MCP servers to discover available tools based on natural language descriptions

Overview

LlamaIndex Tool: MCP Discovery

A LlamaIndex client tool that queries a self-hosted MCP Discovery server to find and recommend other MCP tools by natural language. Use only if you already run or are willing to deploy your own MCP Discovery server - there is no bundled hosted endpoint.

What it does

MCP Discovery lets a LlamaIndex agent query a Model Context Protocol Discovery server to find and retrieve other tools dynamically, based on a natural-language description of what it needs. This integration does not work out of the box - it requires a separately deployed MCP Discovery server that you self-host locally or deploy to your own cloud; this package is only the client, assuming an existing, reachable Discovery server.

MCPDiscoveryTool is initialized with an api_url pointing at the deployed Discovery server's discover endpoint, and its discover_tools function lets the agent search for a server matching a description, such as "Find me a server that can send Slack notifications." The Discovery server itself follows a standard response schema: each recommendation includes a server slug, a human-readable name, an npm_package, an install_command, a confidence score, a description, a category, and a github_url, alongside total_found and query_time_ms at the top level. To keep the LLM's context window efficient, the tool summarizes that raw JSON down to just the name, server, and category before handing it to the agent, rather than passing through the full installation metadata.

The Discovery server itself is a separate open-source project (mcp-discovery) that requires its own deployment - cloning the repo, installing dependencies with npm, and configuring Supabase and OpenAI credentials via environment variables.

When to use - and when NOT to

Use it when you already run (or are willing to deploy and maintain) an MCP Discovery server, and want a LlamaIndex agent to dynamically find and recommend other MCP tools by natural-language description rather than hardcoding a fixed tool list. Do not use it expecting a hosted, ready-to-call discovery service - there is no public Discovery endpoint bundled with this package, and without a working self-hosted server the tool has nothing to query.

Capabilities

discover_tools (via MCPDiscoveryTool) queries a self-hosted MCP Discovery server with a natural-language description and returns a summarized list of matching MCP servers (name, server slug, category), built with aiohttp for async operation and BaseToolSpec for LlamaIndex compatibility.

How to install

pip install llama-index-tools-mcp-discovery

Requires Python >= 3.9, llama-index-core >= 0.13.0, aiohttp >= 3.8.0, and a separately deployed and reachable MCP Discovery server (configured with SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, and OPENAI_API_KEY).

Who it's for

Developers who already operate an MCP Discovery server and want a LlamaIndex agent that can dynamically discover and recommend other MCP tools at runtime instead of a fixed, hardcoded toolset.

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 aiohttp for 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.