Mcp discovery
MCPDiscoveryTool #
Bases: BaseToolSpec
MCP Discovery Tool.
This tool queries the MCP Discovery API for autonomous tool recommendations. It accepts a natural language description of the need and returns a human-readable list of recommended MCP servers with name, category, and description.
Attributes:
| Name | Type | Description |
|---|---|---|
api_url |
The URL of the MCP discovery API endpoint. |
Source code in .build/python/llama-index-integrations/tools/llama-index-tools-mcp-discovery/llama_index/tools/mcp_discovery/base.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
discover_tools
async
#
discover_tools(user_request: str, limit: int = 5) -> str
Discover tools based on a natural language request.
This method allows an agent to discover needed tools without human intervention. It queries the MCP discovery API with the user's request and returns formatted tool recommendations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_request
|
str
|
Natural language description of the tool needed. |
required |
limit
|
int
|
Maximum number of tool recommendations to return. Defaults to 5. |
5
|
Returns:
| Type | Description |
|---|---|
str
|
A formatted string containing the discovered tools with their names, |
str
|
descriptions, and categories. Returns an error message if the request fails. |
Example
tool = MCPDiscoveryTool(api_url="http://localhost:8000/api") result = await tool.discover_tools("I need a math calculator", limit=3) print(result) Found 2 tools: 1. Name: math-calculator, Description: A tool for calculations, Category: math
Source code in .build/python/llama-index-integrations/tools/llama-index-tools-mcp-discovery/llama_index/tools/mcp_discovery/base.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
options: members: - MCPDiscoveryTool