Skip to content

Node.js library for discovering and executing WebMCP tools in Chrome via the Chrome DevTools Protocol

Notifications You must be signed in to change notification settings

tech-sumit/webmcp-cdp

Repository files navigation

@tech-sumit/webmcp-cdp

A standalone Node.js library for discovering and executing WebMCP tools in Chrome via the Chrome DevTools Protocol. Think "Playwright for WebMCP" — without Playwright.

Requirements

Chrome launched with:

chrome --remote-debugging-port=9222 --enable-features=WebMCPTesting

Installation

pnpm add @tech-sumit/webmcp-cdp

Usage

import { CdpToolSource } from "@tech-sumit/webmcp-cdp";

const source = new CdpToolSource();
await source.connect({ host: "localhost", port: 9222 });

// List all tools from all tabs
const tools = source.listTools();
console.log(tools);
// [{ name: "searchFlights", description: "...", inputSchema: "{...}" }]

// Execute a tool (args and result are JSON strings per WebMCP spec)
const result = await source.callTool("searchFlights", '{"from":"SFO","to":"JFK"}');
console.log(result);
// '{"flights":[...]}'

// Listen for tool changes
source.onToolsChanged((tools) => {
  console.log("Tools changed:", tools.length);
});

// Clean up
await source.disconnect();

API

CdpToolSource

Implements the ToolSource interface from @tech-sumit/ai-inspector-types.

Method Description
connect(config?) Connect to Chrome via CDP
disconnect() Disconnect all sessions
listTools() List all discovered tools
callTool(name, args) Execute a tool
onToolsChanged(cb) Register change listener
isConnected() Check connection status

TargetManager

Internal class for managing multiple CDP targets (tabs).

Development

pnpm install
pnpm test         # vitest
pnpm typecheck    # tsc --noEmit
pnpm build        # tsup -> dist/

About

Node.js library for discovering and executing WebMCP tools in Chrome via the Chrome DevTools Protocol

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published