Skip to content

Commit bc5ec6f

Browse files
authored
Merge pull request #40 from janhq/feat/strengthen_browser_mcp
feat: strengthen browser mcp
2 parents 0a07334 + 1caaf7b commit bc5ec6f

24 files changed

+15482
-471
lines changed

manifest.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"contextMenus"
2727
],
2828
"host_permissions": [
29+
"<all_urls>",
2930
"https://*/*",
3031
"http://*/*",
3132
"https://duckduckgo.com/*",
@@ -68,9 +69,9 @@
6869
}
6970
},
7071
"side_panel": {
71-
"default_path": "dist/ui/sidepanel/index.html"
72+
"default_path": "ui/sidepanel/index.html"
7273
},
73-
"options_page": "dist/ui/options/index.html",
74+
"options_page": "ui/options/index.html",
7475
"content_scripts": [
7576
{
7677
"matches": [
@@ -83,5 +84,11 @@
8384
"all_frames": true,
8485
"match_about_blank": true
8586
}
87+
],
88+
"web_accessible_resources": [
89+
{
90+
"resources": ["src/config/defaults.json"],
91+
"matches": ["<all_urls>"]
92+
}
8693
]
8794
}

mcp/search-server/README.md

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,55 @@ Add an entry under `mcpServers`:
7676

7777
Restart Claude Desktop. In a chat, ask it to use the `search` tool (e.g., "search the web for ..."), and it will call this server.
7878

79+
### Jan Desktop App
80+
81+
Jan Desktop supports MCP servers. To configure:
82+
83+
1. Build the MCP server first:
84+
```bash
85+
cd /path/to/jan-browser/mcp/search-server
86+
npm install
87+
npm run build
88+
```
89+
90+
2. Open Jan Desktop app and go to Settings → Extensions → Model Context Protocol
91+
92+
3. Add a new MCP server with these settings:
93+
- **Name**: Jan Browser Extension (or any name you prefer)
94+
- **Command**: `node`
95+
- **Arguments**: `/absolute/path/to/jan-browser/mcp/search-server/dist/src/index.js`
96+
- **Environment variables** (optional):
97+
- `BRIDGE_HOST`: `127.0.0.1`
98+
- `BRIDGE_PORT`: `17389`
99+
100+
4. **Important**: Make sure the Jan Browser Chrome extension is installed and running:
101+
- Load the extension in Chrome from the `dist/` folder
102+
- The extension must be active for the MCP server to work
103+
- Verify connection in Chrome DevTools (see "Run extension and MCP together" section)
104+
105+
5. Restart Jan Desktop or reload the MCP configuration
106+
107+
6. The server will now expose browser automation tools like `snapshot`, `browser_navigate`, `click`, `type`, `screenshot`, `web_search`, and more.
108+
109+
**Troubleshooting Jan Desktop:**
110+
- If you see "Failed to start MCP server", ensure the path to `index.js` is absolute and correct
111+
- Check that Node.js is installed and accessible in your PATH: `which node`
112+
- Verify the build completed successfully: `ls /path/to/mcp/search-server/dist/src/index.js`
113+
- Ensure the file is executable: `chmod +x /path/to/mcp/search-server/dist/src/index.js`
114+
- **NVM users**: If you use NVM for Node.js, Jan Desktop may not find node in your PATH. Use one of these solutions:
115+
- **Option 1 (Recommended)**: Use the wrapper script instead:
116+
- Command: `/absolute/path/to/jan-browser/mcp/search-server/start-mcp.sh`
117+
- Args: (leave empty)
118+
- **Option 2**: Use absolute path to node:
119+
- Command: `/Users/YOUR_USERNAME/.nvm/versions/node/vXX.XX.X/bin/node`
120+
- Args: `/absolute/path/to/jan-browser/mcp/search-server/dist/src/index.js`
121+
- **Option 3**: Install node system-wide (outside NVM) and use `node` as command
122+
- **Port conflict**: If port 17389 is in use, kill the existing process:
123+
```bash
124+
lsof -iTCP:17389 -sTCP:LISTEN | grep node | awk '{print $2}' | xargs kill -9
125+
```
126+
- Check Jan Desktop logs for more detailed error messages
127+
79128
### VS Code (via an MCP-enabled extension)
80129

81130
If your extension supports MCP servers by command, configure it to launch:
@@ -144,13 +193,32 @@ chrome.storage.sync.set({ bridgeToken: 'your-secret' })
144193

145194
Reload the extension or wait for it to reconnect.
146195

147-
## Troubleshooting: `ERR_CONNECTION_REFUSED`
196+
## Troubleshooting
197+
198+
### `ERR_CONNECTION_REFUSED`
148199

149-
- The MCP server isnt running → start it (`npm run dev:mcp`) or `npm run dev:all` from the repo root.
200+
- The MCP server isn't running → start it (`npm run dev:mcp`) or `npm run dev:all` from the repo root.
150201
- Port 17389 is busy → free it: `lsof -iTCP:17389 -sTCP:LISTEN` then `kill -9 <PID>`.
151202
- Host/port overridden incorrectly → ensure `BRIDGE_HOST=127.0.0.1` and `BRIDGE_PORT=17389`.
152203
- Token mismatch → if `BRIDGE_TOKEN` is set, ensure the extension has the same `bridgeToken` in `chrome.storage.sync`.
153204

205+
### Tools Timing Out
206+
207+
If you experience timeouts with `browser_navigate` or other tools:
208+
209+
1. **Verify extension connection**: Check Chrome extension service worker console for `[MCP Bridge] connected`
210+
2. **Enable debug logging**: Set `MCP_LOG_FILE` environment variable:
211+
```bash
212+
MCP_LOG_FILE=~/.jan-mcp-debug.log node dist/src/index.js
213+
```
214+
3. **Check logs**: Review log file for detailed message flow
215+
4. **Test manually**: Use the included test script:
216+
```bash
217+
MCP_LOG_FILE=~/.jan-mcp-test.log node test-manual.js
218+
```
219+
220+
See [TIMEOUT_FIX.md](TIMEOUT_FIX.md) for details on the Buffer handling fix that resolved timeout issues.
221+
154222
## License
155223

156224
Apache License 2.0 — see [LICENSE](../../LICENSE)

0 commit comments

Comments
 (0)