dtlpymcp 0.1.4__py3-none-any.whl → 0.1.7__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.
- dtlpymcp/__init__.py +1 -1
- dtlpymcp/default_sources.json +12 -0
- dtlpymcp/utils/dtlpy_context.py +18 -9
- {dtlpymcp-0.1.4.dist-info → dtlpymcp-0.1.7.dist-info}/METADATA +1 -1
- dtlpymcp-0.1.7.dist-info/RECORD +10 -0
- dtlpymcp-0.1.4.dist-info/RECORD +0 -10
- {dtlpymcp-0.1.4.dist-info → dtlpymcp-0.1.7.dist-info}/WHEEL +0 -0
- {dtlpymcp-0.1.4.dist-info → dtlpymcp-0.1.7.dist-info}/entry_points.txt +0 -0
- {dtlpymcp-0.1.4.dist-info → dtlpymcp-0.1.7.dist-info}/top_level.txt +0 -0
dtlpymcp/__init__.py
CHANGED
dtlpymcp/default_sources.json
CHANGED
|
@@ -16,5 +16,17 @@
|
|
|
16
16
|
"app_url": null,
|
|
17
17
|
"server_url": null,
|
|
18
18
|
"app_jwt": null
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"dpk_name": "dataloop-mcp-data",
|
|
22
|
+
"app_url": null,
|
|
23
|
+
"server_url": null,
|
|
24
|
+
"app_jwt": null
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"dpk_name": "dataloop-mcp-dtlpy-sandbox",
|
|
28
|
+
"app_url": null,
|
|
29
|
+
"server_url": null,
|
|
30
|
+
"app_jwt": null
|
|
19
31
|
}
|
|
20
32
|
]
|
dtlpymcp/utils/dtlpy_context.py
CHANGED
|
@@ -69,10 +69,13 @@ class DataloopContext:
|
|
|
69
69
|
data = json.load(f)
|
|
70
70
|
logger.info(f"Loading MCP sources from {sources_file}")
|
|
71
71
|
for entry in data:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
try:
|
|
73
|
+
if not isinstance(entry, dict):
|
|
74
|
+
raise ValueError(f"Invalid source entry: {entry}")
|
|
75
|
+
logger.info(f"Adding MCP source: {entry.get('dpk_name')}, url: {entry.get('server_url')}")
|
|
76
|
+
await self.add_mcp_source(MCPSource(**entry))
|
|
77
|
+
except Exception as e:
|
|
78
|
+
logger.error(f"Failed to add MCP source: {entry}\n{traceback.format_exc()}")
|
|
76
79
|
|
|
77
80
|
async def add_mcp_source(self, mcp_source: MCPSource):
|
|
78
81
|
self.mcp_sources.append(mcp_source)
|
|
@@ -129,9 +132,15 @@ class DataloopContext:
|
|
|
129
132
|
try:
|
|
130
133
|
dl.setenv(self.env)
|
|
131
134
|
dl.client_api.token = self.token
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
filters = dl.Filters(resource='apps')
|
|
136
|
+
filters.add(field="dpkName", values=source.dpk_name)
|
|
137
|
+
filters.add(field="scope", values="system")
|
|
138
|
+
apps = list(dl.apps.list(filters=filters).all())
|
|
139
|
+
if len(apps) == 0:
|
|
140
|
+
raise ValueError(f"No app found for DPK name: {source.dpk_name}")
|
|
141
|
+
if len(apps) > 1:
|
|
142
|
+
logger.warning(f"Multiple apps found for DPK name: {source.dpk_name}, using first one")
|
|
143
|
+
app = apps[0]
|
|
135
144
|
logger.info(f"App: {app.name}")
|
|
136
145
|
source.app_url = next(iter(app.routes.values()))
|
|
137
146
|
session = requests.Session()
|
|
@@ -139,9 +148,9 @@ class DataloopContext:
|
|
|
139
148
|
logger.info(f"App route URL: {response.url}")
|
|
140
149
|
source.server_url = response.url
|
|
141
150
|
source.app_jwt = session.cookies.get("JWT-APP")
|
|
142
|
-
except Exception:
|
|
151
|
+
except Exception as e:
|
|
143
152
|
logger.error(f"Failed getting app info: {traceback.format_exc()}")
|
|
144
|
-
raise
|
|
153
|
+
raise Exception(f"Failed getting app info: {traceback.format_exc()}") from e
|
|
145
154
|
|
|
146
155
|
@staticmethod
|
|
147
156
|
def is_expired(app_jwt: str) -> bool:
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
dtlpymcp/__init__.py,sha256=tUwpqP2EpOpWItUNbzkuuC10aidfIn1SVheVwMf61bY,185
|
|
2
|
+
dtlpymcp/__main__.py,sha256=1lo4qoZAoUHl9rkt1YGB2kCpKg5cIrTSBSrznxyk6F4,884
|
|
3
|
+
dtlpymcp/default_sources.json,sha256=Kg6ArvMscwevXZp5zsnrnSSf8ds8M7AZDtKCYLJEly4,701
|
|
4
|
+
dtlpymcp/proxy.py,sha256=pE-NAJI0A9wKcBJJt18_aSy1BskZKoxaK3f6VW7u44A,3608
|
|
5
|
+
dtlpymcp/utils/dtlpy_context.py,sha256=WmLOoIpujudJ7pDvb07X8_jDAM_ndAi-L4Kqu4T3lFI,10231
|
|
6
|
+
dtlpymcp-0.1.7.dist-info/METADATA,sha256=bkJWJnqSKUCJy2yvUaRHz-IL7DWESe2KyUq6yJnsgN8,1677
|
|
7
|
+
dtlpymcp-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
+
dtlpymcp-0.1.7.dist-info/entry_points.txt,sha256=6hRVZNTjQevj7erwt9dAOURtPVrSrYu6uHXhAlhTaXQ,52
|
|
9
|
+
dtlpymcp-0.1.7.dist-info/top_level.txt,sha256=z85v20pIEnY3cBaWgwhU3EZS4WAZRywejhIutwd-iHk,9
|
|
10
|
+
dtlpymcp-0.1.7.dist-info/RECORD,,
|
dtlpymcp-0.1.4.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
dtlpymcp/__init__.py,sha256=jz6jKLs8djD6u5xy04_NQO7hgKyFea_oPa-yaiQQq0M,185
|
|
2
|
-
dtlpymcp/__main__.py,sha256=1lo4qoZAoUHl9rkt1YGB2kCpKg5cIrTSBSrznxyk6F4,884
|
|
3
|
-
dtlpymcp/default_sources.json,sha256=Es3XZcdMpe6o5FyOoqW9FG_oUjC5gkNbBC6N9eBqpQs,418
|
|
4
|
-
dtlpymcp/proxy.py,sha256=pE-NAJI0A9wKcBJJt18_aSy1BskZKoxaK3f6VW7u44A,3608
|
|
5
|
-
dtlpymcp/utils/dtlpy_context.py,sha256=0NW5FKFpzUl6gTuJGPPPMqklnNuecgBdwLdW-68YUXE,9752
|
|
6
|
-
dtlpymcp-0.1.4.dist-info/METADATA,sha256=_CYzt19o00e_UIw9SeiQXW7lKp5q1Bq2xSSbyF7W3Yc,1677
|
|
7
|
-
dtlpymcp-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
dtlpymcp-0.1.4.dist-info/entry_points.txt,sha256=6hRVZNTjQevj7erwt9dAOURtPVrSrYu6uHXhAlhTaXQ,52
|
|
9
|
-
dtlpymcp-0.1.4.dist-info/top_level.txt,sha256=z85v20pIEnY3cBaWgwhU3EZS4WAZRywejhIutwd-iHk,9
|
|
10
|
-
dtlpymcp-0.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|