kl-mcp-client 2.1.8__py3-none-any.whl → 2.1.10__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.
- kl_mcp_client/__version__.py +1 -1
- kl_mcp_client/asyncio/tools.py +55 -4
- kl_mcp_client/tools.py +57 -5
- {kl_mcp_client-2.1.8.dist-info → kl_mcp_client-2.1.10.dist-info}/METADATA +1 -1
- kl_mcp_client-2.1.10.dist-info/RECORD +11 -0
- kl_mcp_client-2.1.8.dist-info/RECORD +0 -11
- {kl_mcp_client-2.1.8.dist-info → kl_mcp_client-2.1.10.dist-info}/WHEEL +0 -0
- {kl_mcp_client-2.1.8.dist-info → kl_mcp_client-2.1.10.dist-info}/top_level.txt +0 -0
kl_mcp_client/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__VERSION__ = "2.1.
|
|
1
|
+
__VERSION__ = "2.1.10"
|
kl_mcp_client/asyncio/tools.py
CHANGED
|
@@ -64,7 +64,8 @@ class MCPTools:
|
|
|
64
64
|
|
|
65
65
|
async def type(self, sessionId: str, selector: str, text: str) -> Dict[str, Any]:
|
|
66
66
|
res = await self.client.call_tool(
|
|
67
|
-
"type", {"sessionId": sessionId,
|
|
67
|
+
"type", {"sessionId": sessionId,
|
|
68
|
+
"selector": selector, "text": text}
|
|
68
69
|
)
|
|
69
70
|
return res.get("structuredContent", {})
|
|
70
71
|
|
|
@@ -319,7 +320,7 @@ class MCPTools:
|
|
|
319
320
|
"key": key,
|
|
320
321
|
},
|
|
321
322
|
)
|
|
322
|
-
|
|
323
|
+
|
|
323
324
|
# ======================================================
|
|
324
325
|
# BROWSER RUNTIME (NO SESSION)
|
|
325
326
|
# ======================================================
|
|
@@ -341,13 +342,63 @@ class MCPTools:
|
|
|
341
342
|
)
|
|
342
343
|
return res.get("structuredContent", {})
|
|
343
344
|
|
|
344
|
-
async def release_browser(self) -> Dict[str, Any]:
|
|
345
|
+
async def release_browser(self, pop_name: str) -> Dict[str, Any]:
|
|
345
346
|
"""
|
|
346
347
|
Release / stop browser runtime.
|
|
347
348
|
- KHÔNG cần payload
|
|
348
349
|
"""
|
|
349
350
|
res = await self.client.call_tool(
|
|
350
351
|
"release_browser",
|
|
351
|
-
{
|
|
352
|
+
{
|
|
353
|
+
"pod_name": pop_name
|
|
354
|
+
},
|
|
355
|
+
)
|
|
356
|
+
return res.get("structuredContent", {})
|
|
357
|
+
# ======================================================
|
|
358
|
+
# VIEWPORT (Playwright-style, ASYNC)
|
|
359
|
+
# ======================================================
|
|
360
|
+
|
|
361
|
+
async def get_viewport(self, sessionId: str) -> Dict[str, Any]:
|
|
362
|
+
"""
|
|
363
|
+
Get current browser viewport.
|
|
364
|
+
Equivalent to Playwright page.viewportSize().
|
|
365
|
+
"""
|
|
366
|
+
res = await self.client.call_tool(
|
|
367
|
+
"viewport",
|
|
368
|
+
{
|
|
369
|
+
"sessionId": sessionId,
|
|
370
|
+
},
|
|
371
|
+
)
|
|
372
|
+
return res.get("structuredContent", {})
|
|
373
|
+
|
|
374
|
+
async def set_viewport(
|
|
375
|
+
self,
|
|
376
|
+
sessionId: str,
|
|
377
|
+
*,
|
|
378
|
+
width: int,
|
|
379
|
+
height: int,
|
|
380
|
+
deviceScaleFactor: float = 1.0,
|
|
381
|
+
mobile: bool = False,
|
|
382
|
+
) -> Dict[str, Any]:
|
|
383
|
+
"""
|
|
384
|
+
Set browser viewport (Playwright-like).
|
|
385
|
+
|
|
386
|
+
Args:
|
|
387
|
+
width: viewport width
|
|
388
|
+
height: viewport height
|
|
389
|
+
deviceScaleFactor: default 1.0
|
|
390
|
+
mobile: mobile emulation flag
|
|
391
|
+
"""
|
|
392
|
+
res = await self.client.call_tool(
|
|
393
|
+
"viewport",
|
|
394
|
+
{
|
|
395
|
+
"sessionId": sessionId,
|
|
396
|
+
"viewport": {
|
|
397
|
+
"width": int(width),
|
|
398
|
+
"height": int(height),
|
|
399
|
+
"deviceScaleFactor": float(deviceScaleFactor),
|
|
400
|
+
"mobile": bool(mobile),
|
|
401
|
+
},
|
|
402
|
+
},
|
|
352
403
|
)
|
|
353
404
|
return res.get("structuredContent", {})
|
kl_mcp_client/tools.py
CHANGED
|
@@ -34,7 +34,8 @@ class MCPTools:
|
|
|
34
34
|
# ======================================================
|
|
35
35
|
def connect_mcp(self, mcpUrl: str) -> Dict[str, Any]:
|
|
36
36
|
# sid = self.client.create_session(mcpUrl)
|
|
37
|
-
self.client = MCPClient(
|
|
37
|
+
self.client = MCPClient(
|
|
38
|
+
base_url=mcpUrl, headers=None, timeout=30, retries=2)
|
|
38
39
|
return {"ok": True, "cdpUrl": "http://localhost:9222"}
|
|
39
40
|
|
|
40
41
|
@_ensure_client
|
|
@@ -88,7 +89,8 @@ class MCPTools:
|
|
|
88
89
|
@_ensure_client
|
|
89
90
|
def type(self, sessionId: str, selector: str, text: str) -> Dict[str, Any]:
|
|
90
91
|
return self.client.call_tool(
|
|
91
|
-
"type", {"sessionId": sessionId,
|
|
92
|
+
"type", {"sessionId": sessionId,
|
|
93
|
+
"selector": selector, "text": text}
|
|
92
94
|
).get("structuredContent", {})
|
|
93
95
|
|
|
94
96
|
@_ensure_client
|
|
@@ -562,6 +564,7 @@ class MCPTools:
|
|
|
562
564
|
# ======================================================
|
|
563
565
|
# BROWSER RUNTIME (NO SESSION)
|
|
564
566
|
# ======================================================
|
|
567
|
+
|
|
565
568
|
@_ensure_client
|
|
566
569
|
def create_browser(self, payload: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
567
570
|
"""
|
|
@@ -576,12 +579,61 @@ class MCPTools:
|
|
|
576
579
|
).get("structuredContent", {})
|
|
577
580
|
|
|
578
581
|
@_ensure_client
|
|
579
|
-
def release_browser(self) -> Dict[str, Any]:
|
|
582
|
+
def release_browser(self, pop_name: str) -> Dict[str, Any]:
|
|
580
583
|
"""
|
|
581
584
|
Release / stop browser runtime.
|
|
582
|
-
Không cần payload.
|
|
583
585
|
"""
|
|
584
586
|
return self.client.call_tool(
|
|
585
587
|
"release_browser",
|
|
586
|
-
{
|
|
588
|
+
{
|
|
589
|
+
"pod_name": pop_name
|
|
590
|
+
},
|
|
591
|
+
).get("structuredContent", {})
|
|
592
|
+
# ======================================================
|
|
593
|
+
# VIEWPORT (Playwright-style)
|
|
594
|
+
# ======================================================
|
|
595
|
+
|
|
596
|
+
@_ensure_client
|
|
597
|
+
def get_viewport(self, sessionId: str) -> Dict[str, Any]:
|
|
598
|
+
"""
|
|
599
|
+
Get current browser viewport.
|
|
600
|
+
Equivalent to Playwright page.viewportSize().
|
|
601
|
+
"""
|
|
602
|
+
return self.client.call_tool(
|
|
603
|
+
"viewport",
|
|
604
|
+
{
|
|
605
|
+
"sessionId": sessionId,
|
|
606
|
+
},
|
|
607
|
+
).get("structuredContent", {})
|
|
608
|
+
|
|
609
|
+
@_ensure_client
|
|
610
|
+
def set_viewport(
|
|
611
|
+
self,
|
|
612
|
+
sessionId: str,
|
|
613
|
+
*,
|
|
614
|
+
width: int,
|
|
615
|
+
height: int,
|
|
616
|
+
deviceScaleFactor: float = 1.0,
|
|
617
|
+
mobile: bool = False,
|
|
618
|
+
) -> Dict[str, Any]:
|
|
619
|
+
"""
|
|
620
|
+
Set browser viewport (Playwright-like).
|
|
621
|
+
|
|
622
|
+
Args:
|
|
623
|
+
width: viewport width
|
|
624
|
+
height: viewport height
|
|
625
|
+
deviceScaleFactor: default 1.0
|
|
626
|
+
mobile: mobile emulation flag
|
|
627
|
+
"""
|
|
628
|
+
return self.client.call_tool(
|
|
629
|
+
"viewport",
|
|
630
|
+
{
|
|
631
|
+
"sessionId": sessionId,
|
|
632
|
+
"viewport": {
|
|
633
|
+
"width": int(width),
|
|
634
|
+
"height": int(height),
|
|
635
|
+
"deviceScaleFactor": float(deviceScaleFactor),
|
|
636
|
+
"mobile": bool(mobile),
|
|
637
|
+
},
|
|
638
|
+
},
|
|
587
639
|
).get("structuredContent", {})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
kl_mcp_client/__init__.py,sha256=pdJdBcEH5HaRuHSe2B7VUyRgH5ad3u1dDc4euZMDRMY,106
|
|
2
|
+
kl_mcp_client/__version__.py,sha256=Uq-M9LFtR8tnGSaOR2w76lZ0qh5z5wwReA5I7feMj0k,23
|
|
3
|
+
kl_mcp_client/client.py,sha256=ujhRp0zC5GJKnBYziIPMdKZqrhv8K2t6tBAuwYw7q_k,4513
|
|
4
|
+
kl_mcp_client/tools.py,sha256=eLxWEIh0u72ao8jpkylbP2-1TpYHdPpCDISrq2H5WvA,20212
|
|
5
|
+
kl_mcp_client/asyncio/__init__.py,sha256=pdJdBcEH5HaRuHSe2B7VUyRgH5ad3u1dDc4euZMDRMY,106
|
|
6
|
+
kl_mcp_client/asyncio/client.py,sha256=5CpPf1YGOTzYfbG1mAK9s-vhKQULjdlSJnhXm3Th-1s,4413
|
|
7
|
+
kl_mcp_client/asyncio/tools.py,sha256=t-3iQnYzOCKjuPqhMlHh7XTbsSgyhcfnJNPrZff5X-c,13510
|
|
8
|
+
kl_mcp_client-2.1.10.dist-info/METADATA,sha256=jhYWCn9UZZStwF_J3eQNhfY-LCMleFjgXhykLaExei0,4444
|
|
9
|
+
kl_mcp_client-2.1.10.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
10
|
+
kl_mcp_client-2.1.10.dist-info/top_level.txt,sha256=wd_HFFyGjiKavwACuj8Ny0svtVyNsrxCSVU48EkoQ7c,14
|
|
11
|
+
kl_mcp_client-2.1.10.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
kl_mcp_client/__init__.py,sha256=pdJdBcEH5HaRuHSe2B7VUyRgH5ad3u1dDc4euZMDRMY,106
|
|
2
|
-
kl_mcp_client/__version__.py,sha256=gijF1N5K1fcUKO93GIRamnDCwaUJ3bjN5UgukTujZ20,22
|
|
3
|
-
kl_mcp_client/client.py,sha256=ujhRp0zC5GJKnBYziIPMdKZqrhv8K2t6tBAuwYw7q_k,4513
|
|
4
|
-
kl_mcp_client/tools.py,sha256=kEkeG75SUUostCR5gRjLIjJzHg6-iWzXakjf3nvgXKk,18733
|
|
5
|
-
kl_mcp_client/asyncio/__init__.py,sha256=pdJdBcEH5HaRuHSe2B7VUyRgH5ad3u1dDc4euZMDRMY,106
|
|
6
|
-
kl_mcp_client/asyncio/client.py,sha256=5CpPf1YGOTzYfbG1mAK9s-vhKQULjdlSJnhXm3Th-1s,4413
|
|
7
|
-
kl_mcp_client/asyncio/tools.py,sha256=ayOqGYoiQ0q15xXz_7sKFq9UzUAqaOG0Uscy6uyvErM,11992
|
|
8
|
-
kl_mcp_client-2.1.8.dist-info/METADATA,sha256=rKlfrw0YCBeqCfshpQj7yHanopgJF0mxLHIJvm-Ob0A,4443
|
|
9
|
-
kl_mcp_client-2.1.8.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
10
|
-
kl_mcp_client-2.1.8.dist-info/top_level.txt,sha256=wd_HFFyGjiKavwACuj8Ny0svtVyNsrxCSVU48EkoQ7c,14
|
|
11
|
-
kl_mcp_client-2.1.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|