kl-mcp-client 2.1.2__tar.gz → 2.1.3__tar.gz
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.
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/PKG-INFO +1 -1
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client/tools.py +101 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client.egg-info/PKG-INFO +1 -1
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/pyproject.toml +1 -1
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/README.md +0 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client/__init__.py +0 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client/__version__.py +0 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client/asyncio/__init__.py +0 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client/asyncio/client.py +0 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client/asyncio/tools.py +0 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client/client.py +0 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client.egg-info/SOURCES.txt +0 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client.egg-info/dependency_links.txt +0 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client.egg-info/requires.txt +0 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/kl_mcp_client.egg-info/top_level.txt +0 -0
- {kl_mcp_client-2.1.2 → kl_mcp_client-2.1.3}/setup.cfg +0 -0
|
@@ -321,3 +321,104 @@ class MCPTools:
|
|
|
321
321
|
"getCleanText",
|
|
322
322
|
{"sessionId": sessionId},
|
|
323
323
|
).get("structuredContent", {})
|
|
324
|
+
|
|
325
|
+
@_ensure_client
|
|
326
|
+
def evaluate_stream(
|
|
327
|
+
self,
|
|
328
|
+
sessionId: str,
|
|
329
|
+
expression: str,
|
|
330
|
+
chunkSize: int = 100,
|
|
331
|
+
) -> Dict[str, Any]:
|
|
332
|
+
"""
|
|
333
|
+
Evaluate JS expression theo chế độ STREAM.
|
|
334
|
+
Dùng khi kết quả là array lớn (DOM, list, table, ...)
|
|
335
|
+
|
|
336
|
+
Returns (init response):
|
|
337
|
+
{
|
|
338
|
+
"stream_id": "...",
|
|
339
|
+
"total": 1234,
|
|
340
|
+
"chunk_size": 100
|
|
341
|
+
}
|
|
342
|
+
"""
|
|
343
|
+
return self.client.call_tool(
|
|
344
|
+
"evaluate.stream",
|
|
345
|
+
{
|
|
346
|
+
"sessionId": sessionId,
|
|
347
|
+
"expression": expression,
|
|
348
|
+
"chunkSize": int(chunkSize),
|
|
349
|
+
},
|
|
350
|
+
).get("structuredContent", {})
|
|
351
|
+
|
|
352
|
+
@_ensure_client
|
|
353
|
+
def stream_pull(
|
|
354
|
+
self,
|
|
355
|
+
stream_id: str,
|
|
356
|
+
offset: int = 0,
|
|
357
|
+
limit: int = 100,
|
|
358
|
+
) -> Dict[str, Any]:
|
|
359
|
+
"""
|
|
360
|
+
Kéo 1 chunk từ stream đã tạo bởi evaluate.stream
|
|
361
|
+
|
|
362
|
+
Returns:
|
|
363
|
+
{
|
|
364
|
+
"items": [...],
|
|
365
|
+
"offset": 0,
|
|
366
|
+
"has_more": true
|
|
367
|
+
}
|
|
368
|
+
"""
|
|
369
|
+
return self.client.call_tool(
|
|
370
|
+
"stream.pull",
|
|
371
|
+
{
|
|
372
|
+
"stream_id": stream_id,
|
|
373
|
+
"offset": int(offset),
|
|
374
|
+
"limit": int(limit),
|
|
375
|
+
},
|
|
376
|
+
).get("structuredContent", {})
|
|
377
|
+
|
|
378
|
+
@_ensure_client
|
|
379
|
+
def evaluate_stream_all(
|
|
380
|
+
self,
|
|
381
|
+
sessionId: str,
|
|
382
|
+
expression: str,
|
|
383
|
+
chunkSize: int = 100,
|
|
384
|
+
max_items: Optional[int] = None,
|
|
385
|
+
):
|
|
386
|
+
"""
|
|
387
|
+
Helper: evaluate.stream + tự động pull toàn bộ dữ liệu.
|
|
388
|
+
|
|
389
|
+
⚠️ Chỉ dùng khi bạn THỰC SỰ cần full data.
|
|
390
|
+
"""
|
|
391
|
+
init = self.evaluate_stream(
|
|
392
|
+
sessionId=sessionId,
|
|
393
|
+
expression=expression,
|
|
394
|
+
chunkSize=chunkSize,
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
stream_id = init.get("stream_id")
|
|
398
|
+
total = init.get("total", 0)
|
|
399
|
+
|
|
400
|
+
if not stream_id:
|
|
401
|
+
return []
|
|
402
|
+
|
|
403
|
+
items = []
|
|
404
|
+
offset = 0
|
|
405
|
+
|
|
406
|
+
while True:
|
|
407
|
+
chunk = self.stream_pull(
|
|
408
|
+
stream_id=stream_id,
|
|
409
|
+
offset=offset,
|
|
410
|
+
limit=chunkSize,
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
part = chunk.get("items", [])
|
|
414
|
+
items.extend(part)
|
|
415
|
+
|
|
416
|
+
if max_items and len(items) >= max_items:
|
|
417
|
+
return items[:max_items]
|
|
418
|
+
|
|
419
|
+
if not chunk.get("has_more"):
|
|
420
|
+
break
|
|
421
|
+
|
|
422
|
+
offset += chunkSize
|
|
423
|
+
|
|
424
|
+
return items
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|