webmcp-gate
# webmcp-gate
[](https://glama.ai/mcp/servers/hon2be/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. [한국어](README.ko.md)
```
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.0`). 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](docs/status.md)
## 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`, `read` and `call`.
- Your own MCP tools with `registerTool` in a config file.
## Try it
```bash
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:
```bash
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`](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@next install claude` (`codex`, `all`). Node 20+ is enough.
## Use it in your app
```bash
npm i @webmcp-gate/client@next
```
```ts
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](docs/integrating.md). The wire protocol is documented ([docs/protocol.md](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.0`, so install them with `@next`.
## Config
Put `webmcp-gate.config.ts` in your project, like `vite.config.ts`. `webmcp-gate init` creates one.
```ts
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](docs/config.md).
## What the agent sees
| Tool | Does |
|---|---|
| `status` | State and the connection string |
| `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.1` only. 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.
- One tab at a time.
- `attach_file` is 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](docs/security.md).
## More
[What was checked](docs/status.md) · [Related projects](docs/related-work.md) · [Roadmap](docs/roadmap.md) · [Architecture](docs/architecture.md) · [Plugins](docs/plugins.md) · [Privacy](docs/privacy.md)
## Develop
```bash
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.
TDQS
Scored across 5 tools
Each tool has a clear primary role: status for connection, search for discovery, describe for inspection, read and call for execution. The only overlap is read vs. call, since read is a restricted subset of call, but the descriptions explicitly say to use call for anything that changes state, which resolves most confusion.
All names are short, lowercase, single-word and prefix-free, giving a predictable vocabulary. The only minor deviation is that status is a noun while the others are verbs (search, describe, read, call), but the set still reads as a coherent convention.
Five tools is exactly right for a gateway: connect, discover, inspect, execute-read, execute-write. Each tool earns its place with no redundant surface area.
The lifecycle of discovering and invoking tab tools is fully covered, including a safety split between read-only and mutating execution. Minor gaps exist, such as no explicit disconnect/reset operation or a way to enumerate all tools without a query, but agents can work around these.