zenlink-mcp 1.0.0__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.
- zenlink_mcp-1.0.0/.gitignore +8 -0
- zenlink_mcp-1.0.0/.mcp/server.json +24 -0
- zenlink_mcp-1.0.0/LICENSE +21 -0
- zenlink_mcp-1.0.0/PKG-INFO +155 -0
- zenlink_mcp-1.0.0/README.md +128 -0
- zenlink_mcp-1.0.0/pyproject.toml +40 -0
- zenlink_mcp-1.0.0/src/zenlink_mcp/__init__.py +2 -0
- zenlink_mcp-1.0.0/src/zenlink_mcp/server.py +239 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
|
|
3
|
+
"name": "io.github.jayquan-mccleary/zenlink-mcp",
|
|
4
|
+
"title": "ZenLink MCP",
|
|
5
|
+
"description": "Browser automation for MCP clients � navigate, click, fill forms, take screenshots, execute JS, and more through Zen Browser or Firefox.",
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"websiteUrl": "https://github.com/JayQuan-McCleary/ZenLink-MCP",
|
|
8
|
+
"packages": [
|
|
9
|
+
{
|
|
10
|
+
"registry_type": "pip",
|
|
11
|
+
"identifier": "zenlink-mcp",
|
|
12
|
+
"version": "1.0.0",
|
|
13
|
+
"transport": {
|
|
14
|
+
"type": "stdio"
|
|
15
|
+
},
|
|
16
|
+
"packageArguments": [],
|
|
17
|
+
"environmentVariables": []
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"url": "https://github.com/JayQuan-McCleary/ZenLink-MCP",
|
|
22
|
+
"source": "github"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jay-Quan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zenlink-mcp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: MCP server for browser automation via ZenLink - gives Claude Desktop and other MCP clients native browser control.
|
|
5
|
+
Project-URL: Homepage, https://github.com/JayQuan-McCleary/ZenLink-MCP
|
|
6
|
+
Project-URL: Repository, https://github.com/JayQuan-McCleary/ZenLink-MCP
|
|
7
|
+
Project-URL: Issues, https://github.com/JayQuan-McCleary/ZenLink-MCP/issues
|
|
8
|
+
Project-URL: ZenLink Bridge, https://github.com/JayQuan-McCleary/ZenLink
|
|
9
|
+
Author-email: Jay-Quan <jayquanmccleary@gmail.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: automation,browser,claude,firefox,mcp,zen-browser,zenlink
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
|
|
22
|
+
Classifier: Topic :: Software Development :: Testing
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: httpx>=0.27.0
|
|
25
|
+
Requires-Dist: mcp[cli]>=1.2.0
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# ZenLink-MCP
|
|
29
|
+
|
|
30
|
+
MCP server that gives Claude Desktop (and any MCP client) native browser control through [ZenLink](https://github.com/JayQuan-McCleary/ZenLink).
|
|
31
|
+
|
|
32
|
+
Instead of shell commands and HTTP calls, every ZenLink action becomes a **native tool** - faster, cleaner, no overhead.
|
|
33
|
+
|
|
34
|
+
## Prerequisites
|
|
35
|
+
|
|
36
|
+
- [ZenLink](https://github.com/JayQuan-McCleary/ZenLink) installed and bridge running (`python native/bridge.py`)
|
|
37
|
+
- Zen Browser or Firefox with the ZenLink extension loaded
|
|
38
|
+
- Python 3.10+
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install zenlink-mcp
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Setup for Claude Desktop
|
|
47
|
+
|
|
48
|
+
Add to your config file:
|
|
49
|
+
|
|
50
|
+
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
51
|
+
**Mac:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"mcpServers": {
|
|
56
|
+
"zenlink": {
|
|
57
|
+
"command": "zenlink-mcp"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Restart Claude Desktop. ZenLink tools will appear in the tools menu.
|
|
64
|
+
|
|
65
|
+
### Alternative (run from source)
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"mcpServers": {
|
|
70
|
+
"zenlink": {
|
|
71
|
+
"command": "python",
|
|
72
|
+
"args": ["/path/to/ZenLink-MCP/src/zenlink_mcp/server.py"]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## How It Works
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
Claude Desktop / Any MCP Client
|
|
82
|
+
-
|
|
83
|
+
- MCP (stdio) - native tool calls
|
|
84
|
+
?
|
|
85
|
+
ZenLink-MCP (this server)
|
|
86
|
+
-
|
|
87
|
+
- HTTP to localhost:8765
|
|
88
|
+
?
|
|
89
|
+
ZenLink Bridge ? Browser Extension ? Web Page
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
No shell spawning. No curl. Just direct tool calls returning clean JSON.
|
|
93
|
+
|
|
94
|
+
## Available Tools (22)
|
|
95
|
+
|
|
96
|
+
### Reading
|
|
97
|
+
| Tool | Description |
|
|
98
|
+
|------|-------------|
|
|
99
|
+
| `zen_status` | Check bridge + extension connection |
|
|
100
|
+
| `zen_tabs` | List all open tabs with IDs |
|
|
101
|
+
| `zen_page_info` | URL, title, dimensions, scroll position |
|
|
102
|
+
| `zen_page_text` | Extract readable text from page |
|
|
103
|
+
| `zen_forms` | All form fields with labels and values |
|
|
104
|
+
| `zen_dom` | Accessibility tree |
|
|
105
|
+
| `zen_screenshot` | Capture viewport as PNG |
|
|
106
|
+
|
|
107
|
+
### Navigation
|
|
108
|
+
| Tool | Description |
|
|
109
|
+
|------|-------------|
|
|
110
|
+
| `zen_navigate(url)` | Load URL in active tab |
|
|
111
|
+
| `zen_new_tab(url)` | Open new tab |
|
|
112
|
+
| `zen_close_tab(tab_id)` | Close tab by ID |
|
|
113
|
+
| `zen_switch_tab(tab_id)` | Focus a tab |
|
|
114
|
+
|
|
115
|
+
### Interaction
|
|
116
|
+
| Tool | Description |
|
|
117
|
+
|------|-------------|
|
|
118
|
+
| `zen_click(selector, x, y)` | Click by selector or coordinates |
|
|
119
|
+
| `zen_type(selector, text, clear)` | Type into input |
|
|
120
|
+
| `zen_fill(selector, value)` | Set form field value |
|
|
121
|
+
| `zen_scroll(direction, amount)` | Scroll page |
|
|
122
|
+
| `zen_hover(selector)` | Hover over element |
|
|
123
|
+
|
|
124
|
+
### Smart Queries
|
|
125
|
+
| Tool | Description |
|
|
126
|
+
|------|-------------|
|
|
127
|
+
| `zen_find(query)` | Find elements by natural language |
|
|
128
|
+
| `zen_js(code)` | Execute JavaScript in page context |
|
|
129
|
+
| `zen_highlight(selector)` | Visual overlay on element |
|
|
130
|
+
| `zen_batch(commands)` | Multiple commands in one call |
|
|
131
|
+
|
|
132
|
+
## Example
|
|
133
|
+
|
|
134
|
+
**You:** "Open Wikipedia and search for ducks"
|
|
135
|
+
|
|
136
|
+
**Claude calls:**
|
|
137
|
+
1. `zen_navigate("https://en.wikipedia.org")`
|
|
138
|
+
2. `zen_fill("#searchInput", "Duck")`
|
|
139
|
+
3. `zen_click("#searchButton")`
|
|
140
|
+
4. `zen_page_text()` ? reads the article
|
|
141
|
+
|
|
142
|
+
No shell commands. Just native tool calls.
|
|
143
|
+
|
|
144
|
+
## Why separate from ZenLink?
|
|
145
|
+
|
|
146
|
+
**[ZenLink](https://github.com/JayQuan-McCleary/ZenLink)** is the universal HTTP bridge - works with any language, any tool, any AI.
|
|
147
|
+
|
|
148
|
+
**ZenLink-MCP** is the MCP wrapper. Keeping them separate means:
|
|
149
|
+
- ZenLink stays clean and universal
|
|
150
|
+
- MCP users get a focused, easy setup
|
|
151
|
+
- Updates to either don't break the other
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# ZenLink-MCP
|
|
2
|
+
|
|
3
|
+
MCP server that gives Claude Desktop (and any MCP client) native browser control through [ZenLink](https://github.com/JayQuan-McCleary/ZenLink).
|
|
4
|
+
|
|
5
|
+
Instead of shell commands and HTTP calls, every ZenLink action becomes a **native tool** - faster, cleaner, no overhead.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- [ZenLink](https://github.com/JayQuan-McCleary/ZenLink) installed and bridge running (`python native/bridge.py`)
|
|
10
|
+
- Zen Browser or Firefox with the ZenLink extension loaded
|
|
11
|
+
- Python 3.10+
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install zenlink-mcp
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Setup for Claude Desktop
|
|
20
|
+
|
|
21
|
+
Add to your config file:
|
|
22
|
+
|
|
23
|
+
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
24
|
+
**Mac:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"mcpServers": {
|
|
29
|
+
"zenlink": {
|
|
30
|
+
"command": "zenlink-mcp"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Restart Claude Desktop. ZenLink tools will appear in the tools menu.
|
|
37
|
+
|
|
38
|
+
### Alternative (run from source)
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"mcpServers": {
|
|
43
|
+
"zenlink": {
|
|
44
|
+
"command": "python",
|
|
45
|
+
"args": ["/path/to/ZenLink-MCP/src/zenlink_mcp/server.py"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## How It Works
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
Claude Desktop / Any MCP Client
|
|
55
|
+
-
|
|
56
|
+
- MCP (stdio) - native tool calls
|
|
57
|
+
?
|
|
58
|
+
ZenLink-MCP (this server)
|
|
59
|
+
-
|
|
60
|
+
- HTTP to localhost:8765
|
|
61
|
+
?
|
|
62
|
+
ZenLink Bridge ? Browser Extension ? Web Page
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
No shell spawning. No curl. Just direct tool calls returning clean JSON.
|
|
66
|
+
|
|
67
|
+
## Available Tools (22)
|
|
68
|
+
|
|
69
|
+
### Reading
|
|
70
|
+
| Tool | Description |
|
|
71
|
+
|------|-------------|
|
|
72
|
+
| `zen_status` | Check bridge + extension connection |
|
|
73
|
+
| `zen_tabs` | List all open tabs with IDs |
|
|
74
|
+
| `zen_page_info` | URL, title, dimensions, scroll position |
|
|
75
|
+
| `zen_page_text` | Extract readable text from page |
|
|
76
|
+
| `zen_forms` | All form fields with labels and values |
|
|
77
|
+
| `zen_dom` | Accessibility tree |
|
|
78
|
+
| `zen_screenshot` | Capture viewport as PNG |
|
|
79
|
+
|
|
80
|
+
### Navigation
|
|
81
|
+
| Tool | Description |
|
|
82
|
+
|------|-------------|
|
|
83
|
+
| `zen_navigate(url)` | Load URL in active tab |
|
|
84
|
+
| `zen_new_tab(url)` | Open new tab |
|
|
85
|
+
| `zen_close_tab(tab_id)` | Close tab by ID |
|
|
86
|
+
| `zen_switch_tab(tab_id)` | Focus a tab |
|
|
87
|
+
|
|
88
|
+
### Interaction
|
|
89
|
+
| Tool | Description |
|
|
90
|
+
|------|-------------|
|
|
91
|
+
| `zen_click(selector, x, y)` | Click by selector or coordinates |
|
|
92
|
+
| `zen_type(selector, text, clear)` | Type into input |
|
|
93
|
+
| `zen_fill(selector, value)` | Set form field value |
|
|
94
|
+
| `zen_scroll(direction, amount)` | Scroll page |
|
|
95
|
+
| `zen_hover(selector)` | Hover over element |
|
|
96
|
+
|
|
97
|
+
### Smart Queries
|
|
98
|
+
| Tool | Description |
|
|
99
|
+
|------|-------------|
|
|
100
|
+
| `zen_find(query)` | Find elements by natural language |
|
|
101
|
+
| `zen_js(code)` | Execute JavaScript in page context |
|
|
102
|
+
| `zen_highlight(selector)` | Visual overlay on element |
|
|
103
|
+
| `zen_batch(commands)` | Multiple commands in one call |
|
|
104
|
+
|
|
105
|
+
## Example
|
|
106
|
+
|
|
107
|
+
**You:** "Open Wikipedia and search for ducks"
|
|
108
|
+
|
|
109
|
+
**Claude calls:**
|
|
110
|
+
1. `zen_navigate("https://en.wikipedia.org")`
|
|
111
|
+
2. `zen_fill("#searchInput", "Duck")`
|
|
112
|
+
3. `zen_click("#searchButton")`
|
|
113
|
+
4. `zen_page_text()` ? reads the article
|
|
114
|
+
|
|
115
|
+
No shell commands. Just native tool calls.
|
|
116
|
+
|
|
117
|
+
## Why separate from ZenLink?
|
|
118
|
+
|
|
119
|
+
**[ZenLink](https://github.com/JayQuan-McCleary/ZenLink)** is the universal HTTP bridge - works with any language, any tool, any AI.
|
|
120
|
+
|
|
121
|
+
**ZenLink-MCP** is the MCP wrapper. Keeping them separate means:
|
|
122
|
+
- ZenLink stays clean and universal
|
|
123
|
+
- MCP users get a focused, easy setup
|
|
124
|
+
- Updates to either don't break the other
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
MIT
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "zenlink-mcp"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "MCP server for browser automation via ZenLink - gives Claude Desktop and other MCP clients native browser control."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Jay-Quan", email = "jayquanmccleary@gmail.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["mcp", "browser", "automation", "zenlink", "claude", "zen-browser", "firefox"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Topic :: Software Development :: Testing",
|
|
26
|
+
"Topic :: Internet :: WWW/HTTP :: Browsers",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"mcp[cli]>=1.2.0",
|
|
30
|
+
"httpx>=0.27.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/JayQuan-McCleary/ZenLink-MCP"
|
|
35
|
+
Repository = "https://github.com/JayQuan-McCleary/ZenLink-MCP"
|
|
36
|
+
Issues = "https://github.com/JayQuan-McCleary/ZenLink-MCP/issues"
|
|
37
|
+
"ZenLink Bridge" = "https://github.com/JayQuan-McCleary/ZenLink"
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
zenlink-mcp = "zenlink_mcp.server:main"
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ZenLink MCP Server
|
|
3
|
+
Exposes ZenLink browser automation as native MCP tools for Claude Desktop and other MCP clients.
|
|
4
|
+
Requires the ZenLink bridge (bridge.py) to be running on localhost:8765.
|
|
5
|
+
|
|
6
|
+
Install: pip install "mcp[cli]" httpx
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import httpx
|
|
10
|
+
from mcp.server.fastmcp import FastMCP
|
|
11
|
+
|
|
12
|
+
mcp = FastMCP("ZenLink")
|
|
13
|
+
BRIDGE = "http://localhost:8765"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _get(endpoint: str) -> dict:
|
|
17
|
+
"""GET request to bridge."""
|
|
18
|
+
try:
|
|
19
|
+
r = httpx.get(f"{BRIDGE}{endpoint}", timeout=15)
|
|
20
|
+
return r.json()
|
|
21
|
+
except httpx.ConnectError:
|
|
22
|
+
return {"error": "ZenLink bridge not running. Start it with: python native/bridge.py"}
|
|
23
|
+
except Exception as e:
|
|
24
|
+
return {"error": str(e)}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _post(endpoint: str, data: dict) -> dict:
|
|
28
|
+
"""POST request to bridge."""
|
|
29
|
+
try:
|
|
30
|
+
r = httpx.post(f"{BRIDGE}{endpoint}", json=data, timeout=15)
|
|
31
|
+
return r.json()
|
|
32
|
+
except httpx.ConnectError:
|
|
33
|
+
return {"error": "ZenLink bridge not running. Start it with: python native/bridge.py"}
|
|
34
|
+
except Exception as e:
|
|
35
|
+
return {"error": str(e)}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# -- Read Operations ----------------------------------------------
|
|
39
|
+
|
|
40
|
+
@mcp.tool()
|
|
41
|
+
def zen_status() -> dict:
|
|
42
|
+
"""Check if ZenLink bridge and browser extension are connected."""
|
|
43
|
+
return _get("/api/status")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@mcp.tool()
|
|
47
|
+
def zen_tabs() -> dict:
|
|
48
|
+
"""List all open browser tabs with their IDs, titles, and URLs."""
|
|
49
|
+
return _get("/api/tabs")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@mcp.tool()
|
|
53
|
+
def zen_page_info() -> dict:
|
|
54
|
+
"""Get current page URL, title, dimensions, and scroll position."""
|
|
55
|
+
return _get("/api/page-info")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@mcp.tool()
|
|
59
|
+
def zen_page_text() -> dict:
|
|
60
|
+
"""Extract all readable text from the current page."""
|
|
61
|
+
return _get("/api/page-text")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@mcp.tool()
|
|
65
|
+
def zen_forms() -> dict:
|
|
66
|
+
"""Get all form fields on the current page with their labels and values."""
|
|
67
|
+
return _get("/api/forms")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@mcp.tool()
|
|
71
|
+
def zen_dom() -> dict:
|
|
72
|
+
"""Get the accessibility tree of interactive elements on the page."""
|
|
73
|
+
return _get("/api/dom")
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@mcp.tool()
|
|
77
|
+
def zen_screenshot() -> dict:
|
|
78
|
+
"""Capture a screenshot of the current page. Returns the saved file path."""
|
|
79
|
+
return _get("/api/screenshot")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# -- Navigation ---------------------------------------------------
|
|
83
|
+
|
|
84
|
+
@mcp.tool()
|
|
85
|
+
def zen_navigate(url: str) -> dict:
|
|
86
|
+
"""Navigate the active tab to a URL.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
url: The URL to navigate to (e.g. "https://example.com")
|
|
90
|
+
"""
|
|
91
|
+
return _post("/api/navigate", {"url": url})
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@mcp.tool()
|
|
95
|
+
def zen_new_tab(url: str = "about:blank") -> dict:
|
|
96
|
+
"""Open a new browser tab.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
url: URL to open in the new tab (default: blank page)
|
|
100
|
+
"""
|
|
101
|
+
return _post("/api/new-tab", {"url": url})
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@mcp.tool()
|
|
105
|
+
def zen_close_tab(tab_id: int) -> dict:
|
|
106
|
+
"""Close a browser tab by its ID.
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
tab_id: The tab ID to close (get IDs from zen_tabs)
|
|
110
|
+
"""
|
|
111
|
+
return _post("/api/close-tab", {"tabId": tab_id})
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@mcp.tool()
|
|
115
|
+
def zen_switch_tab(tab_id: int) -> dict:
|
|
116
|
+
"""Switch focus to a specific browser tab.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
tab_id: The tab ID to focus (get IDs from zen_tabs)
|
|
120
|
+
"""
|
|
121
|
+
return _post("/api/switch-tab", {"tabId": tab_id})
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# -- Interaction --------------------------------------------------
|
|
125
|
+
|
|
126
|
+
@mcp.tool()
|
|
127
|
+
def zen_click(selector: str = "", x: int = 0, y: int = 0) -> dict:
|
|
128
|
+
"""Click an element on the page by CSS selector or coordinates.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
selector: CSS selector to click (e.g. "#submit", ".btn-primary")
|
|
132
|
+
x: X coordinate (used if selector is empty)
|
|
133
|
+
y: Y coordinate (used if selector is empty)
|
|
134
|
+
"""
|
|
135
|
+
if selector:
|
|
136
|
+
return _post("/api/click", {"selector": selector})
|
|
137
|
+
return _post("/api/click", {"coords": {"x": x, "y": y}})
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@mcp.tool()
|
|
141
|
+
def zen_type(selector: str, text: str, clear: bool = False) -> dict:
|
|
142
|
+
"""Type text into an input field.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
selector: CSS selector of the input element
|
|
146
|
+
text: Text to type
|
|
147
|
+
clear: Whether to clear existing text first
|
|
148
|
+
"""
|
|
149
|
+
return _post("/api/type", {"selector": selector, "text": text, "clear": clear})
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
@mcp.tool()
|
|
153
|
+
def zen_fill(selector: str, value: str) -> dict:
|
|
154
|
+
"""Set a form field's value directly (faster than typing).
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
selector: CSS selector of the input/select element
|
|
158
|
+
value: Value to set
|
|
159
|
+
"""
|
|
160
|
+
return _post("/api/fill", {"selector": selector, "value": value})
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@mcp.tool()
|
|
164
|
+
def zen_scroll(direction: str = "down", amount: int = 500) -> dict:
|
|
165
|
+
"""Scroll the page.
|
|
166
|
+
|
|
167
|
+
Args:
|
|
168
|
+
direction: Scroll direction - "up", "down", "left", or "right"
|
|
169
|
+
amount: Pixels to scroll
|
|
170
|
+
"""
|
|
171
|
+
return _post("/api/scroll", {"direction": direction, "amount": amount})
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
@mcp.tool()
|
|
175
|
+
def zen_hover(selector: str) -> dict:
|
|
176
|
+
"""Hover over an element on the page.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
selector: CSS selector of the element to hover over
|
|
180
|
+
"""
|
|
181
|
+
return _post("/api/hover", {"selector": selector})
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
# -- Smart Queries ------------------------------------------------
|
|
185
|
+
|
|
186
|
+
@mcp.tool()
|
|
187
|
+
def zen_find(query: str) -> dict:
|
|
188
|
+
"""Find elements on the page using natural language description.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
query: What to find (e.g. "login button", "search bar", "email input")
|
|
192
|
+
"""
|
|
193
|
+
return _post("/api/find", {"query": query})
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
@mcp.tool()
|
|
197
|
+
def zen_js(code: str) -> dict:
|
|
198
|
+
"""Execute JavaScript in the current page context.
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
code: JavaScript code to run (e.g. "document.title" or "document.querySelectorAll('a').length")
|
|
202
|
+
"""
|
|
203
|
+
return _post("/api/js", {"code": code})
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
@mcp.tool()
|
|
207
|
+
def zen_highlight(selector: str) -> dict:
|
|
208
|
+
"""Highlight an element on the page with a visual overlay.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
selector: CSS selector of the element to highlight
|
|
212
|
+
"""
|
|
213
|
+
return _post("/api/highlight", {"selector": selector})
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
# -- Batch --------------------------------------------------------
|
|
217
|
+
|
|
218
|
+
@mcp.tool()
|
|
219
|
+
def zen_batch(commands: list[dict]) -> dict:
|
|
220
|
+
"""Run multiple commands in a single request for speed.
|
|
221
|
+
|
|
222
|
+
Each command is a dict with "action" and parameters.
|
|
223
|
+
Available actions: navigate, newTab, closeTab, switchTab, click, type,
|
|
224
|
+
fill, scroll, hover, find, js, pageInfo, pageText, screenshot, tabs,
|
|
225
|
+
forms, dom, sleep
|
|
226
|
+
|
|
227
|
+
Args:
|
|
228
|
+
commands: List of command dicts, e.g. [{"action": "navigate", "url": "..."}, {"action": "sleep", "ms": 2000}, {"action": "click", "selector": "#btn"}]
|
|
229
|
+
"""
|
|
230
|
+
return _post("/api/batch", {"commands": commands})
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def main():
|
|
234
|
+
"""Entry point for the ZenLink MCP server."""
|
|
235
|
+
mcp.run(transport="stdio")
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
if __name__ == "__main__":
|
|
239
|
+
main()
|