An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.
TypeScript agentic-browseragentic-browsingagy-cliaiai-agentai-browser-extensionai-toolsbrave-extensionbrowser-agentbrowser-automationbrowser-extensionbrowser-usebrowserskillchrome-extensionclaude-codecodexfirefox-addonmcp-servernanobrowserweb-automation
fix(cli): browsentic-mcp with no arguments serves MCP on Windows too, where npm's shim starts Node on the file and the name it was called by is lost
Shahriaree4377eb15e6
diff --git a/src/daemon/cli.ts b/src/daemon/cli.tsindex 2e52be3..93fd1c1 100644--- a/src/daemon/cli.ts+++ b/src/daemon/cli.ts@@ -7,7 +7,7 @@ import { SOURCE_LABEL } from '@/lib/stores';import { RESERVED_ACTIONS } from '@/lib/actions/reserved';import { assertToolNamesRoundTrip, toolNameFor } from '@/lib/actions/tool-names';import { formatWhen } from '@/lib/format-when';-import { basename, join } from 'node:path';+import { join } from 'node:path';import { fileURLToPath } from 'node:url';import { agentSkills } from './agent/agent-skills';import {@@ -106,12 +106,8 @@ const FOLDER_PICKER: Partial<Record<NodeJS.Platform, string>> = {linux: 'In the folder picker press Ctrl+L and paste that path.',};-// `browsentic mcp` is the MCP server. The legacy `browsentic-mcp` bin keeps serving on bare-// invocation, because an MCP client config is literally {"command": "browsentic-mcp"} with no-// arguments, and those must keep working. The extension strip matters on Windows, where npm-// writes browsentic-mcp.cmd.-const invokedAs = basename(process.argv[1] ?? '').replace(/\.(?:js|cjs|mjs|exe|cmd|ps1)$/i, '');-const servesBare = invokedAs === 'browsentic-mcp' || !!process.env.BROWSENTIC_AGENT_RUN;+// `browsentic mcp` is the MCP server; `browsentic-mcp` with no arguments reaches it through mcp.ts.+const servesBare = !!process.env.BROWSENTIC_AGENT_RUN;const [command] = process.argv.slice(2);const wantsJson = process.argv.includes('--json');diff --git a/src/daemon/mcp.ts b/src/daemon/mcp.tsnew file mode 100644index 0000000..a907584--- /dev/null+++ b/src/daemon/mcp.ts@@ -0,0 +1,5 @@+// What `browsentic-mcp` runs. An MCP client config names it with no arguments, {"command": "browsentic-mcp"},+// and that means serve. It is a file of its own because npm's shim on Windows starts Node on the file the bin+// points at, so the name it was called by never reaches cli.ts.+if (process.argv.length === 2) process.argv.push('mcp');+await import(new URL('./cli.js', import.meta.url).href);diff --git a/src/daemon/package.json b/src/daemon/package.jsonindex c20da95..4e46630 100644--- a/src/daemon/package.json+++ b/src/daemon/package.json@@ -31,7 +31,7 @@},"bin": {"browsentic": "dist/cli.js",- "browsentic-mcp": "dist/cli.js",+ "browsentic-mcp": "dist/mcp.js","browsentic-mcpd": "dist/daemon-main.js"},"files": [diff --git a/src/daemon/tsup.config.ts b/src/daemon/tsup.config.tsindex 0c86d91..e389491 100644--- a/src/daemon/tsup.config.ts+++ b/src/daemon/tsup.config.ts@@ -1,7 +1,7 @@import { defineConfig } from 'tsup';export default defineConfig({- entry: ['cli.ts', 'daemon-main.ts'],+ entry: ['cli.ts', 'daemon-main.ts', 'mcp.ts'],format: ['esm'],target: 'node20',platform: 'node',