You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Restructure usage examples and fix architecture diagram
- Fix mermaid diagram to show correct flow: Agent uses discovery results to call execution layer
- Restructure Usage Examples section into two clear approaches:
1. Direct Developer Usage - programmatic calls to intelligent_tool_finder
2. Agent Integration - autonomous agent discovery and invocation
- Move agent integration content from separate section into usage examples
- Improve example queries to be more natural
- Clarify that discovery and execution are parallel processes controlled by the agent
Copy file name to clipboardExpand all lines: docs/dynamic-tool-discovery.md
+52-23Lines changed: 52 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,26 +44,24 @@ The dynamic tool discovery process follows these steps:
44
44
graph TB
45
45
subgraph "Agent Layer"
46
46
A[AI Agent] --> B[Natural Language Query]
47
+
A --> H[invoke_mcp_tool]
47
48
end
48
49
49
50
subgraph "Discovery Layer"
50
51
B --> C[intelligent_tool_finder]
51
52
C --> D[Sentence Transformer]
52
53
C --> E[FAISS Index]
53
-
end
54
-
55
-
subgraph "Registry Layer"
56
54
E --> F[Tool Metadata]
57
55
F --> G[Server Information]
56
+
G --> K[Tool Discovery Results]
57
+
K --> A
58
58
end
59
59
60
60
subgraph "Execution Layer"
61
-
G --> H[invoke_mcp_tool]
62
61
H --> I[Target MCP Server]
62
+
I --> J[Tool Result]
63
+
J --> A
63
64
end
64
-
65
-
I --> J[Tool Result]
66
-
J --> A
67
65
```
68
66
69
67
### Key Technologies
@@ -75,33 +73,60 @@ graph TB
75
73
76
74
## Usage Examples
77
75
78
-
### Basic Tool Discovery
76
+
Dynamic tool discovery can be used in two primary ways:
77
+
78
+
### 1. Direct Developer Usage
79
+
80
+
Agent developers can directly call the `intelligent_tool_finder` in their code to discover tools, then use the results with the `invoke_mcp_tool` function to call the discovered tool.
81
+
82
+
#### Basic Discovery
79
83
80
84
```python
81
-
# Agent discovers time-related tools
82
-
result = intelligent_tool_finder("current time in different timezone")
85
+
# Basic usage with session cookie
86
+
tools =await intelligent_tool_finder(
87
+
natural_language_query="what time is it in Tokyo",
88
+
session_cookie="your_session_cookie_here"
89
+
)
83
90
84
91
# Returns information about relevant tools:
85
-
# {
86
-
# "tool_name": "current_time_by_timezone",
87
-
# "service_path": "/currenttime",
88
-
# "service_name": "Current Time Server",
89
-
# "tool_schema": {...},
90
-
# "overall_similarity_score": 0.89
91
-
# }
92
+
# [
93
+
# {
94
+
# "tool_name": "current_time_by_timezone",
95
+
# "service_path": "/currenttime",
96
+
# "service_name": "Current Time Server",
97
+
# "tool_schema": {...},
98
+
# "overall_similarity_score": 0.89
99
+
# }
100
+
# ]
101
+
```
102
+
103
+
#### Advanced Discovery
104
+
105
+
```python
106
+
# Advanced usage with multiple results
107
+
tools =await intelligent_tool_finder(
108
+
natural_language_query="stock market information and financial data",
109
+
username="admin",
110
+
password="your_password",
111
+
top_k_services=5,
112
+
top_n_tools=3
113
+
)
92
114
```
93
115
94
-
### Complete Workflow Example
116
+
####Complete Workflow
95
117
96
118
```python
97
119
# 1. Discover tools for weather information
98
-
weather_tools = intelligent_tool_finder("weather forecast for tomorrow")
120
+
weather_tools =await intelligent_tool_finder(
121
+
natural_language_query="weather forecast for tomorrow",
The more powerful approach is when AI agents themselves use dynamic tool discovery autonomously. The agent has access to both `intelligent_tool_finder` and `invoke_mcp_tool` as available tools, allowing it to discover and execute new capabilities on-demand.
118
145
119
-
### System Prompt Configuration
146
+
####System Prompt Configuration
120
147
121
148
Agents are configured with instructions on how to use dynamic tool discovery:
122
149
@@ -138,7 +165,7 @@ Example workflow:
138
165
</tool_discovery>
139
166
```
140
167
141
-
### Agent Implementation
168
+
####Agent Implementation
142
169
143
170
The agent implementation in [`agents/agent.py`](../agents/agent.py) shows how to:
144
171
@@ -163,6 +190,8 @@ logger.info(f"All available tools: {[tool.name if hasattr(tool, 'name') else too
163
190
agent = create_react_agent(model, all_tools)
164
191
```
165
192
193
+
This integration enables agents to have **limitless capabilities** - they can handle any task for which there's an appropriate MCP tool registered in the system, even if they weren't originally programmed with knowledge of that tool.
0 commit comments