site-mcp
by kingonly
README.md
# site-mcp
**MCP tools for websites that have no API.** You ask, the answer comes back, and nothing opens on your screen. An agent explores a flow on a site once and writes it down as a JSON spec; from then on the flow is one tool. Where the site allows it, a call runs as plain HTTP requests and answers in under a second. Otherwise it runs in a hidden browser. A window appears only for flows where a human has chosen to press submit.
> **Status: pilot.** Five flows on four live sites run on one runtime with no site-specific code; three of them run without a browser, and no window opens for any of them. It has not been used on a site that requires login. See [Limitations](#limitations) and [Next steps](#next-steps).
## Why
Many sites people depend on (banks, government services, internal portals) have no API and no MCP server. Letting an LLM agent drive them freely is slow, costs tokens on every run, and is risky when the last button moves money or sends something.
site-mcp separates the three concerns:
| Phase | Who | How often | Output |
|---|---|---|---|
| **Explore** | An agent with a browser tool | Once per flow | `flows/<name>.json` |
| **Compile** | The runtime | At server start | MCP tools, no code generated |
| **Replay** | The runtime, no LLM in the loop | Every call | The result, or a verified form left for a human |
```mermaid
flowchart LR
A[Agent explores the flow once] --> B[flows/name.json]
B --> C{commit.by}
C -->|tool| R[one tool: name]
R --> H{http recipe?}
H -->|yes| T1[Plain requests<br/>no browser]
H -->|no, or it failed<br/>before submitting| T2[Hidden browser<br/>fill, read back, submit]
C -->|human| P[name_prepare<br/>visible window: fill, read back, stop]
P --> E{{Human reviews<br/>and clicks submit}}
T1 --> F[Result]
T2 --> F
E --> F
```
## Execution tiers
A browser is the most expensive way to talk to a site, so a call uses the cheapest tier that works and reports which one ran (`"via"`).
| Tier | What runs | Typical time | On screen | Used when |
|---|---|---|---|---|
| Requests | Plain HTTP from the spec's `http` recipe. No browser process. | 0.2 to 1 s | Nothing | The flow has a recipe and the tool commits |
| Hidden browser | Playwright Chromium without a window | 3 to 9 s | Nothing | No recipe, or the recipe failed before submitting |
| Visible browser | The same, in a window | 3 to 9 s | The filled form | A human commits the flow |
Measured on the pilot flows:
| Flow | Browser | Requests |
|---|---|---|
| Israel Post zip finder | 8.8 s | 0.24 s (0.6 s on the very first call) |
| Purchase tax simulator | 3.5 s | 0.3 to 1.1 s |
The tool acts as the user's browser and presents itself as one. Requests are sent the way Chrome sends them (connection handshake and headers, via [impit](https://github.com/apify/impit)), and the hidden browser runs under Chrome's ordinary name rather than "HeadlessChrome". Sites commonly turn away clients that fail either test; Israel Post's page does, and it was measured to check nothing else. See [Responsible use](#responsible-use).
Some recipes need a value that the site hands out in its page, such as an API key in the markup. A recipe can declare a **bootstrap**: the page is fetched once (by request, or in the hidden browser if that fails), the value is read and cached on disk, and it is fetched again only when the site rejects it.
## Design principles
- **Submit policy is per flow.** Each spec says who presses the final button. `"by": "tool"` suits lookups, calculators and anything safe to repeat, and makes the flow a single tool. `"by": "human"` suits payments and anything that cannot be undone: the tool fills and verifies, and the runtime refuses to click. The default is `human`, so automation of the last step is always an explicit choice.
- **Read-back, not trust.** In the browser tier, every value is read from the DOM after it is entered and compared with what was asked. A mismatch is an error, never a "ready". The request tier has no form to read back; it reports what it sent, and `check` requires its result to equal the browser's.
- **Cheapest tier first, openly.** Requests before browser, hidden before visible. Every result says which tier ran, and a fallback says why.
- **Deterministic replay.** A spec is a fixed list of steps. No model decides anything at call time.
- **No site-specific code.** If a flow cannot be expressed in the spec, the runtime gets a generic capability. It never gets a special case.
- **Fail loudly.** A missing element, an unknown option, or a page that left the allowed hosts is an error that names the step.
## How it compares
Other projects turn websites into agent tools by driving a browser or by replaying API calls. site-mcp does both from one spec, picks the cheaper one per call, and checks that they agree.
| | Runs without a browser | Falls back to a browser | No LLM or cloud service at run time | Submits forms under a per-flow policy | Checks its own results |
|---|:---:|:---:|:---:|:---:|:---:|
| **site-mcp** | ✅ 3 of 5 pilot flows | ✅ | ✅ | ✅ tool or human, enforced | ✅ read-back, and both tiers must match |
| [webpage-mcp](https://github.com/mcpland/webpage-mcp) | ❌ drives Chrome | n/a | ✅ | ➖ replays actions, no stated policy | ❔ |
| [workflow-use](https://github.com/browser-use/workflow-use) | ❌ drives Chromium | n/a | ➖ agent steps in on failure | ➖ replays actions, no stated policy | ❔ |
| [browser-to-mcp](https://github.com/browser-to-mcp/browser-to-mcp) | ❌ drives Chromium | n/a | ✅ | ❌ read-only by design | ✅ drafts tested against expected answers |
| [MCPKit](https://mcpkit.sh/) | ❌ cloud browser | n/a | ❌ needs cloud browser and model | ❔ | ❔ |
| HAR-based generators ([web2sdk](https://github.com/jasonwcfan/web2sdk), [Integuru](https://github.com/Integuru-AI/Integuru)) | ✅ | ❌ | ✅ | ➖ sends requests, no stated policy | ❔ |
| [WebMCP / MCP-B](https://github.com/WebMCP-org) | n/a, runs in the page | n/a | ✅ | Up to the site | Up to the site |
✅ yes · ➖ partly · ❌ no · ❔ not documented. The other rows are based on each project's README as of December 2026; none was installed or benchmarked, so check the projects themselves.
What the combination gives you:
- **Speed.** A request-tier call answers in 0.2 to 1 second, against 3 to 9 seconds in a browser. The Israel Post lookup went from 8.8 s to 0.24 s.
- **Nothing on screen.** No window ever opens for a flow the tool submits. Even the fallback browser is hidden.
- **One tool per flow.** The model sees `israel_post_zip`, not a set of step tools.
- **Resilience.** When a recipe breaks before submitting, the same call completes in the browser and says so. API-replay tools have no second path; browser tools have no fast path.
- **No per-call cost.** No model and no cloud browser is involved after the flow is explored.
- **Control over the last step.** Each flow states whether the tool or a human submits, and the runtime enforces it.
- **Evidence.** `check` runs both tiers on the same input and fails unless the results are identical.
Where others are ahead: webpage-mcp works inside the user's real, logged-in Chrome session; workflow-use has a recorder and an agent that takes over when a step fails; WebMCP is the cleanest answer when the site owner takes part.
## Included flows
| Flow | Site | What it exercises |
|---|---|---|
| `purchase_tax` | Israel Tax Authority purchase tax simulator | ASP.NET postbacks, dependent dropdown, date picker. **Runs without a browser** (ViewState form post) |
| `btl_insurance_fees` | Bituach Leumi insurance fee calculator | 2-screen wizard, radio groups |
| `btl_child_savings` | Bituach Leumi savings-per-child calculator | Single screen. Spec written by a fresh agent from this README alone |
| `uk_visa_check_israeli` | GOV.UK visa checker | 4-screen wizard with identical selectors on every screen. **Runs without a browser** (one request) |
| `israel_post_zip` | Israel Post zip code finder | React/MUI, autocomplete fields, generated ids, popup over the form, page protected by Cloudflare. **Runs without a browser**, including reading the page's API key (JSON API) |
All five are public, read-only calculators or lookups, chosen so the pilot could be replayed freely. They are set to `"by": "tool"`; the tests also run one of them in human mode.
## Quick start
Requires Node.js 22 or later.
```bash
git clone https://github.com/kingonly/site-mcp.git
cd site-mcp
npm install
npx playwright install chromium
```
Run one flow against the live site:
```bash
node bin/site-mcp.js check flows/purchase_tax.json
```
Register the server with an MCP client, for example Claude Code:
```bash
claude mcp add site-mcp -- node /path/to/site-mcp/bin/site-mcp.js serve /path/to/site-mcp/flows
```
No window opens unless a flow is committed by a human. Browser profiles are kept in `~/.local/share/site-mcp/` (`profile` for the visible browser, `profile-hidden` for the hidden one), screenshots in `shots`, cached bootstrap values in `cache`.
## Tools
A flow the tool commits is **one tool**, named after the flow. Call it and get the result.
A flow a human commits is two tools:
| Tool | What it does |
|---|---|
| `<name>_prepare` | Opens the site in a visible window, fills the form from the parameters, reads every value back, outlines the commit button, takes a screenshot. Does not submit. |
| `<name>_result` | Returns the result fields after the human clicked. Returns `not_committed` if they have not, or `site_error` with the site's own message. |
Starting the server with `SITE_MCP_STEP_TOOLS=1` also exposes `_prepare`, `_result` and `_commit` for tool-committed flows, for debugging and tests.
Example with `israel_post_zip`, answered by the request tier:
```jsonc
// israel_post_zip { "city": "תל אביב", "street": "דיזנגוף", "house_number": "50" }
{
"status": "done",
"fields": { "zip": "6433222" },
"sent": { "city": "תל אביב - יפו", "street": "דיזנגוף", "house_number": "50" },
"via": "http"
}
```
With `"by": "human"`, `_prepare` fills the real form and returns `"status": "ready_for_commit"` with the values read back from the page.
## Adding a flow
1. List the page's controls:
```bash
node bin/site-mcp.js probe https://example.com/form
```
`probe` shows only the first screen. Result and error markup has to be read while driving the flow.
2. Drive the flow once, by hand or with an agent that has a browser tool. Note each selector, what appears after each click, and what the result looks like.
3. Write `flows/<name>.json` using the reference below.
4. Verify against the live site:
```bash
node bin/site-mcp.js check flows/<name>.json # hidden
node bin/site-mcp.js check flows/<name>.json --headed # watch it
```
5. Optional, for flows the tool commits: add a request recipe so the flow runs without a browser.
```bash
node bin/site-mcp.js record flows/<name>.json # what the page really sent
```
Write the `http` section from that output (reference below), then run `check` again. `check` runs the browser and the recipe on the same input and fails unless the fields are identical.
6. Restart the MCP server. The new tools are available.
## Flow spec reference
```json
{
"name": "purchase_tax",
"description": "Shown to the model as the tool description.",
"start_url": "https://www.misim.gov.il/svsimurechisha/",
"allowed_hosts": ["www.misim.gov.il"],
"params": {
"property_type": { "type": "string", "description": "...", "enum": ["apartment", "land"], "required": true },
"deal_date": { "type": "string", "description": "DD/MM/YYYY" }
},
"steps": [
{ "do": "fill", "selector": "#date", "value": "{deal_date}", "when": "deal_date", "then_press": "Tab", "label": "deal date" },
{ "do": "select", "selector": "#type", "value": "{property_type}", "map": { "apartment": "30", "land": "70" }, "label": "property type" },
{ "do": "wait", "selector": "#calc option:nth-child(2)" },
{ "do": "check", "selector": "input[name='currency']", "value": "nis", "label": "currency" },
{ "do": "click", "selector": "#next" }
],
"commit": { "selector": "#submit", "label": "חישוב", "by": "tool" },
"result": {
"ready": "#resultTable",
"error": "#errorBox",
"fields": {
"total": { "selector": "#resultTable tr:last-child td:last-child" },
"rows": { "selector": "#resultTable", "as": "table" },
"note": { "selector": "#note", "optional": true }
}
},
"example": { "property_type": "apartment" },
"expect": { "total": "20,538" },
"cases": [ { "name": "...", "args": { }, "status": "done", "fields": { } } ]
}
```
Steps:
| `do` | Meaning |
|---|---|
| `fill` | Type `value` into the field. `then_press` sends a key afterwards (date pickers often need `Tab`). |
| `select` | Choose the option whose value is `value`. |
| `check` | Without `value`: tick the one checkbox or radio. With `value`: `selector` matches a radio group and `value` picks the member. |
| `pick` | Autocomplete field: types `value`, waits for the suggestions matched by `options`, and chooses the one whose text equals `value`. If there is exactly one suggestion it takes that one and reports its full text. Otherwise it fails and lists the suggestions. |
| `click` | Click a button that is not the commit button, such as "next" in a wizard. |
| `wait` | Wait for `selector` (`state`: `attached` by default, or `visible`). |
| `press` | Send a key to the element. |
| `goto` | Navigate to `value`. |
Selectors are Playwright selectors; plain CSS is the safe choice. On ASP.NET sites the generated ids are long and unstable, so match the stable tail: `[id$='StartNextButton']`.
`probe` shows only the first screen. The result and error markup has to be read while driving the flow once.
Result: `ready` is a selector that is visible only once the result is shown. `error` is a selector that is visible and non-empty only when the site rejected the input (a hidden or empty error box does not count). Each field returns the element's text with whitespace collapsed, or rows of cells with `"as": "table"`; the first match is used; a missing field is an error unless `"optional": true`. Values are returned as the site prints them (`"12,618 ש\"ח"`), not as numbers.
`commit.by` is `"human"` (default) or `"tool"`. `commit.label` is only shown to the human and the model; it is not matched against the page.
`check` prints two JSON objects: the prepare report (`ready_for_commit`), then, for a flow the tool commits, the result. `"status": "done"` means it worked. `check` runs only `example`; `cases` run in `npm test`. A case is `{ "name", "args", "status"?, "fields"?, "prepare_error"? }`: it prepares with `args`, commits, and compares the status and the listed fields, or expects prepare to fail with a message matching `prepare_error`.
Common keys: `value` takes `{param}` placeholders, `map` translates a parameter value to the site's value, `when` skips the step when that parameter is absent, `label` names the field in the read-back report.
Top-level option: `"overlays": ["#popup"]` for popups and banners that cover the form. They are hidden by CSS for the whole flow.
On sites with generated ids (React, MUI), select by role and name or by text: `role=combobox[name='יישוב']`, `role=button[name='חיפוש מיקוד']`, `text=/המיקוד לכתובת הינו/ >> xpath=..`.
`example` is required by `check` and the tests. `expect` and `cases` are optional test data.
## Request recipe reference (`http`)
Optional. Allowed only with `"by": "tool"`, because a direct request is a submit.
```json
"http": {
"bootstrap": {
"url": "https://example.com/form",
"values": { "api_key": { "selector": "[data-apikey]", "attr": "data-apikey" } }
},
"headers": { "x-api-key": "{boot.api_key}" },
"vars": { "kind": { "param": "property_type", "map": { "apartment": "30", "land": "70" } } },
"steps": [
{ "get": "https://example.com/form", "save": "page" },
{ "post": "https://example.com/form/Options", "json": { "kind": "{kind}" }, "save": "options" },
{ "choose": { "from": "options.json.d", "where": "Value", "equals": "{calc}", "label": "calculation" }, "save": "calc_row" },
{ "post": "https://example.com/form", "form_base": "page",
"form": { "kind": "{kind}", "calcIndex": "{calc_row.$index}", "amount": "{price}" },
"submits": true, "save": "final" },
{ "expect": { "value": "{final.url}", "contains": "Result.aspx",
"site_error": { "in": "final", "css": "#errorBox" } } }
],
"sent": { "kind": "{property_type}", "calculation": "{calc_row.Text}", "amount": "{price}" },
"result": { "fields": {
"total": { "in": "final", "css": "#resultTable tr:last-child td:last-child" },
"rows": { "in": "final", "css": "#resultTable", "as": "table" },
"code": { "value": "{final.json.Result.code}", "pattern": "[0-9]{7}" }
} }
}
```
| Key | Meaning |
|---|---|
| `steps[].get` / `post` | A request. `json` sends a JSON body; `form` sends a URL-encoded form; `form_base` starts from every field of a saved page's form (ViewState and other hidden fields) and `form` overrides. `headers` adds headers. The answer is stored under `save` as `{ status, url, text, json }`. Cookies are kept for the run and redirects are followed; `url` is the final address. |
| `"submits": true` | Marks the one request that commits. Required on exactly one request. |
| `choose` | Picks one item from a JSON list: the one whose `where` property equals `equals`, or the only item if there is just one. Otherwise the call fails and lists the candidates. The item is saved with `$index`, its position in the list. |
| `expect` | Asserts that a rendered value contains a string. If it does not and `site_error` finds text, the tool returns `site_error` with the site's message. |
| `vars` | Named translations of a parameter into the site's values. |
| `bootstrap` | Values read from the site's page: fetched by request, or in the hidden browser if that fails. Cached in `~/.local/share/site-mcp/cache` and available as `{boot.<name>}`. Fetched again when the site answers 401 or 403, or after `ttl_hours` if set. Keeps site keys out of the spec file. |
| `sent` | What the result reports as sent. |
| `result.fields` | Same field names as the browser `result.fields`. Either `value` (a template) or `in` + `css` (plain CSS) on a saved HTML answer, with `"as": "table"` for rows of cells. |
Placeholders are `{param}`, `{var}`, `{boot.name}` and paths into saved answers such as `{row.id}` or `{found.json.Result.zip}`. Values placed in URLs are URL-encoded.
Result fields in both tiers accept `"pattern"`, a regular expression whose first match becomes the value. An empty value is an error unless the field is `"optional"`, so a site answering "nothing found" never produces a `done`.
Writing a recipe:
- `record` prints one entry per request (`type`, `method`, `url`, `status`, `headers`, `form` or `body`, and the first 400 characters of the `answer`); redirect hops are separate entries. The answers are cut short, so for HTML results reuse the browser `result` selectors as `css`.
- A recipe does not have to replay every recorded request. Keep the ones the final answer depends on. If a wizard keeps earlier answers in the URL, one request can be enough.
- The `submits` request can be a `get` or a `post`: it is the one the commit button triggers. Query strings go inline in the URL.
- Placeholders work in URLs (path and query), headers, bodies, `expect.value`, `expect.contains`, `sent` and `value`.
- `site_error.css` counts when the element exists in the answer and has text. There is no notion of visibility in raw HTML, so pick a selector the site only fills on failure.
- `sent` is free-form and is not compared by `check`; use names a reader will recognise.
- `check` succeeds when its last line is `http recipe ok: same fields as the browser`. It runs only `example`, so try other parameter values too.
Rules of the request tier:
- **Hosts.** Every request and every redirect hop must be https and on `allowed_hosts`.
- **Fallback boundary.** If the recipe fails before the `submits` request, the call falls back to the hidden browser and reports `fallback_reason`. If it fails after, the call is an error and nothing is retried, so a flow is never submitted twice.
- **No fallback for bad input.** An ambiguous choice or a site validation message is returned as is.
- **Uncovered parameters.** If a call passes a parameter the recipe never mentions, the call goes to the browser instead of dropping it.
## Safety model
- **The submit policy is enforced.** With `"by": "human"` (the default) no commit or run tool exists, the runtime refuses to click the commit button, and an `http` recipe is rejected at load. In every flow, a step that clicks the commit selector is rejected at load, and at run time each `click` is compared with the commit button as elements, so a differently written selector that lands on the same button is refused. The commit happens only through the commit or run tool, or the human.
- **Read-back.** Before every `click` and at the end, each entered value is read from the DOM and compared with what was asked. A mismatch fails the tool; it does not report "ready".
- **Hosts.** If the page leaves `allowed_hosts`, the tool fails.
- **No fallbacks.** A missing selector, an option that does not exist, or an unknown parameter is an error, with the step number.
## Tests
```bash
npm test
```
Runs every flow over real MCP stdio against the live sites: prepare, commit, and the one-call tool, asserting that the one-call tool returns the same fields as the browser. It then checks the default tool list, the human-click path, the commit guard, and the request tier's boundaries (no browser launched, no request in human mode, fallback only before the submit, hosts, empty results). It needs network access. No window opens. A failure usually means a site changed and the spec needs re-exploring.
## What the pilot found
| Flow | Runtime changes it required |
|---|---|
| 1. Purchase tax | Built alongside the runtime |
| 2. Insurance fees wizard | Read-back before each screen change; radio groups |
| 3. Visa checker | None |
| 4. Child savings (written by a fresh agent) | None |
| 5. Israel Post zip finder | Autocomplete step; overlay hiding |
| Request tier (flows 1, 3 and 5) | New `http` recipe engine, bootstrap, `record` command |
| Nothing on screen | Browser-grade request client; hidden browser under its ordinary name; window only for human-commit flows; one tool per flow |
- Plain forms and wizards replay reliably once the runtime knows the widget type. Each new widget type costs one generic addition.
- Israel Post's page turned away plain requests and the default hidden browser. Testing one variable at a time showed exactly two checks: the connection handshake must look like a browser's, and the client must not name itself "Headless" or "curl". No window and no JavaScript check was involved, so an early conclusion that the site "needs a visible window" was wrong.
- Three of the five flows were compiled to plain requests and return the same fields as the browser, 3 to 35 times faster. The form's HTML was not enough to do it: one site needed hidden fields that its script fills and a setup request made by a dropdown, which only showed up in recorded traffic.
- That site's API has neither check, only a key that its page hands out. With a browser-grade request client the key is read by request too, so the flow needs no browser at all.
- The first two request recipes were written by hand from recorded traffic. A third (`uk_visa_check_israeli`) was written by a fresh agent from this README and `record` output alone, with no code changes, and passed `check` on the first run: it collapsed a 4-screen wizard into one request.
- A review during the pilot found that the commit guard compared selector strings only. The runtime now compares the resolved elements before every click.
## Limitations
- **No login sites yet.** The runtime drives its own Chromium profile. It has not been tried on a site that requires authentication, and it does not attach to the user's existing browser session.
- **The request tier is for tool-committed flows only.** A human-submit flow needs a page to look at, so it opens a window until approval can be asked in the conversation.
- **Request recipes are more brittle than the page.** They depend on endpoints a site does not document. `check` and the tests catch drift; the browser tier remains as fallback.
- **Recipes are written by an agent or a person** from `record` output. The step is not yet part of an automatic pipeline.
- **One commit point per flow.** Intermediate "continue" buttons are clicked by the runtime. A flow where a human must approve every screen cannot be expressed yet.
- **Linear flows only.** A wizard whose questions depend on earlier answers needs one spec per path.
- **Exploring is manual.** An agent writes the spec with `probe` and a browser tool. There is no recorder.
- **No self-healing.** When a site changes, the tool fails with the step that broke, and the flow is explored again.
- **One server at a time.** The server, `check`, and the tests share browser profiles and cannot run at the same moment.
- **Bot protection can change.** A site can tighten its checks at any time. The tool does not solve challenges; a flow that starts being challenged fails and says so.
## Next steps
1. **Approval in the conversation** (MCP elicitation): for human-submit flows, show the values in the chat and submit on approval, so no window is needed.
2. **Build tools from use:** when no flow exists for a request, let the agent do it once in the browser and save the spec as a by-product.
3. **Make recipe writing automatic:** after exploring, have the agent run `record`, write the recipe, and keep it only if `check` passes.
4. **Attach to the user's browser** (Chrome DevTools Protocol or an extension) so flows work behind a login without handling credentials. Evaluate [webpage-mcp](https://github.com/mcpland/webpage-mcp) for this part.
5. **Checkpoints and branching:** several human-only buttons in one flow, and wizards whose path depends on earlier answers.
6. **Drift detection:** a scheduled `check` per flow that reports when a site changed.
7. **A shared registry of flow specs,** so a site explored once works for everyone.
## Responsible use
The tool acts for one person, at the pace of that person's requests, on pages they could open themselves. It presents itself the way their browser would: requests use a Chrome-like connection and headers, and the hidden browser does not label itself "Headless". Some sites filter on exactly those signals, so be deliberate about where you point it, and check a site's terms of use before adding a flow, in particular a request recipe: it calls the endpoints the site's own page calls, which the site does not document for outside use.
It does not solve captchas, does not go around logins, and does not rotate identities or addresses. Do not use it for bulk collection. Site keys are read from the page at run time and are not stored in this repository. The included flows target public, read-only pages. The project is not affiliated with any of the sites listed.
## Project layout
```
bin/site-mcp.js CLI: serve, probe, check, record
src/runtime.js spec loading, browser tier: steps, read-back, results; tier selection (no site knowledge)
src/http.js request tier: recipe engine (no site knowledge)
src/server.js flow specs -> MCP tools
flows/ one JSON spec per flow
test/e2e.js end-to-end over MCP against the live sites
```
## License
[MIT](LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues