Skip to content

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";constsource=newCdpToolSource();awaitsource.connect({host: "localhost",port: 9222});// List all tools from all tabsconsttools=source.listTools();console.log(tools);// [{ name: "searchFlights", description: "...", inputSchema: "{...}" }]// Execute a tool (args and result are JSON strings per WebMCP spec)constresult=awaitsource.callTool("searchFlights",'{"from":"SFO","to":"JFK"}');console.log(result);// '{"flights":[...]}'// Listen for tool changessource.onToolsChanged((tools)=>{console.log("Tools changed:",tools.length);});// Clean upawaitsource.disconnect();

API

CdpToolSource

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

MethodDescription
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

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages