solace-agent-mesh 1.0.6__py3-none-any.whl → 1.0.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of solace-agent-mesh might be problematic. Click here for more details.
- solace_agent_mesh/agent/adk/artifacts/__init__.py +1 -0
- solace_agent_mesh/agent/adk/{filesystem_artifact_service.py → artifacts/filesystem_artifact_service.py} +14 -15
- solace_agent_mesh/agent/adk/artifacts/s3_artifact_service.py +440 -0
- solace_agent_mesh/agent/adk/callbacks.py +123 -159
- solace_agent_mesh/agent/adk/embed_resolving_mcp_toolset.py +316 -0
- solace_agent_mesh/agent/adk/intelligent_mcp_callbacks.py +414 -0
- solace_agent_mesh/agent/adk/mcp_content_processor.py +665 -0
- solace_agent_mesh/agent/adk/services.py +43 -1
- solace_agent_mesh/agent/adk/setup.py +85 -45
- solace_agent_mesh/agent/adk/tool_wrapper.py +19 -3
- solace_agent_mesh/agent/protocol/event_handlers.py +1 -1
- solace_agent_mesh/agent/sac/app.py +67 -0
- solace_agent_mesh/agent/sac/component.py +14 -86
- solace_agent_mesh/assets/docs/404.html +3 -3
- solace_agent_mesh/assets/docs/assets/js/04989206.b9dfe831.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/0e682baa.b3bbde9a.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/1023fc19.364235d5.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/1523c6b4.1b0ec6f9.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/166ab619.e8f3a7c7.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/21ceee5f.3bf39250.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/3d406171.7d02a73b.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/42b3f8d8.8ccb9901.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/442a8107.b3159bb2.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/4c2787c2.fc6804f2.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/5b4258a4.0d080cd9.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/75384d09.ccd480c4.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/768e31b0.8b51cd70.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/945fb41e.c63791d1.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/{9eff14a2.036c35ea.js → 9eff14a2.472b0310.js} +1 -1
- solace_agent_mesh/assets/docs/assets/js/a3a92b25.4b7fa6a2.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/aba87c2f.76376d7c.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/ae4415af.7a2f0bbf.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/b7006a3a.73a79653.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/beecea0d.ae31f6a7.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/c2c06897.587b4af5.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/{cd3d4052.ca6eed8c.js → cd3d4052.b6535013.js} +1 -1
- solace_agent_mesh/assets/docs/assets/js/f284c35a.731836ad.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/f897a61a.0aa29dbb.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/main.6dba4a66.js +2 -0
- solace_agent_mesh/assets/docs/assets/js/runtime~main.6415ad00.js +1 -0
- solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +28 -4
- solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +6 -6
- solace_agent_mesh/assets/docs/docs/documentation/concepts/cli/index.html +8 -8
- solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +5 -5
- solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +5 -5
- solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +34 -5
- solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +5 -5
- solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +6 -6
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/index.html +72 -0
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +5 -5
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +7 -7
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +35 -16
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/bedrock-agents/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/custom-agent/index.html +17 -11
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/event-mesh-gateway/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mcp-integration/index.html +5 -5
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mongodb-integration/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rag-integration/index.html +6 -6
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rest-gateway/index.html +6 -6
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +6 -6
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/sql-database/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/artifact-management/index.html +8 -8
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/audio-tools/index.html +14 -14
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/data-analysis-tools/index.html +8 -8
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/embeds/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/index.html +6 -6
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-agents/index.html +35 -23
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-gateways/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +6 -6
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +4 -4
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +4 -4
- solace_agent_mesh/assets/docs/lunr-index-1756153049706.json +1 -0
- solace_agent_mesh/assets/docs/lunr-index.json +1 -1
- solace_agent_mesh/assets/docs/search-doc-1756153049706.json +1 -0
- solace_agent_mesh/assets/docs/search-doc.json +1 -1
- solace_agent_mesh/assets/docs/sitemap.xml +1 -1
- solace_agent_mesh/cli/__init__.py +1 -1
- solace_agent_mesh/cli/commands/add_cmd/add_cmd_llm.txt +1 -1
- solace_agent_mesh/cli/commands/add_cmd/agent_cmd.py +67 -10
- solace_agent_mesh/cli/commands/add_cmd/gateway_cmd.py +2 -2
- solace_agent_mesh/cli/commands/eval_cmd.py +8 -2
- solace_agent_mesh/cli/commands/init_cmd/__init__.py +20 -2
- solace_agent_mesh/cli/commands/init_cmd/env_step.py +25 -1
- solace_agent_mesh/cli/commands/init_cmd/orchestrator_step.py +45 -1
- solace_agent_mesh/cli/utils.py +21 -12
- solace_agent_mesh/client/webui/frontend/static/assets/main-BucUdn9m.js +673 -0
- solace_agent_mesh/client/webui/frontend/static/index.html +1 -1
- solace_agent_mesh/common/a2a_protocol.py +1 -1
- solace_agent_mesh/common/utils/mime_helpers.py +60 -1
- solace_agent_mesh/config_portal/backend/server.py +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/assets/{_index-xSu2leR8.js → _index-MqsrTd6g.js} +9 -9
- solace_agent_mesh/config_portal/frontend/static/client/assets/{manifest-950eb3be.js → manifest-28271392.js} +1 -1
- solace_agent_mesh/config_portal/frontend/static/client/index.html +1 -1
- solace_agent_mesh/core_a2a/core_a2a_llm.txt +1 -1
- solace_agent_mesh/core_a2a/service.py +1 -1
- solace_agent_mesh/evaluation/run.py +149 -15
- solace_agent_mesh/evaluation/summary_builder.py +5 -3
- solace_agent_mesh/gateway/http_sse/dependencies.py +1 -1
- solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +1 -1
- solace_agent_mesh/gateway/http_sse/services/task_service.py +1 -1
- solace_agent_mesh/llm_detail.txt +2 -2
- solace_agent_mesh/templates/agent_template.yaml +1 -1
- solace_agent_mesh/templates/plugin_agent_config_template.yaml +3 -3
- solace_agent_mesh/templates/plugin_readme_template.md +1 -1
- solace_agent_mesh/templates/shared_config.yaml +8 -1
- {solace_agent_mesh-1.0.6.dist-info → solace_agent_mesh-1.0.8.dist-info}/METADATA +4 -1
- {solace_agent_mesh-1.0.6.dist-info → solace_agent_mesh-1.0.8.dist-info}/RECORD +113 -108
- solace_agent_mesh/assets/docs/assets/js/04989206.da8246cd.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/0e682baa.79f0ab22.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/1023fc19.8e6d174c.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/1523c6b4.91c7bc01.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/166ab619.7d97ccaf.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/21ceee5f.614fa8dd.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/3d406171.9b081d5f.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/42b3f8d8.36090198.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/442a8107.5ba94b65.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/4c2787c2.66ee00e9.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/5b4258a4.bda20761.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/75384d09.c3991823.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/768e31b0.a12673db.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/945fb41e.74d728aa.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/a3a92b25.26ca071f.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/aba87c2f.a6b84da6.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/ae4415af.96189a93.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/b7006a3a.38c0cf3d.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/bb2ef573.56931473.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/c2c06897.63b76e9e.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/f284c35a.5aff74ab.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/f897a61a.862b0514.js +0 -1
- solace_agent_mesh/assets/docs/assets/js/main.ea9672b6.js +0 -2
- solace_agent_mesh/assets/docs/assets/js/runtime~main.aa687c82.js +0 -1
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/index.html +0 -17
- solace_agent_mesh/assets/docs/lunr-index-1755285974624.json +0 -1
- solace_agent_mesh/assets/docs/search-doc-1755285974624.json +0 -1
- solace_agent_mesh/client/webui/frontend/static/assets/main-DzKPMTRs.js +0 -673
- /solace_agent_mesh/assets/docs/assets/js/{main.ea9672b6.js.LICENSE.txt → main.6dba4a66.js.LICENSE.txt} +0 -0
- {solace_agent_mesh-1.0.6.dist-info → solace_agent_mesh-1.0.8.dist-info}/WHEEL +0 -0
- {solace_agent_mesh-1.0.6.dist-info → solace_agent_mesh-1.0.8.dist-info}/entry_points.txt +0 -0
- {solace_agent_mesh-1.0.6.dist-info → solace_agent_mesh-1.0.8.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Custom MCPToolset that resolves embeds in tool parameters before calling MCP tools.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
from typing import Dict, List, Optional, Any
|
|
7
|
+
|
|
8
|
+
from google.adk.tools.mcp_tool import MCPToolset, MCPTool
|
|
9
|
+
from google.adk.tools.mcp_tool.mcp_session_manager import (
|
|
10
|
+
SseConnectionParams,
|
|
11
|
+
StdioConnectionParams,
|
|
12
|
+
StreamableHTTPConnectionParams,
|
|
13
|
+
)
|
|
14
|
+
from google.adk.tools.tool_context import ToolContext
|
|
15
|
+
from solace_ai_connector.common.log import log
|
|
16
|
+
|
|
17
|
+
from ..utils.context_helpers import get_original_session_id
|
|
18
|
+
from ...common.utils.embeds import (
|
|
19
|
+
resolve_embeds_in_string,
|
|
20
|
+
evaluate_embed,
|
|
21
|
+
EARLY_EMBED_TYPES,
|
|
22
|
+
LATE_EMBED_TYPES,
|
|
23
|
+
EMBED_DELIMITER_OPEN,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class EmbedResolvingMCPTool(MCPTool):
|
|
28
|
+
"""
|
|
29
|
+
Custom MCPTool that resolves embeds in parameters before calling the actual MCP tool.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(self, original_mcp_tool: MCPTool, tool_config: Optional[Dict] = None):
|
|
33
|
+
# Copy all attributes from the original tool
|
|
34
|
+
super().__init__(
|
|
35
|
+
mcp_tool=original_mcp_tool._mcp_tool,
|
|
36
|
+
mcp_session_manager=original_mcp_tool._mcp_session_manager,
|
|
37
|
+
auth_scheme=getattr(original_mcp_tool, "_auth_scheme", None),
|
|
38
|
+
auth_credential=getattr(original_mcp_tool, "_auth_credential", None),
|
|
39
|
+
)
|
|
40
|
+
self._original_mcp_tool = original_mcp_tool
|
|
41
|
+
self._tool_config = tool_config or {}
|
|
42
|
+
|
|
43
|
+
log.info(
|
|
44
|
+
"Created EmbedResolvingMCPTool for '%s' with embed resolution capabilities",
|
|
45
|
+
self.name,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
async def _resolve_embeds_recursively(
|
|
49
|
+
self,
|
|
50
|
+
data: Any,
|
|
51
|
+
context: Any,
|
|
52
|
+
log_identifier: str,
|
|
53
|
+
current_depth: int = 0,
|
|
54
|
+
max_depth: int = 10,
|
|
55
|
+
) -> Any:
|
|
56
|
+
"""
|
|
57
|
+
Recursively resolve embeds in nested data structures with performance safeguards.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
data: The data structure to process (str, list, dict, or other)
|
|
61
|
+
context: Context for embed resolution
|
|
62
|
+
log_identifier: Logging identifier
|
|
63
|
+
current_depth: Current recursion depth
|
|
64
|
+
max_depth: Maximum allowed recursion depth
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
Data structure with embeds resolved
|
|
68
|
+
"""
|
|
69
|
+
# Depth limit safeguard
|
|
70
|
+
if current_depth >= max_depth:
|
|
71
|
+
log.warning(
|
|
72
|
+
"%s Max recursion depth (%d) reached. Stopping embed resolution.",
|
|
73
|
+
log_identifier,
|
|
74
|
+
max_depth,
|
|
75
|
+
)
|
|
76
|
+
return data
|
|
77
|
+
|
|
78
|
+
# Handle None and primitive non-string types
|
|
79
|
+
if data is None or isinstance(data, (int, float, bool)):
|
|
80
|
+
return data
|
|
81
|
+
|
|
82
|
+
# Handle strings with embeds
|
|
83
|
+
if isinstance(data, str):
|
|
84
|
+
if EMBED_DELIMITER_OPEN in data:
|
|
85
|
+
try:
|
|
86
|
+
# Create the resolution context
|
|
87
|
+
if hasattr(context, "_invocation_context"):
|
|
88
|
+
# Use the invocation context if available
|
|
89
|
+
invocation_context = context._invocation_context
|
|
90
|
+
else:
|
|
91
|
+
# Error if no invocation context is found
|
|
92
|
+
log.error(
|
|
93
|
+
"%s No invocation context found in ToolContext. Cannot resolve embeds.",
|
|
94
|
+
log_identifier,
|
|
95
|
+
)
|
|
96
|
+
return data
|
|
97
|
+
session_context = invocation_context.session
|
|
98
|
+
if not session_context:
|
|
99
|
+
log.error(
|
|
100
|
+
"%s No session context found in invocation context. Cannot resolve embeds.",
|
|
101
|
+
log_identifier,
|
|
102
|
+
)
|
|
103
|
+
return data
|
|
104
|
+
|
|
105
|
+
resolution_context = {
|
|
106
|
+
"artifact_service": invocation_context.artifact_service,
|
|
107
|
+
"session_context": {
|
|
108
|
+
"session_id": get_original_session_id(invocation_context),
|
|
109
|
+
"user_id": session_context.user_id,
|
|
110
|
+
"app_name": session_context.app_name,
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
resolved_value, _, _ = await resolve_embeds_in_string(
|
|
114
|
+
text=data,
|
|
115
|
+
context=resolution_context,
|
|
116
|
+
resolver_func=evaluate_embed,
|
|
117
|
+
types_to_resolve=EARLY_EMBED_TYPES.union(LATE_EMBED_TYPES),
|
|
118
|
+
log_identifier=log_identifier,
|
|
119
|
+
config=self._tool_config,
|
|
120
|
+
)
|
|
121
|
+
return resolved_value
|
|
122
|
+
except Exception as e:
|
|
123
|
+
log.error(
|
|
124
|
+
"%s Failed to resolve embed in string: %s",
|
|
125
|
+
log_identifier,
|
|
126
|
+
e,
|
|
127
|
+
)
|
|
128
|
+
return data
|
|
129
|
+
return data
|
|
130
|
+
|
|
131
|
+
# Handle lists
|
|
132
|
+
if isinstance(data, list):
|
|
133
|
+
resolved_list = []
|
|
134
|
+
for i, item in enumerate(data):
|
|
135
|
+
try:
|
|
136
|
+
resolved_item = await self._resolve_embeds_recursively(
|
|
137
|
+
item, context, log_identifier, current_depth + 1, max_depth
|
|
138
|
+
)
|
|
139
|
+
resolved_list.append(resolved_item)
|
|
140
|
+
except Exception as e:
|
|
141
|
+
log.error(
|
|
142
|
+
"%s Failed to resolve embeds in list item %d: %s",
|
|
143
|
+
log_identifier,
|
|
144
|
+
i,
|
|
145
|
+
e,
|
|
146
|
+
)
|
|
147
|
+
resolved_list.append(item) # Keep original on error
|
|
148
|
+
return resolved_list
|
|
149
|
+
|
|
150
|
+
# Handle dictionaries
|
|
151
|
+
if isinstance(data, dict):
|
|
152
|
+
resolved_dict = {}
|
|
153
|
+
for key, value in data.items():
|
|
154
|
+
try:
|
|
155
|
+
resolved_value = await self._resolve_embeds_recursively(
|
|
156
|
+
value, context, log_identifier, current_depth + 1, max_depth
|
|
157
|
+
)
|
|
158
|
+
resolved_dict[key] = resolved_value
|
|
159
|
+
except Exception as e:
|
|
160
|
+
log.error(
|
|
161
|
+
"%s Failed to resolve embeds in dict key '%s': %s",
|
|
162
|
+
log_identifier,
|
|
163
|
+
key,
|
|
164
|
+
e,
|
|
165
|
+
)
|
|
166
|
+
resolved_dict[key] = value # Keep original on error
|
|
167
|
+
return resolved_dict
|
|
168
|
+
|
|
169
|
+
# Handle tuples (convert to list, process, convert back)
|
|
170
|
+
if isinstance(data, tuple):
|
|
171
|
+
try:
|
|
172
|
+
resolved_list = await self._resolve_embeds_recursively(
|
|
173
|
+
list(data), context, log_identifier, current_depth + 1, max_depth
|
|
174
|
+
)
|
|
175
|
+
return tuple(resolved_list)
|
|
176
|
+
except Exception as e:
|
|
177
|
+
log.error(
|
|
178
|
+
"%s Failed to resolve embeds in tuple: %s",
|
|
179
|
+
log_identifier,
|
|
180
|
+
e,
|
|
181
|
+
)
|
|
182
|
+
return data
|
|
183
|
+
|
|
184
|
+
# Handle sets (convert to list, process, convert back)
|
|
185
|
+
if isinstance(data, set):
|
|
186
|
+
try:
|
|
187
|
+
resolved_list = await self._resolve_embeds_recursively(
|
|
188
|
+
list(data), context, log_identifier, current_depth + 1, max_depth
|
|
189
|
+
)
|
|
190
|
+
return set(resolved_list)
|
|
191
|
+
except Exception as e:
|
|
192
|
+
log.error(
|
|
193
|
+
"%s Failed to resolve embeds in set: %s",
|
|
194
|
+
log_identifier,
|
|
195
|
+
e,
|
|
196
|
+
)
|
|
197
|
+
return data
|
|
198
|
+
|
|
199
|
+
# For any other type, return as-is
|
|
200
|
+
log.debug(
|
|
201
|
+
"%s Skipping embed resolution for unsupported type: %s",
|
|
202
|
+
log_identifier,
|
|
203
|
+
type(data).__name__,
|
|
204
|
+
)
|
|
205
|
+
return data
|
|
206
|
+
|
|
207
|
+
async def _run_async_impl(
|
|
208
|
+
self, *, args, tool_context: ToolContext, credential
|
|
209
|
+
) -> Any:
|
|
210
|
+
"""
|
|
211
|
+
Override the run implementation to resolve embeds recursively before calling the original tool.
|
|
212
|
+
"""
|
|
213
|
+
log_identifier = f"[EmbedResolvingMCPTool:{self.name}]"
|
|
214
|
+
|
|
215
|
+
# Get context for embed resolution - pass the tool_context object directly
|
|
216
|
+
context_for_embeds = tool_context
|
|
217
|
+
|
|
218
|
+
if context_for_embeds:
|
|
219
|
+
log.debug(
|
|
220
|
+
"%s Starting recursive embed resolution for all parameters. Context type: %s",
|
|
221
|
+
log_identifier,
|
|
222
|
+
type(context_for_embeds).__name__,
|
|
223
|
+
)
|
|
224
|
+
# Log context attributes for debugging
|
|
225
|
+
if hasattr(context_for_embeds, "__dict__"):
|
|
226
|
+
context_attrs = list(context_for_embeds.__dict__.keys())
|
|
227
|
+
log.debug(
|
|
228
|
+
"%s Context attributes available: %s", log_identifier, context_attrs
|
|
229
|
+
)
|
|
230
|
+
try:
|
|
231
|
+
# Recursively resolve embeds in the entire args structure
|
|
232
|
+
resolved_args = await self._resolve_embeds_recursively(
|
|
233
|
+
data=args,
|
|
234
|
+
context=context_for_embeds,
|
|
235
|
+
log_identifier=log_identifier,
|
|
236
|
+
current_depth=0,
|
|
237
|
+
max_depth=10, # Configurable depth limit
|
|
238
|
+
)
|
|
239
|
+
log.debug("%s Completed recursive embed resolution", log_identifier)
|
|
240
|
+
except Exception as e:
|
|
241
|
+
log.error(
|
|
242
|
+
"%s Failed during recursive embed resolution: %s. Using original args.",
|
|
243
|
+
log_identifier,
|
|
244
|
+
e,
|
|
245
|
+
)
|
|
246
|
+
resolved_args = args # Fallback to original args
|
|
247
|
+
else:
|
|
248
|
+
log.warning(
|
|
249
|
+
"%s ToolContext not found. Skipping embed resolution for all parameters.",
|
|
250
|
+
log_identifier,
|
|
251
|
+
)
|
|
252
|
+
resolved_args = args
|
|
253
|
+
|
|
254
|
+
# Call the original MCP tool with resolved parameters
|
|
255
|
+
return await self._original_mcp_tool._run_async_impl(
|
|
256
|
+
args=resolved_args, tool_context=tool_context, credential=credential
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class EmbedResolvingMCPToolset(MCPToolset):
|
|
261
|
+
"""
|
|
262
|
+
Custom MCPToolset that creates EmbedResolvingMCPTool instances for embed resolution.
|
|
263
|
+
"""
|
|
264
|
+
|
|
265
|
+
def __init__(
|
|
266
|
+
self,
|
|
267
|
+
connection_params,
|
|
268
|
+
tool_filter=None,
|
|
269
|
+
auth_scheme=None,
|
|
270
|
+
auth_credential=None,
|
|
271
|
+
tool_config: Optional[Dict] = None,
|
|
272
|
+
):
|
|
273
|
+
super().__init__(
|
|
274
|
+
connection_params=connection_params,
|
|
275
|
+
tool_filter=tool_filter,
|
|
276
|
+
auth_scheme=auth_scheme,
|
|
277
|
+
auth_credential=auth_credential,
|
|
278
|
+
)
|
|
279
|
+
self._tool_config = tool_config or {}
|
|
280
|
+
|
|
281
|
+
async def get_tools(self, readonly_context=None) -> List[MCPTool]:
|
|
282
|
+
"""
|
|
283
|
+
Override get_tools to return EmbedResolvingMCPTool instances.
|
|
284
|
+
"""
|
|
285
|
+
# Get the original tools from the parent class
|
|
286
|
+
original_tools = await super().get_tools(readonly_context)
|
|
287
|
+
|
|
288
|
+
# Wrap each tool with embed resolution capability
|
|
289
|
+
embed_resolving_tools = []
|
|
290
|
+
log.info(
|
|
291
|
+
"EmbedResolvingMCPToolset: Wrapping %d MCP tools with embed resolution",
|
|
292
|
+
len(original_tools),
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
for tool in original_tools:
|
|
296
|
+
# Get tool-specific config
|
|
297
|
+
tool_specific_config = self._tool_config.get("tool_configs", {}).get(
|
|
298
|
+
tool.name, self._tool_config.get("config", {})
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
embed_resolving_tool = EmbedResolvingMCPTool(
|
|
302
|
+
original_mcp_tool=tool,
|
|
303
|
+
tool_config=tool_specific_config,
|
|
304
|
+
)
|
|
305
|
+
embed_resolving_tools.append(embed_resolving_tool)
|
|
306
|
+
|
|
307
|
+
log.info(
|
|
308
|
+
"EmbedResolvingMCPToolset: Successfully wrapped MCP tool '%s'",
|
|
309
|
+
tool.name,
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
log.info(
|
|
313
|
+
"EmbedResolvingMCPToolset: Completed wrapping %d MCP tools",
|
|
314
|
+
len(embed_resolving_tools),
|
|
315
|
+
)
|
|
316
|
+
return embed_resolving_tools
|