datarobot-genai 0.1.63__py3-none-any.whl → 0.1.67__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.
- datarobot_genai/core/agents/base.py +7 -0
- datarobot_genai/core/custom_model.py +5 -0
- datarobot_genai/core/mcp/common.py +34 -11
- datarobot_genai/crewai/base.py +1 -0
- datarobot_genai/crewai/mcp.py +5 -1
- datarobot_genai/drmcp/core/dr_mcp_server.py +10 -3
- datarobot_genai/drmcp/core/dr_mcp_server_logo.py +12 -1
- datarobot_genai/drmcp/core/dynamic_prompts/dr_lib.py +17 -7
- datarobot_genai/drmcp/core/dynamic_prompts/register.py +36 -4
- datarobot_genai/drmcp/core/mcp_server_tools.py +2 -2
- datarobot_genai/langgraph/agent.py +2 -0
- datarobot_genai/langgraph/mcp.py +7 -1
- datarobot_genai/llama_index/base.py +1 -0
- datarobot_genai/llama_index/mcp.py +6 -1
- {datarobot_genai-0.1.63.dist-info → datarobot_genai-0.1.67.dist-info}/METADATA +2 -2
- {datarobot_genai-0.1.63.dist-info → datarobot_genai-0.1.67.dist-info}/RECORD +20 -20
- {datarobot_genai-0.1.63.dist-info → datarobot_genai-0.1.67.dist-info}/WHEEL +1 -1
- {datarobot_genai-0.1.63.dist-info → datarobot_genai-0.1.67.dist-info}/entry_points.txt +0 -0
- {datarobot_genai-0.1.63.dist-info → datarobot_genai-0.1.67.dist-info}/licenses/AUTHORS +0 -0
- {datarobot_genai-0.1.63.dist-info → datarobot_genai-0.1.67.dist-info}/licenses/LICENSE +0 -0
|
@@ -52,6 +52,7 @@ class BaseAgent(Generic[TTool], abc.ABC):
|
|
|
52
52
|
verbose: bool | str | None = True,
|
|
53
53
|
timeout: int | None = 90,
|
|
54
54
|
authorization_context: dict[str, Any] | None = None,
|
|
55
|
+
forwarded_headers: dict[str, str] | None = None,
|
|
55
56
|
**_: Any,
|
|
56
57
|
) -> None:
|
|
57
58
|
self.api_key = api_key or os.environ.get("DATAROBOT_API_TOKEN")
|
|
@@ -68,6 +69,7 @@ class BaseAgent(Generic[TTool], abc.ABC):
|
|
|
68
69
|
self.verbose = bool(verbose)
|
|
69
70
|
self._mcp_tools: list[TTool] = []
|
|
70
71
|
self._authorization_context = authorization_context or {}
|
|
72
|
+
self._forwarded_headers: dict[str, str] = forwarded_headers or {}
|
|
71
73
|
|
|
72
74
|
def set_mcp_tools(self, tools: list[TTool]) -> None:
|
|
73
75
|
self._mcp_tools = tools
|
|
@@ -86,6 +88,11 @@ class BaseAgent(Generic[TTool], abc.ABC):
|
|
|
86
88
|
"""Return the authorization context for this agent."""
|
|
87
89
|
return self._authorization_context
|
|
88
90
|
|
|
91
|
+
@property
|
|
92
|
+
def forwarded_headers(self) -> dict[str, str]:
|
|
93
|
+
"""Return the forwarded headers for this agent."""
|
|
94
|
+
return self._forwarded_headers
|
|
95
|
+
|
|
89
96
|
def litellm_api_base(self, deployment_id: str | None) -> str:
|
|
90
97
|
return get_api_base(self.api_base, deployment_id)
|
|
91
98
|
|
|
@@ -139,6 +139,11 @@ def chat_entrypoint(
|
|
|
139
139
|
completion_create_params["authorization_context"] = resolve_authorization_context(
|
|
140
140
|
completion_create_params, **kwargs
|
|
141
141
|
)
|
|
142
|
+
# Keep only allowed headers from the forwarded_headers.
|
|
143
|
+
incoming_headers = kwargs.get("headers", {}) or {}
|
|
144
|
+
allowed_headers = {"x-datarobot-api-token", "x-datarobot-api-key"}
|
|
145
|
+
forwarded_headers = {k: v for k, v in incoming_headers.items() if k.lower() in allowed_headers}
|
|
146
|
+
completion_create_params["forwarded_headers"] = forwarded_headers
|
|
142
147
|
|
|
143
148
|
# Instantiate user agent with all supplied completion params including auth context
|
|
144
149
|
agent = agent_cls(**completion_create_params)
|
|
@@ -16,6 +16,7 @@ import json
|
|
|
16
16
|
import re
|
|
17
17
|
from typing import Any
|
|
18
18
|
from typing import Literal
|
|
19
|
+
from urllib.parse import urlparse
|
|
19
20
|
|
|
20
21
|
from datarobot.core.config import DataRobotAppFrameworkBaseSettings
|
|
21
22
|
from pydantic import field_validator
|
|
@@ -37,6 +38,7 @@ class MCPConfig(DataRobotAppFrameworkBaseSettings):
|
|
|
37
38
|
datarobot_endpoint: str | None = None
|
|
38
39
|
datarobot_api_token: str | None = None
|
|
39
40
|
authorization_context: dict[str, Any] | None = None
|
|
41
|
+
forwarded_headers: dict[str, str] | None = None
|
|
40
42
|
|
|
41
43
|
_auth_context_handler: AuthContextHeaderHandler | None = None
|
|
42
44
|
_server_config: dict[str, Any] | None = None
|
|
@@ -121,18 +123,33 @@ class MCPConfig(DataRobotAppFrameworkBaseSettings):
|
|
|
121
123
|
"""
|
|
122
124
|
if self.external_mcp_url:
|
|
123
125
|
# External MCP URL - no authentication needed
|
|
126
|
+
headers: dict[str, str] = {}
|
|
127
|
+
|
|
128
|
+
# Forward headers for localhost connections
|
|
129
|
+
if self.forwarded_headers:
|
|
130
|
+
try:
|
|
131
|
+
parsed_url = urlparse(self.external_mcp_url)
|
|
132
|
+
hostname = parsed_url.hostname or ""
|
|
133
|
+
# Check if hostname is localhost or 127.0.0.1
|
|
134
|
+
if hostname in ("localhost", "127.0.0.1", "::1"):
|
|
135
|
+
headers.update(self.forwarded_headers)
|
|
136
|
+
except Exception:
|
|
137
|
+
# If URL parsing fails, fall back to simple string check
|
|
138
|
+
if "localhost" in self.external_mcp_url or "127.0.0.1" in self.external_mcp_url:
|
|
139
|
+
headers.update(self.forwarded_headers)
|
|
140
|
+
|
|
141
|
+
# Merge external headers if provided
|
|
124
142
|
if self.external_mcp_headers:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
headers = {}
|
|
143
|
+
external_headers = json.loads(self.external_mcp_headers)
|
|
144
|
+
headers.update(external_headers)
|
|
128
145
|
|
|
129
|
-
|
|
146
|
+
return {
|
|
130
147
|
"url": self.external_mcp_url.rstrip("/"),
|
|
131
148
|
"transport": self.external_mcp_transport,
|
|
132
149
|
"headers": headers,
|
|
133
150
|
}
|
|
134
|
-
|
|
135
|
-
|
|
151
|
+
|
|
152
|
+
if self.mcp_deployment_id:
|
|
136
153
|
# DataRobot deployment ID - requires authentication
|
|
137
154
|
if self.datarobot_endpoint is None:
|
|
138
155
|
raise ValueError(
|
|
@@ -142,15 +159,21 @@ class MCPConfig(DataRobotAppFrameworkBaseSettings):
|
|
|
142
159
|
raise ValueError(
|
|
143
160
|
"When using a DataRobot hosted MCP deployment, datarobot_api_token must be set."
|
|
144
161
|
)
|
|
162
|
+
|
|
145
163
|
base_url = self.datarobot_endpoint.rstrip("/")
|
|
146
164
|
if not base_url.endswith("/api/v2"):
|
|
147
|
-
base_url = base_url
|
|
165
|
+
base_url = f"{base_url}/api/v2"
|
|
166
|
+
|
|
148
167
|
url = f"{base_url}/deployments/{self.mcp_deployment_id}/directAccess/mcp"
|
|
149
168
|
|
|
150
|
-
headers
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
169
|
+
# Start with forwarded headers if available
|
|
170
|
+
headers = {}
|
|
171
|
+
if self.forwarded_headers:
|
|
172
|
+
headers.update(self.forwarded_headers)
|
|
173
|
+
|
|
174
|
+
# Add authentication headers
|
|
175
|
+
headers.update(self._authorization_bearer_header())
|
|
176
|
+
headers.update(self._authorization_context_header())
|
|
154
177
|
|
|
155
178
|
return {
|
|
156
179
|
"url": url,
|
datarobot_genai/crewai/base.py
CHANGED
|
@@ -93,6 +93,7 @@ class CrewAIAgent(BaseAgent[BaseTool], abc.ABC):
|
|
|
93
93
|
# Use MCP context manager to handle connection lifecycle
|
|
94
94
|
with mcp_tools_context(
|
|
95
95
|
authorization_context=self._authorization_context,
|
|
96
|
+
forwarded_headers=self.forwarded_headers,
|
|
96
97
|
) as mcp_tools:
|
|
97
98
|
# Set MCP tools for all agents if MCP is not configured this is effectively a no-op
|
|
98
99
|
self.set_mcp_tools(mcp_tools)
|
datarobot_genai/crewai/mcp.py
CHANGED
|
@@ -30,9 +30,13 @@ from datarobot_genai.core.mcp.common import MCPConfig
|
|
|
30
30
|
@contextmanager
|
|
31
31
|
def mcp_tools_context(
|
|
32
32
|
authorization_context: dict[str, Any] | None = None,
|
|
33
|
+
forwarded_headers: dict[str, str] | None = None,
|
|
33
34
|
) -> Generator[list[Any], None, None]:
|
|
34
35
|
"""Context manager for MCP tools that handles connection lifecycle."""
|
|
35
|
-
config = MCPConfig(
|
|
36
|
+
config = MCPConfig(
|
|
37
|
+
authorization_context=authorization_context,
|
|
38
|
+
forwarded_headers=forwarded_headers,
|
|
39
|
+
)
|
|
36
40
|
# If no MCP server configured, return empty tools list
|
|
37
41
|
if not config.server_config:
|
|
38
42
|
print("No MCP server configured, using empty tools list", flush=True)
|
|
@@ -184,13 +184,17 @@ class DataRobotMCPServer:
|
|
|
184
184
|
prompts = asyncio.run(self._mcp._list_prompts_mcp())
|
|
185
185
|
resources = asyncio.run(self._mcp._list_resources_mcp())
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
tools_count = len(tools)
|
|
188
|
+
prompts_count = len(prompts)
|
|
189
|
+
resources_count = len(resources)
|
|
190
|
+
|
|
191
|
+
self._logger.info(f"Registered tools: {tools_count}")
|
|
188
192
|
for tool in tools:
|
|
189
193
|
self._logger.info(f" > {tool.name}")
|
|
190
|
-
self._logger.info(f"Registered prompts: {
|
|
194
|
+
self._logger.info(f"Registered prompts: {prompts_count}")
|
|
191
195
|
for prompt in prompts:
|
|
192
196
|
self._logger.info(f" > {prompt.name}")
|
|
193
|
-
self._logger.info(f"Registered resources: {
|
|
197
|
+
self._logger.info(f"Registered resources: {resources_count}")
|
|
194
198
|
for resource in resources:
|
|
195
199
|
self._logger.info(f" > {resource.name}")
|
|
196
200
|
|
|
@@ -209,6 +213,9 @@ class DataRobotMCPServer:
|
|
|
209
213
|
self._mcp,
|
|
210
214
|
self._mcp_transport,
|
|
211
215
|
port=self._config.mcp_server_port,
|
|
216
|
+
tools_count=tools_count,
|
|
217
|
+
prompts_count=prompts_count,
|
|
218
|
+
resources_count=resources_count,
|
|
212
219
|
)
|
|
213
220
|
|
|
214
221
|
if self._mcp_transport == "stdio":
|
|
@@ -54,6 +54,9 @@ def log_server_custom_banner(
|
|
|
54
54
|
host: str | None = None,
|
|
55
55
|
port: int | None = None,
|
|
56
56
|
path: str | None = None,
|
|
57
|
+
tools_count: int | None = None,
|
|
58
|
+
prompts_count: int | None = None,
|
|
59
|
+
resources_count: int | None = None,
|
|
57
60
|
) -> None:
|
|
58
61
|
"""
|
|
59
62
|
Create and log a formatted banner with server information and logo.
|
|
@@ -64,13 +67,20 @@ def log_server_custom_banner(
|
|
|
64
67
|
host: Host address (for HTTP transports)
|
|
65
68
|
port: Port number (for HTTP transports)
|
|
66
69
|
path: Server path (for HTTP transports)
|
|
70
|
+
tools_count: Number of tools registered
|
|
71
|
+
prompts_count: Number of prompts registered
|
|
72
|
+
resources_count: Number of resources registered
|
|
67
73
|
"""
|
|
68
74
|
# Create the logo text
|
|
69
75
|
# Use Text with no_wrap and markup disabled to preserve ANSI escape codes
|
|
70
76
|
logo_text = Text.from_ansi(DR_LOGO_ASCII, no_wrap=True)
|
|
71
77
|
|
|
72
78
|
# Create the main title
|
|
73
|
-
title_text = Text(f"DataRobot MCP Server {datarobot_genai_version}", style="
|
|
79
|
+
title_text = Text(f"DataRobot MCP Server {datarobot_genai_version}", style="dim green")
|
|
80
|
+
stats_text = Text(
|
|
81
|
+
f"{tools_count} tools, {prompts_count} prompts, {resources_count} resources",
|
|
82
|
+
style="bold green",
|
|
83
|
+
)
|
|
74
84
|
|
|
75
85
|
# Create the information table
|
|
76
86
|
info_table = Table.grid(padding=(0, 1))
|
|
@@ -107,6 +117,7 @@ def log_server_custom_banner(
|
|
|
107
117
|
Align.center(logo_text),
|
|
108
118
|
"",
|
|
109
119
|
Align.center(title_text),
|
|
120
|
+
Align.center(stats_text),
|
|
110
121
|
"",
|
|
111
122
|
"",
|
|
112
123
|
Align.center(info_table),
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
-
|
|
14
|
+
from collections import defaultdict
|
|
15
15
|
from dataclasses import dataclass
|
|
16
16
|
|
|
17
17
|
import datarobot as dr
|
|
@@ -34,6 +34,7 @@ class DrVariable:
|
|
|
34
34
|
@dataclass
|
|
35
35
|
class DrPromptVersion:
|
|
36
36
|
id: str
|
|
37
|
+
prompt_template_id: str
|
|
37
38
|
version: int
|
|
38
39
|
prompt_text: str
|
|
39
40
|
variables: list[DrVariable]
|
|
@@ -45,6 +46,7 @@ class DrPromptVersion:
|
|
|
45
46
|
]
|
|
46
47
|
return cls(
|
|
47
48
|
id=d["id"],
|
|
49
|
+
prompt_template_id=d["promptTemplateId"],
|
|
48
50
|
version=d["version"],
|
|
49
51
|
prompt_text=d["promptText"],
|
|
50
52
|
variables=variables,
|
|
@@ -58,7 +60,9 @@ class DrPrompt:
|
|
|
58
60
|
description: str
|
|
59
61
|
|
|
60
62
|
def get_latest_version(self) -> DrPromptVersion | None:
|
|
61
|
-
|
|
63
|
+
all_prompt_template_versions = get_datarobot_prompt_template_versions([self.id])
|
|
64
|
+
prompt_template_versions = all_prompt_template_versions.get(self.id)
|
|
65
|
+
|
|
62
66
|
if not prompt_template_versions:
|
|
63
67
|
return None
|
|
64
68
|
latest_version = max(prompt_template_versions, key=lambda v: v.version)
|
|
@@ -77,15 +81,21 @@ def get_datarobot_prompt_templates() -> list[DrPrompt]:
|
|
|
77
81
|
return [DrPrompt.from_dict(prompt_template) for prompt_template in prompt_templates_data]
|
|
78
82
|
|
|
79
83
|
|
|
80
|
-
def get_datarobot_prompt_template_versions(
|
|
84
|
+
def get_datarobot_prompt_template_versions(
|
|
85
|
+
prompt_template_ids: list[str],
|
|
86
|
+
) -> dict[str, list[DrPromptVersion]]:
|
|
81
87
|
prompt_template_versions_data = dr.utils.pagination.unpaginate(
|
|
82
|
-
initial_url=
|
|
83
|
-
initial_params={
|
|
88
|
+
initial_url="genai/promptTemplates/versions/",
|
|
89
|
+
initial_params={
|
|
90
|
+
"promptTemplateIds": prompt_template_ids,
|
|
91
|
+
},
|
|
84
92
|
client=get_api_client(),
|
|
85
93
|
)
|
|
86
|
-
prompt_template_versions =
|
|
94
|
+
prompt_template_versions = defaultdict(list)
|
|
87
95
|
for prompt_template_version in prompt_template_versions_data:
|
|
88
|
-
prompt_template_versions.append(
|
|
96
|
+
prompt_template_versions[prompt_template_version["promptTemplateId"]].append(
|
|
97
|
+
DrPromptVersion.from_dict(prompt_template_version)
|
|
98
|
+
)
|
|
89
99
|
return prompt_template_versions
|
|
90
100
|
|
|
91
101
|
|
|
@@ -27,6 +27,7 @@ from datarobot_genai.drmcp.core.mcp_instance import register_prompt
|
|
|
27
27
|
from .dr_lib import DrPrompt
|
|
28
28
|
from .dr_lib import DrPromptVersion
|
|
29
29
|
from .dr_lib import DrVariable
|
|
30
|
+
from .dr_lib import get_datarobot_prompt_template_versions
|
|
30
31
|
from .dr_lib import get_datarobot_prompt_templates
|
|
31
32
|
|
|
32
33
|
logger = logging.getLogger(__name__)
|
|
@@ -36,11 +37,21 @@ async def register_prompts_from_datarobot_prompt_management() -> None:
|
|
|
36
37
|
"""Register prompts from DataRobot Prompt Management."""
|
|
37
38
|
prompts = get_datarobot_prompt_templates()
|
|
38
39
|
logger.info(f"Found {len(prompts)} prompts in Prompts Management.")
|
|
40
|
+
all_prompts_versions = get_datarobot_prompt_template_versions(
|
|
41
|
+
prompt_template_ids=list({prompt.id for prompt in prompts})
|
|
42
|
+
)
|
|
39
43
|
|
|
40
44
|
# Try to register each prompt, continue on failure
|
|
41
45
|
for prompt in prompts:
|
|
46
|
+
prompt_versions = all_prompts_versions.get(prompt.id)
|
|
47
|
+
if not prompt_versions:
|
|
48
|
+
logger.warning(f"Prompt template id {prompt.id} has no versions.")
|
|
49
|
+
continue
|
|
50
|
+
|
|
51
|
+
latest_version = max(prompt_versions, key=lambda v: v.version)
|
|
52
|
+
|
|
42
53
|
try:
|
|
43
|
-
await register_prompt_from_datarobot_prompt_management(prompt)
|
|
54
|
+
await register_prompt_from_datarobot_prompt_management(prompt, latest_version)
|
|
44
55
|
except DynamicPromptRegistrationError:
|
|
45
56
|
pass
|
|
46
57
|
|
|
@@ -114,15 +125,36 @@ async def register_prompt_from_datarobot_prompt_management(
|
|
|
114
125
|
) from exc
|
|
115
126
|
|
|
116
127
|
|
|
128
|
+
def _escape_non_ascii(s: str) -> str:
|
|
129
|
+
out = []
|
|
130
|
+
for ch in s:
|
|
131
|
+
# If its space -> change to underscore
|
|
132
|
+
if ch.isspace():
|
|
133
|
+
out.append("_")
|
|
134
|
+
# ASCII letter, digit or underscore -> keep
|
|
135
|
+
elif ch.isascii() and (ch.isalnum() or ch == "_"):
|
|
136
|
+
out.append(ch)
|
|
137
|
+
# Everything else -> encode as 'xHEX'
|
|
138
|
+
else:
|
|
139
|
+
out.append(f"x{ord(ch):x}")
|
|
140
|
+
return "".join(out)
|
|
141
|
+
|
|
142
|
+
|
|
117
143
|
def to_valid_mcp_prompt_name(s: str) -> str:
|
|
118
144
|
"""Convert an arbitrary string into a valid MCP prompt name."""
|
|
119
|
-
# Replace any sequence of invalid characters with '_'
|
|
120
|
-
s = re.sub(r"[^0-9a-zA-Z_]+", "_", s)
|
|
121
|
-
|
|
122
145
|
# If its ONLY numbers return "prompt_[number]"
|
|
123
146
|
if s.isdigit():
|
|
124
147
|
return f"prompt_{s}"
|
|
125
148
|
|
|
149
|
+
# First, ASCII-transliterate using hex escape for non-ASCII
|
|
150
|
+
if not s.isascii():
|
|
151
|
+
# whole string non-ascii? -> escape and prefix with prompt_
|
|
152
|
+
encoded = _escape_non_ascii(s)
|
|
153
|
+
return f"prompt_{encoded}"
|
|
154
|
+
|
|
155
|
+
# Replace any sequence of invalid characters with '_'
|
|
156
|
+
s = re.sub(r"[^0-9a-zA-Z_]+", "_", s)
|
|
157
|
+
|
|
126
158
|
# Remove leading characters that are not letters or underscores (can't start with a digit or _)
|
|
127
159
|
s = re.sub(r"^[^a-zA-Z]+", "", s)
|
|
128
160
|
|
|
@@ -51,7 +51,7 @@ async def list_tools_by_tags(tags: list[str] | None = None, match_all: bool = Fa
|
|
|
51
51
|
-------
|
|
52
52
|
A formatted string listing tools that match the tag criteria.
|
|
53
53
|
"""
|
|
54
|
-
tools = await mcp.
|
|
54
|
+
tools = await mcp.list_tools(tags=tags, match_all=match_all)
|
|
55
55
|
|
|
56
56
|
if not tools:
|
|
57
57
|
if tags:
|
|
@@ -95,7 +95,7 @@ async def get_tool_info_by_name(tool_name: str) -> str:
|
|
|
95
95
|
-------
|
|
96
96
|
A formatted string with detailed information about the tool.
|
|
97
97
|
"""
|
|
98
|
-
all_tools = await mcp.
|
|
98
|
+
all_tools = await mcp.list_tools()
|
|
99
99
|
|
|
100
100
|
for tool in all_tools:
|
|
101
101
|
if tool.name == tool_name:
|
|
@@ -86,6 +86,7 @@ class LangGraphAgent(BaseAgent[BaseTool], abc.ABC):
|
|
|
86
86
|
]:
|
|
87
87
|
async with mcp_tools_context(
|
|
88
88
|
authorization_context=self._authorization_context,
|
|
89
|
+
forwarded_headers=self.forwarded_headers,
|
|
89
90
|
) as mcp_tools:
|
|
90
91
|
self.set_mcp_tools(mcp_tools)
|
|
91
92
|
result = await self._invoke(completion_create_params)
|
|
@@ -104,6 +105,7 @@ class LangGraphAgent(BaseAgent[BaseTool], abc.ABC):
|
|
|
104
105
|
# For non-streaming, use async with directly
|
|
105
106
|
async with mcp_tools_context(
|
|
106
107
|
authorization_context=self._authorization_context,
|
|
108
|
+
forwarded_headers=self.forwarded_headers,
|
|
107
109
|
) as mcp_tools:
|
|
108
110
|
self.set_mcp_tools(mcp_tools)
|
|
109
111
|
result = await self._invoke(completion_create_params)
|
datarobot_genai/langgraph/mcp.py
CHANGED
|
@@ -28,6 +28,7 @@ from datarobot_genai.core.mcp.common import MCPConfig
|
|
|
28
28
|
@asynccontextmanager
|
|
29
29
|
async def mcp_tools_context(
|
|
30
30
|
authorization_context: dict[str, Any] | None = None,
|
|
31
|
+
forwarded_headers: dict[str, str] | None = None,
|
|
31
32
|
) -> AsyncGenerator[list[BaseTool], None]:
|
|
32
33
|
"""Yield a list of LangChain BaseTool instances loaded via MCP.
|
|
33
34
|
|
|
@@ -37,8 +38,13 @@ async def mcp_tools_context(
|
|
|
37
38
|
----------
|
|
38
39
|
authorization_context : dict[str, Any] | None
|
|
39
40
|
Authorization context to use for MCP connections
|
|
41
|
+
forwarded_headers : dict[str, str] | None
|
|
42
|
+
Forwarded headers, e.g. x-datarobot-api-key to use for MCP authentication
|
|
40
43
|
"""
|
|
41
|
-
mcp_config = MCPConfig(
|
|
44
|
+
mcp_config = MCPConfig(
|
|
45
|
+
authorization_context=authorization_context,
|
|
46
|
+
forwarded_headers=forwarded_headers,
|
|
47
|
+
)
|
|
42
48
|
server_config = mcp_config.server_config
|
|
43
49
|
|
|
44
50
|
if not server_config:
|
|
@@ -84,6 +84,7 @@ class LlamaIndexAgent(BaseAgent[BaseTool], abc.ABC):
|
|
|
84
84
|
# Load MCP tools (if configured) asynchronously before building workflow
|
|
85
85
|
mcp_tools = await load_mcp_tools(
|
|
86
86
|
authorization_context=self._authorization_context,
|
|
87
|
+
forwarded_headers=self.forwarded_headers,
|
|
87
88
|
)
|
|
88
89
|
self.set_mcp_tools(mcp_tools)
|
|
89
90
|
|
|
@@ -30,18 +30,23 @@ from datarobot_genai.core.mcp.common import MCPConfig
|
|
|
30
30
|
|
|
31
31
|
async def load_mcp_tools(
|
|
32
32
|
authorization_context: dict[str, Any] | None = None,
|
|
33
|
+
forwarded_headers: dict[str, str] | None = None,
|
|
33
34
|
) -> list[Any]:
|
|
34
35
|
"""
|
|
35
36
|
Asynchronously load MCP tools for LlamaIndex.
|
|
36
37
|
|
|
37
38
|
Args:
|
|
38
39
|
authorization_context: Optional authorization context for MCP connections
|
|
40
|
+
forwarded_headers: Optional forwarded headers, e.g. x-datarobot-api-key for MCP auth
|
|
39
41
|
|
|
40
42
|
Returns
|
|
41
43
|
-------
|
|
42
44
|
List of MCP tools, or empty list if no MCP configuration is present.
|
|
43
45
|
"""
|
|
44
|
-
config = MCPConfig(
|
|
46
|
+
config = MCPConfig(
|
|
47
|
+
authorization_context=authorization_context,
|
|
48
|
+
forwarded_headers=forwarded_headers,
|
|
49
|
+
)
|
|
45
50
|
server_params = config.server_config
|
|
46
51
|
|
|
47
52
|
if not server_params:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datarobot-genai
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.67
|
|
4
4
|
Summary: Generic helpers for GenAI
|
|
5
5
|
Project-URL: Homepage, https://github.com/datarobot-oss/datarobot-genai
|
|
6
6
|
Author: DataRobot, Inc.
|
|
@@ -32,7 +32,7 @@ Requires-Dist: aiohttp<4.0.0,>=3.9.0; extra == 'drmcp'
|
|
|
32
32
|
Requires-Dist: aiosignal<2.0.0,>=1.3.1; extra == 'drmcp'
|
|
33
33
|
Requires-Dist: boto3<2.0.0,>=1.34.0; extra == 'drmcp'
|
|
34
34
|
Requires-Dist: datarobot-asgi-middleware<1.0.0,>=0.2.0; extra == 'drmcp'
|
|
35
|
-
Requires-Dist: fastmcp
|
|
35
|
+
Requires-Dist: fastmcp<3.0.0,>=2.13.0.2; extra == 'drmcp'
|
|
36
36
|
Requires-Dist: httpx<1.0.0,>=0.28.1; extra == 'drmcp'
|
|
37
37
|
Requires-Dist: opentelemetry-api<2.0.0,>=1.22.0; extra == 'drmcp'
|
|
38
38
|
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.22.0; extra == 'drmcp'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
datarobot_genai/__init__.py,sha256=QwWCADIZigzGvew8tGT9rAjgQjchSMjaZtFPbi3Bt2s,527
|
|
2
2
|
datarobot_genai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
datarobot_genai/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
datarobot_genai/core/custom_model.py,sha256=
|
|
4
|
+
datarobot_genai/core/custom_model.py,sha256=8SMW3BAToI44331pF6fATQlS-FulDXop1OmmrVxuB1U,7155
|
|
5
5
|
datarobot_genai/core/telemetry_agent.py,sha256=CxvoyResG3jXQ7ucU26NXCzWjWQyua-5qSYvVxpZJQg,5343
|
|
6
6
|
datarobot_genai/core/agents/__init__.py,sha256=mTG_QVV5aoOWOgVA3KEq7KQLJllyxtG2ZQoq9wiUNYo,1542
|
|
7
|
-
datarobot_genai/core/agents/base.py,sha256=
|
|
7
|
+
datarobot_genai/core/agents/base.py,sha256=kyMk9m1qGFT_XretYIEbP0F-vstPIWh_OZlECqWXvdw,6685
|
|
8
8
|
datarobot_genai/core/chat/__init__.py,sha256=kAxp4Dc-6HIM_cdBl-3IxwzJQr13UYYQ2Zc-hMwz2F8,638
|
|
9
9
|
datarobot_genai/core/chat/auth.py,sha256=6qITKTHFtESsBc2NsA6cvJf78pPUrcA5XV3Vxlhb5us,5457
|
|
10
10
|
datarobot_genai/core/chat/client.py,sha256=fk8MebXa8_R33VK0_DrXCS0Fgw3wFvPEvsuubC27c3s,6639
|
|
@@ -13,15 +13,15 @@ datarobot_genai/core/cli/__init__.py,sha256=B93Yb6VavoZpatrh8ltCL6YglIfR5FHgytXb
|
|
|
13
13
|
datarobot_genai/core/cli/agent_environment.py,sha256=BJzQoiDvZF5gW4mFE71U0yeg-l72C--kxiE-fv6W194,1662
|
|
14
14
|
datarobot_genai/core/cli/agent_kernel.py,sha256=3XX58DQ6XPpWB_tn5m3iGb3XTfhZf5X3W9tc6ADieU4,7790
|
|
15
15
|
datarobot_genai/core/mcp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
-
datarobot_genai/core/mcp/common.py,sha256=
|
|
16
|
+
datarobot_genai/core/mcp/common.py,sha256=Y24Ij8e4BwOnxojnz2BJRIFcs_Y7EfbORLrN6txowpY,6833
|
|
17
17
|
datarobot_genai/core/utils/__init__.py,sha256=VxtRUz6iwb04eFQQy0zqTNXLAkYpPXcJxVoKV0nOdXk,59
|
|
18
18
|
datarobot_genai/core/utils/auth.py,sha256=Xo1PxVr6oMgtMHkmHdS02klDKK1cyDpjGvIMF4Tx0Lo,7874
|
|
19
19
|
datarobot_genai/core/utils/urls.py,sha256=tk0t13duDEPcmwz2OnS4vwEdatruiuX8lnxMMhSaJik,2289
|
|
20
20
|
datarobot_genai/crewai/__init__.py,sha256=MtFnHA3EtmgiK_GjwUGPgQQ6G1MCEzz1SDBwQi9lE8M,706
|
|
21
21
|
datarobot_genai/crewai/agent.py,sha256=vp8_2LExpeLls7Fpzo0R6ud5I6Ryfu3n3oVTN4Yyi6A,1417
|
|
22
|
-
datarobot_genai/crewai/base.py,sha256=
|
|
22
|
+
datarobot_genai/crewai/base.py,sha256=iDIbU5LrdEaBKd914WuZuVg5f9yMw7pZTsWZqMTO1TI,7506
|
|
23
23
|
datarobot_genai/crewai/events.py,sha256=K67bO1zwPrxmppz2wh8dFGNbVebyWGXAMD7oodFE2sQ,5462
|
|
24
|
-
datarobot_genai/crewai/mcp.py,sha256=
|
|
24
|
+
datarobot_genai/crewai/mcp.py,sha256=AJTrs-8KdiRSjRECfBT1lJOsszWMoFoN9NIa1p5_wsM,2115
|
|
25
25
|
datarobot_genai/drmcp/__init__.py,sha256=JE83bfpGU7v77VzrDdlb0l8seM5OwUsUbaQErJ2eisc,2983
|
|
26
26
|
datarobot_genai/drmcp/server.py,sha256=KE4kjS5f9bfdYftG14HBHrfvxDfCD4pwCXePfvl1OvU,724
|
|
27
27
|
datarobot_genai/drmcp/core/__init__.py,sha256=y4yapzp3KnFMzSR6HlNDS4uSuyNT7I1iPBvaCLsS0sU,577
|
|
@@ -31,12 +31,12 @@ datarobot_genai/drmcp/core/config.py,sha256=D7bSi40Yc5J71_JxmpfppG83snbIJW9iz1J7
|
|
|
31
31
|
datarobot_genai/drmcp/core/config_utils.py,sha256=U-aieWw7MyP03cGDFIp97JH99ZUfr3vD9uuTzBzxn7w,6428
|
|
32
32
|
datarobot_genai/drmcp/core/constants.py,sha256=lUwoW_PTrbaBGqRJifKqCn3EoFacoEgdO-CpoFVrUoU,739
|
|
33
33
|
datarobot_genai/drmcp/core/credentials.py,sha256=PYEUDNMVw1BoMzZKLkPVTypNkVevEPtmk3scKnE-zYg,6706
|
|
34
|
-
datarobot_genai/drmcp/core/dr_mcp_server.py,sha256=
|
|
35
|
-
datarobot_genai/drmcp/core/dr_mcp_server_logo.py,sha256=
|
|
34
|
+
datarobot_genai/drmcp/core/dr_mcp_server.py,sha256=7mu5UXHQmKNbIpNoQE0lPJaUI7AZa03avfHZRRtpjNI,12841
|
|
35
|
+
datarobot_genai/drmcp/core/dr_mcp_server_logo.py,sha256=Npkn-cPPBv261kiiaNwfeS_y4a2WXlbiMS2dP80uDj8,4708
|
|
36
36
|
datarobot_genai/drmcp/core/exceptions.py,sha256=eqsGI-lxybgvWL5w4BFhbm3XzH1eU5tetwjnhJxelpc,905
|
|
37
37
|
datarobot_genai/drmcp/core/logging.py,sha256=Y_hig4eBWiXGaVV7B_3wBcaYVRNH4ydptbEQhrP9-mY,3414
|
|
38
38
|
datarobot_genai/drmcp/core/mcp_instance.py,sha256=wMsP39xqTmNBYqd49olEQb5UHTSsxj6BOIoIElorRB0,19235
|
|
39
|
-
datarobot_genai/drmcp/core/mcp_server_tools.py,sha256=
|
|
39
|
+
datarobot_genai/drmcp/core/mcp_server_tools.py,sha256=odNZKozfx0VV38SLZHw9lY0C0JM_JnRI06W3BBXnyE4,4278
|
|
40
40
|
datarobot_genai/drmcp/core/routes.py,sha256=zW4Ukr9f_odF-_oXq_WlTaCH5P4mb7gBSFp67IiuAoo,17208
|
|
41
41
|
datarobot_genai/drmcp/core/routes_utils.py,sha256=vSseXWlplMSnRgoJgtP_rHxWSAVYcx_tpTv4lyTpQoc,944
|
|
42
42
|
datarobot_genai/drmcp/core/server_life_cycle.py,sha256=WKGJWGxalvqxupzJ2y67Kklc_9PgpZT0uyjlv_sr5wc,3419
|
|
@@ -45,8 +45,8 @@ datarobot_genai/drmcp/core/tool_filter.py,sha256=tLOcG50QBvS48cOVHM6OqoODYiiS6Ke
|
|
|
45
45
|
datarobot_genai/drmcp/core/utils.py,sha256=dSjrayWVcnC5GxQcvOIOSHaoEymPIVtG_s2ZBMlmSOw,4336
|
|
46
46
|
datarobot_genai/drmcp/core/dynamic_prompts/__init__.py,sha256=y4yapzp3KnFMzSR6HlNDS4uSuyNT7I1iPBvaCLsS0sU,577
|
|
47
47
|
datarobot_genai/drmcp/core/dynamic_prompts/controllers.py,sha256=vCMYxwYjNDadRxSlRk6p8pHK6h_2K-PkbBTTW_lqBJ0,3318
|
|
48
|
-
datarobot_genai/drmcp/core/dynamic_prompts/dr_lib.py,sha256=
|
|
49
|
-
datarobot_genai/drmcp/core/dynamic_prompts/register.py,sha256=
|
|
48
|
+
datarobot_genai/drmcp/core/dynamic_prompts/dr_lib.py,sha256=IEdD2Gqm4SfUdiXJB99RiWxkN6frGaxJ2SfATetMM3c,4243
|
|
49
|
+
datarobot_genai/drmcp/core/dynamic_prompts/register.py,sha256=5AEh1m8GX-gPZHUdiE1VATt7IKJQk-eThcxh01sWn0I,7204
|
|
50
50
|
datarobot_genai/drmcp/core/dynamic_prompts/utils.py,sha256=BZ3792AgfvYlwL0_J0MzQfGecyEA5_OKUMynEZYzCds,1136
|
|
51
51
|
datarobot_genai/drmcp/core/dynamic_tools/__init__.py,sha256=0kq9vMkF7EBsS6lkEdiLibmUrghTQqosHbZ5k-V9a5g,578
|
|
52
52
|
datarobot_genai/drmcp/core/dynamic_tools/register.py,sha256=3M5-F0mhUYTZJWmFDmqzsj3QAd7ut7b0kPv-JZyaTzg,9204
|
|
@@ -83,19 +83,19 @@ datarobot_genai/drmcp/tools/predictive/predict_realtime.py,sha256=t7f28y_ealZoA6
|
|
|
83
83
|
datarobot_genai/drmcp/tools/predictive/project.py,sha256=KaMDAvJY4s12j_4ybA7-KcCS1yMOj-KPIKNBgCSE2iM,2536
|
|
84
84
|
datarobot_genai/drmcp/tools/predictive/training.py,sha256=kxeDVLqUh9ajDk8wK7CZRRydDK8UNuTVZCB3huUihF8,23660
|
|
85
85
|
datarobot_genai/langgraph/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
86
|
-
datarobot_genai/langgraph/agent.py,sha256=
|
|
87
|
-
datarobot_genai/langgraph/mcp.py,sha256=
|
|
86
|
+
datarobot_genai/langgraph/agent.py,sha256=IcNawsi2Avsw3usTQ6Z8Ku0JdCsK3sYa2CQMhUe2Kk4,9859
|
|
87
|
+
datarobot_genai/langgraph/mcp.py,sha256=iA2_j46mZAaNaL7ntXT-LW6C-NMJkzr3VfKDDfe7mh8,2851
|
|
88
88
|
datarobot_genai/llama_index/__init__.py,sha256=JEMkLQLuP8n14kNE3bZ2j08NdajnkJMfYjDQYqj7C0c,407
|
|
89
89
|
datarobot_genai/llama_index/agent.py,sha256=V6ZsD9GcBDJS-RJo1tJtIHhyW69_78gM6_fOHFV-Piw,1829
|
|
90
|
-
datarobot_genai/llama_index/base.py,sha256=
|
|
91
|
-
datarobot_genai/llama_index/mcp.py,sha256=
|
|
90
|
+
datarobot_genai/llama_index/base.py,sha256=ovcQQtC-djD_hcLrWdn93jg23AmD6NBEj7xtw4a6K6c,14481
|
|
91
|
+
datarobot_genai/llama_index/mcp.py,sha256=leXqF1C4zhuYEKFwNEfZHY4dsUuGZk3W7KArY-zxVL8,2645
|
|
92
92
|
datarobot_genai/nat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
93
93
|
datarobot_genai/nat/agent.py,sha256=siBLDWAff2-JwZ8Q3iNpM_e4_IoSwG9IvY0hyEjNenw,10292
|
|
94
94
|
datarobot_genai/nat/datarobot_llm_clients.py,sha256=IZq_kooUL8QyDTkpEreszLQk9vCzg6-FbTjIkXR9wc0,7203
|
|
95
95
|
datarobot_genai/nat/datarobot_llm_providers.py,sha256=lOVaL_0Fl6-7GFYl3HmfqttqKpKt-2w8o92P3T7B6cU,3683
|
|
96
|
-
datarobot_genai-0.1.
|
|
97
|
-
datarobot_genai-0.1.
|
|
98
|
-
datarobot_genai-0.1.
|
|
99
|
-
datarobot_genai-0.1.
|
|
100
|
-
datarobot_genai-0.1.
|
|
101
|
-
datarobot_genai-0.1.
|
|
96
|
+
datarobot_genai-0.1.67.dist-info/METADATA,sha256=hfSJaoB-QbjSH8wEMUAYxqzmdyudEz8IYdqG53tRdb4,5918
|
|
97
|
+
datarobot_genai-0.1.67.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
98
|
+
datarobot_genai-0.1.67.dist-info/entry_points.txt,sha256=CZhmZcSyt_RBltgLN_b9xasJD6J5SaDc_z7K0wuOY9Y,150
|
|
99
|
+
datarobot_genai-0.1.67.dist-info/licenses/AUTHORS,sha256=isJGUXdjq1U7XZ_B_9AH8Qf0u4eX0XyQifJZ_Sxm4sA,80
|
|
100
|
+
datarobot_genai-0.1.67.dist-info/licenses/LICENSE,sha256=U2_VkLIktQoa60Nf6Tbt7E4RMlfhFSjWjcJJfVC-YCE,11341
|
|
101
|
+
datarobot_genai-0.1.67.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|