
webmcp-gate
io.github.hon2be/webmcp-gate
Use a logged-in web app tab's tools from MCP agents. A person approves risky actions in the page.
Documentation
webmcp-gate
Let an agent use the tools of a web app you are logged in to, safely.
A small local relay connects your page to Claude Code, Codex or any MCP agent. Risky actions are approved by a person in the page, not by the agent. No browser extension. 한국어

A real run of examples/02-approval. The agent side is a scripted MCP client. The dialog is redrawn from the browser's real one, because headless Chrome cannot capture it.
agent ──(MCP · stdio)──▶ relay ◀──(WebSocket · 127.0.0.1)── your logged-in tab
runs the tools, asks you to approve
Experimental (
0.1.0-alpha.2). Tried on macOS in headless Chrome, with a live Codex session and a live Claude Code session (read-only calls). Not tried on a production app or other browsers. What was checked
Why this one
- A pairing code per session, never sent: both sides only prove they know it.
- Allowed origins are listed one by one. No wildcard, nothing to switch off.
- A person approves risky actions in the page, and the relay re-checks the call afterwards.
- Thousands of tools? The agent gets
search,describe,readandcall. - Your own MCP tools with
registerToolin a config file.
Try it
git clone https://github.com/hon2be/webmcp-gate && cd webmcp-gate
npm install && npm run build
node examples/serve.mjs 01-hello # the page, on http://localhost:3000
In another terminal:
cd examples/01-hello/server
node ../../../plugins/claude/dist/cli.mjs trust # approve the example config
claude --plugin-dir ../../../plugins/claude
Ask "show the webmcp-gate status", paste the wgate1.… string into the page, press Connect, then ask the agent to read demo.echo. For the approval dialog, try examples/02-approval.
Install the plugin
# Claude Code
/plugin marketplace add hon2be/webmcp-gate
/plugin install webmcp-gate@webmcp-gate
# Codex
codex plugin marketplace add hon2be/webmcp-gate
codex plugin add webmcp-gate@webmcp-gate
Or run npx -y @webmcp-gate/server install claude (codex, all). Node 20+ is enough.
Use it in your app
npm i @webmcp-gate/client
import { connectBridge } from "@webmcp-gate/client";
const host = connectBridge({ connection }); // the string the agent's `status` tool shows
await host.registerTool({
name: "app.items.list",
description: "Lists items",
annotations: { readOnlyHint: true }, // read-only tools run with `read`
execute: async () => ({ ok: true, result: [] }),
});
More in docs/integrating.md. The wire protocol is documented (docs/protocol.md), so you can write your own client.
Packages: @webmcp-gate/client (your page), @webmcp-gate/server (relay and CLI), @webmcp-gate/protocol (shared types). All are 0.1.0-alpha.2. It is an alpha, so the API may change.
Config
Put webmcp-gate.config.ts in your project, like vite.config.ts. webmcp-gate init creates one.
import type { Config } from "@webmcp-gate/server";
export default {
origins: ["http://localhost:3000"],
tools(server, bridge, z) { // your own MCP tools
server.registerTool("list_menus", { description: "Lists menus", inputSchema: { keyword: z.string().optional() } },
async ({ keyword }) => ({ content: [{ type: "text", text: JSON.stringify(await bridge.call("app.menu.list", { keyword })) }] }));
},
} satisfies Config;
A config is code, so it runs only after you approve it with webmcp-gate trust. Agents cannot approve it. All fields are in docs/config.md.
One command for an app
When an app only needs allowed origins and an upload folder, one command installs the plugin, writes ~/webmcp-gate.config.mjs with those values and trusts it:
npx -y @webmcp-gate/server@0.1.0-alpha.4 install codex --origin https://app.example.com --attach ~/app-uploads
Use claude or all instead of codex, and restart the agent afterwards.
What the agent sees
| Tool | Does |
|---|---|
status | State and the connection string |
copy_connection | Puts the connection string on your clipboard, for agents that won't print it |
search | Finds page tools |
describe | One tool's input shape |
read | Runs a read-only page tool |
call | Runs any other page tool |
attach_file | Optional. Attaches a file from the one folder you allow |
Safety
- Listens on
127.0.0.1only. Only the origins you list can connect. - A 20-character pairing code per session (about 100 bits). Wrong tries are rate-limited.
- Approval stays in the page. The relay re-checks the call after you approve.
- Several tabs and several agent sessions can be connected at once. Each connection needs the code a person pasted, and when a relay has several tabs every call has to name one (
tab). attach_fileis off unless you set a folder, and it stays inside it.- A config runs only after
trust, as a single file.
Details and limits: docs/security.md.
More
FAQ · What was checked · Related projects · Roadmap · Architecture · Plugins · Privacy
Develop
npm install
npm test # typecheck, build, end-to-end tests
plugins/*/dist/cli.mjs is committed (twice) because a plugin runs alone from its folder. After changing source, run npm run build and commit the result.
MIT licensed.
If this project is useful to you, starring the repository helps other people find it.
@webmcp-gate/servernpm install @webmcp-gate/server