Skip to content

feat: add local openclaude-for-chrome-mcp package - #673

Closed
Flo5k5 wants to merge 1 commit into
Twigpine:mainfrom
Flo5k5:feat/chrome-mcp-local
Closed

Flo5k5 wants to merge 1 commit into
Twigpine:mainfrom
Flo5k5:feat/chrome-mcp-local

Conversation

@Flo5k5

@Flo5k5 Flo5k5 commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add packages/openclaude-for-chrome-mcp/ — a local MCP server package that replaces the previously stubbed @ant/claude-for-chrome-mcp, enabling Chrome browser automation via the extension (ID fcoeoabgfenejglbffodgkkbkcdhcgfn)
  • Redirect build resolution from the proprietary stub to the local package via onResolve in scripts/build.ts
  • Rename all imports from @ant/claude-for-chrome-mcp to openclaude-for-chrome-mcp across 4 consumer files

Package contents (6 files)

File Purpose
types.ts Logger, PermissionMode, ClaudeForChromeContext types
protocol.ts Socket protocol types (4-byte LE + JSON, matching chromeNativeHost.ts)
tools.ts 17 browser tool definitions with full MCP schemas (typed as SDK Tool[])
socketClient.ts Unix socket client with lazy connection, backpressure-safe writes, idempotent teardown
server.ts MCP server factory using @modelcontextprotocol/sdk with ListTools/CallTool handlers
index.ts Barrel export

Modified files (8 files)

  • scripts/build.ts — onResolve for local package; removed from native-stub list; dead stubs cleaned
  • tsconfig.json — paths mapping, rootDir: ".", packages/**/* in include
  • src/utils/claudeInChrome/mcpServer.ts — import + obsolete version comment cleaned
  • src/utils/claudeInChrome/setup.ts — import renamed
  • src/utils/claudeInChrome/common.ts — comment updated
  • src/utils/claudeInChrome/toolRendering.tsx — comment updated
  • src/skills/bundled/claudeInChrome.ts — import renamed
  • src/services/mcp/client.ts — dynamic import renamed

Test plan

  • bun run build succeeds
  • bun run typecheck — no new errors from the package
  • BROWSER_TOOLS in bundle contains 17 tool definitions (not [])
  • 0 references to @ant/claude-for-chrome-mcp remain in source
  • 4 rounds of code review with fixes applied
  • End-to-end: openclaude --chrome with extension installed → tabs_context_mcp returns results

…n integration

Replace the stubbed @ant/claude-for-chrome-mcp with a functional local
implementation at packages/openclaude-for-chrome-mcp/. This enables the
Chrome browser automation integration (extension ID fcoeoabgfenejglbffodgkkbkcdhcgfn)
which was previously dead code in the open build.

The package provides:
- 17 browser tool definitions with full MCP schemas
- Unix socket client matching chromeNativeHost.ts protocol (4-byte LE + JSON)
- MCP server factory using @modelcontextprotocol/sdk
- Lazy connection, backpressure-safe writes, idempotent teardown
Copilot AI review requested due to automatic review settings April 13, 2026 18:12
@Flo5k5
Flo5k5 marked this pull request as draft April 13, 2026 18:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the previously stubbed proprietary @ant/claude-for-chrome-mcp dependency with a new local package (packages/openclaude-for-chrome-mcp/) that implements an MCP server for Chrome extension–backed browser automation, and updates the build + consumers to use it.

Changes:

  • Added a local openclaude-for-chrome-mcp package containing types, protocol definitions, tool schemas, a socket client, and an MCP server factory.
  • Updated build resolution (scripts/build.ts) and TypeScript path mapping (tsconfig.json) to resolve the local package.
  • Renamed imports across Chrome-integration consumers from @ant/claude-for-chrome-mcp to openclaude-for-chrome-mcp.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tsconfig.json Adds path mapping + includes packages/**/* for typechecking the new local package.
