Skip to main content
Glama
README.md
# PageMCP

**Any tab. A permissioned MCP server.**

The long tail of the web will never ship an MCP server. PageMCP gives a page one at
runtime: a browser runtime extracts what the page is and what it can do, a local bridge
exposes those actions as MCP tools, and every action passes a human permission gate and
returns an Ed25519-signed receipt.

No account. No cloud. The page never leaves the machine.

![PageMCP permission modal](docs/shots/modal.png)

*Every action stops at a human. Every result comes back signed.*

## Why

There are roughly a billion websites and only a few thousand MCP servers. A coffee shop,
a wedding invitation, a local clothing store — none of them will ever write an MCP
integration. Agents can read those pages, but they cannot safely act on them.

PageMCP is the adapter layer:

- **Read** — page identity, hours, address, menu, event, forms, actions.
- **Act** — only declared tools: fill a form, click a declared action, add an event to a
  calendar.
- **Verify** — every successful action returns a signed receipt, hash-chained to the
  previous one.

The permission gate and the receipt are the product. Scraping is the easy part.

## Architecture

![PageMCP architecture](docs/shots/architecture.png)

```
Browser tab (runtime/pagemcp.js)
  extracts a manifest, shows the permission modal, executes declared actions
        │ HTTP 127.0.0.1:8765
Local bridge (server/bridge.js)
  page registry + command queue, tool generation, Ed25519 receipts
        │ MCP JSON-RPC (stdio or TCP 8766)
Agent / MCP client (client/mcp_client.py)
```

## Quick start

Requirements: Node.js 18+ and Python 3.10+ (the Python client is stdlib only).

```bash
# 1. start the bridge
node server/bridge.js

# 2. serve the demo pages (separate terminal)
python -m http.server 8770 --bind 127.0.0.1 --directory .

# 3. open a demo
#    http://127.0.0.1:8770/demo/coffee/
#    (append ?auto=1 to skip the permission modal in automated tests)

# 4. list tools and run an end-to-end demo
python client/mcp_client.py list
python client/mcp_client.py demo coffee
python client/mcp_client.py demo shop
python client/mcp_client.py demo wedding
```

The bridge prints nothing to stdout except MCP responses; logs go to stderr.

## Browser extension

`extension/` is a thin Manifest V3 wrapper:

1. Open `edge://extensions` (or `chrome://extensions`), enable Developer mode.
2. **Load unpacked** → select `extension/`.
3. Open any page, click the PageMCP icon, click **Connect this tab**.
4. The PageMCP badge appears at the bottom right with the exposed tool count.

`tools/sync-extension.ps1` is not included in this repo; after editing
`runtime/pagemcp.js`, copy it to `extension/pagemcp.js` and reload the extension.

## Demos

| Demo | What it proves |
| --- | --- |
| `demo/coffee` | A small shop with JSON-LD and a reservation form. `page_info`, `submit_reserve`. |
| `demo/dynamic-shop` | Products and a booking form rendered 600 ms after load; the runtime re-reads the live DOM. |
| `demo/wedding` | Event schema, RSVP form, one-tap map action, `.ics` calendar download. |

All three were tested end-to-end with a real MCP client: page registration → tool
discovery → `page_info` → form submission → signed receipt → `verify_receipt` returns
`valid: true`.

Screenshots: `docs/shots/` (page badge, permission modal, confirmation).

## Security model

- **Declared tools only.** The runtime never exposes “click anything”. Forms and actions
  are enumerated, capped, and named.
- **Human in the loop.** Every non-read action shows a modal with the tool name and exact
  arguments. Cancel returns `cancelled by user` to the agent.
- **Signed receipts.** The bridge signs `{page, tool, args_sha256, result_sha256, prev}`
  with Ed25519. Receipts are hash-chained; `verify_receipt` verifies locally.
- **Local only.** The bridge binds to `127.0.0.1`. No page content is uploaded. No account
  or API key.
- **No credentials.** The runtime skips password and file inputs.

## Limitations

- The extension is a wrapper around the tested runtime; the popup button path was not
  clicked end to end (the injection path it calls was tested).
- Natural-language inference of tools is rule-based (JSON-LD, forms, `data-pagemcp-*`).
  An LLM fallback is the next step.
- Cross-page workflows are not in v0.1.
- Receipts prove integrity, not intent; a compromised page can still lie about its own
  confirmation text.

## Repository layout

```
server/bridge.js        HTTP + MCP + receipts
runtime/pagemcp.js      browser runtime (extract / confirm / execute)
extension/              Manifest V3 wrapper
client/mcp_client.py    minimal MCP client + demos
demo/coffee             static shop
demo/dynamic-shop       late-rendered DOM
demo/wedding            event + RSVP + calendar
docs/                   architecture, demo, test log, screenshots
data/                   generated keys + receipts (gitignored)
```

## Test log

See [`docs/TESTING.md`](docs/TESTING.md) for the end-to-end runs, the allow/cancel paths
and the receipt tamper test.

## License

MIT.