scripts/build.ts Adds a bundler onResolve rule to point openclaude-for-chrome-mcp imports at the local package.
src/utils/claudeInChrome/mcpServer.ts Switches to the local package and updates context typing comment.
src/utils/claudeInChrome/setup.ts Updates tool import to the local package.
src/utils/claudeInChrome/common.ts Updates comment referencing the source of ClaudeForChromeContext.
src/utils/claudeInChrome/toolRendering.tsx Updates comment referencing the tool source package name.
src/skills/bundled/claudeInChrome.ts Uses the local package’s BROWSER_TOOLS for bundled skill tool allowlisting.
src/services/mcp/client.ts Updates dynamic import to the local package for in-process Chrome MCP server.
packages/openclaude-for-chrome-mcp/types.ts Defines the context + logger interfaces used by existing consumers.
packages/openclaude-for-chrome-mcp/protocol.ts Defines socket framing and message types compatible with the native host.
packages/openclaude-for-chrome-mcp/tools.ts Provides the 17 MCP tool schemas used for browser automation.
packages/openclaude-for-chrome-mcp/socketClient.ts Implements the Unix socket client with framing, queueing, and notifications.
packages/openclaude-for-chrome-mcp/server.ts Implements the MCP server factory with ListTools/CallTool forwarding to the socket client.
packages/openclaude-for-chrome-mcp/index.ts Barrel exports for consumers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +59 to +60
context.logger.warn(
`[OpenClaude Chrome] Failed to connect: ${e}`,
Comment on lines +135 to +139
/**
* Send a tool request and wait for the response.
* Tool calls are sequential (one at a time from the LLM), so a simple
* FIFO queue handles request/response correlation.
*/
Comment on lines +453 to +474
{
name: 'shortcuts_execute',
description:
'Execute a named keyboard shortcut on the page.',
inputSchema: {
type: 'object',
properties: {
tabId: {
type: 'number',
description: 'The ID of the tab to execute the shortcut in.',
},
shortcutId: {
type: 'string',
description: 'The ID of the shortcut to execute (from shortcuts_list).',
},
command: {
type: 'string',
description: 'Alternative: a command string to execute.',
},
},
required: ['tabId', 'shortcutId'],
},
Comment on lines +32 to +34
): Server {
const server = new Server(
{ name: context.serverName, version: '1.0.0' },
Flo5k5 added a commit to Flo5k5/openclaude that referenced this pull request Apr 13, 2026
Replace the proprietary @ant/claude-for-chrome-mcp stub with a local
MCP server package enabling Chrome browser automation via the extension.

Package (packages/openclaude-for-chrome-mcp/):
- 17 browser tool definitions with full MCP schemas
- Unix socket client with lazy connection and backpressure-safe writes
- MCP server factory using @modelcontextprotocol/sdk
- Socket protocol types (4-byte LE + JSON)

Build integration:
- onResolve redirects openclaude-for-chrome-mcp to local package
- Import renames across 4 consumer files
@FluxLuFFy

Copy link
Copy Markdown
Contributor

@kevincodex1 what do you think

@Vasanthdev2004 Vasanthdev2004 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: PR #673 — Add local openclaude-for-chrome-mcp package (head f545da7)

CI green ✅. 14 files, +1053/-19.

What this does

Replaces the stubbed @ant/claude-for-chrome-mcp with a full local implementation in packages/openclaude-for-chrome-mcp/. This enables Chrome browser automation via the existing Chrome extension (ID fcoeoabgfenejglbffodgkkbkcdhcgfn) through the MCP tool system.

Package structure (6 files)

File Assessment
types.ts Clean types for Logger, PermissionMode, ClaudeForChromeContext ✅
protocol.ts 4-byte LE + JSON protocol matching chromeNativeHost.ts ✅
tools.ts 17 browser tools with full MCP schemas, proper required fields ✅
socketClient.ts Unix socket client with lazy connect, backpressure-safe writes, idempotent teardown, message size limits (1MB), timeouts (5s connect, 120s tool call) ✅
server.ts MCP server factory with ListTools/CallTool handlers, screenshot support, error handling ✅
index.ts Barrel export ✅

Integration (8 modified files)

  • scripts/build.ts — onResolve redirects openclaude-for-chrome-mcp to local package, removed from native-stub list ✅
  • tsconfig.json — Added paths mapping ✅
  • All 5 consumer files — Clean import rename from @ant/claude-for-chrome-mcp to openclaude-for-chrome-mcp ✅
  • src/services/mcp/client.ts — Updated import ✅
  • No remaining @ant/claude-for-chrome-mcp references ✅

Security

  • Socket path from ClaudeForChromeContext, not user input ✅
  • MAX_MESSAGE_SIZE = 1MB on both send and receive ✅
  • Pending requests cleaned up on disconnect ✅
  • No shell injection vectors ✅

🟡 Non-blocking

1. server.ts hardcodes version: '1.0.0'

Consider using the package version from package.json or a shared constant to avoid staleness.

2. No unit tests for socketClient.ts

The socket client has non-trivial logic (message framing, pending queue, concurrent connect dedup, disconnect handling). Unit tests with a mock socket would improve confidence. Not a blocker since CI passes and the protocol is well-documented for manual testing.

3. tools.ts tool names must stay in sync with toolRendering.tsx

The comment notes this dependency. Consider generating tool names from a single source of truth (e.g., a shared constant file) to prevent drift.


Verdict: Approve-ready ✅

Clean, well-structured replacement of a stubbed package with a full local implementation. Good security practices, proper protocol documentation, and thorough integration across all consumer files. Non-blocking items are follow-up polish.

@kevincodex1

Copy link
Copy Markdown
Member

looks great to me but stil in draft?

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues here, LGTM.

@blouflab

blouflab commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

This needs to be pushed the sooner the better

error: Cannot find module '@ant/claude-for-chrome-mcp' from 'src\utils\claudeInChrome\setup.ts'

bun add @ant/claude-for-chrome-mcp
bun add v1.3.14 (0d9b296a)
error: GET https://registry.npmjs.org/@ant%2fclaude-for-chrome-mcp - 404

@jatmn

jatmn commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

closing as abandoned

@jatmn jatmn closed this Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants