Record a web app once in your browser. Call it forever without one.
Web2MCP turns web apps that have no public API into MCP tools for AI agents such as Claude Code, Cursor and Codex. It learns an app's real HTTP requests from one browser recording, a HAR file, a cURL command or an OpenAPI/Postman file, then calls them over plain HTTP — no browser at call time. Read-only by default; writes need a reviewed contract.
English | 简体中文
pip install git+https://github.com/xuexying/web2mcp
web2mcp inspect site.har
web2mcp discover site.har --out my-profile --origin https://api.example.com --read-only-safe- No browser at call time. Tools send plain HTTP requests learned from your recording; the browser is only needed to explore, log in and re-verify.
- Writes are guarded. Every write is previewed, needs explicit approval, is read back from the server to verify the business result, and is protected by a persistent duplicate-submission lock.
- "Captured" is never treated as "verified". Observed requests are candidates; tools are published only after trials with assertions pass.
They are different things with similar names.
- WebMCP is a W3C draft that lets site authors expose tools from inside their own pages. The site has to adopt it.
- Web2MCP (this project) works from the outside. It turns the recorded traffic of a web app you are authorized to use into MCP tools, with no cooperation from the site.
If the site you need already ships WebMCP tools or an official API, use those. Web2MCP is for the apps that offer neither.
flowchart LR
A[URL & goal] --> B[Browse / log in once]
B --> C[Capture real HTTP requests]
C --> D[Candidate operations + JSON integration pack]
D --> E[Trials with assertions]
E --> F[Install verified tools]
F --> G[Python / stdio MCP calls]
G -->|login expired or API changed| B
The capturer records what actually happened, packs describe how to call it, and the executor sends requests under constraints. The optional autopilot layer only orchestrates this flow — a model never generates arbitrary code for direct execution.
Log into the target site in any browser, do the few actions you care about, then save the traffic:
- Chrome / Edge: DevTools (F12) → Network tab → right-click any request → Save all as HAR with content.
- Firefox: DevTools → Network tab → gear icon ⚙ → Save All As HAR.
- Safari: enable the Develop menu, then Develop → Show Web Inspector → Network tab → Export.
Phone and desktop apps (not just browsers): route the app through mitmproxy with its CA certificate trusted, then export a HAR (File → Export → HAR, or run mitmweb/mitmdump with --save-har out.har). mitmproxy emits standard HAR 1.2, which web2mcp quick / discover consume directly — so a phone app or an Electron desktop app integrates the same way a website does. Only capture apps and accounts you are authorized to automate.
The HAR carries your login state (cookies), so treat the file as a credential and keep it out of version control.
Running discover on a capture produces a private profile directory containing:
- An MCP server (
web2mcp serve <profile>, stdio transport) plus a ready-to-pastemcp.json. - A CLI + a
SKILL.mdso a terminal agent (Claude Code, Codex, …) can drive the same tools over the command line (web2mcp call <profile> <op>) — with the same write safety. Same profile, four shapes: MCP, CLI, Python, spec. - A generated Python client (
client.py) with one method per operation. - An OpenAPI 3.1 spec (
openapi.json) describing the observed surface, including read/write annotations and RPC variants. - A hash-chained local audit log of every call, with sensitive values redacted.
git clone https://github.com/xuexying/web2mcp.git
cd web2mcp
python3 -m venv .venv && source .venv/bin/activate
python -m pip install -e '.[test]'
python examples/demo.py --verbose
python -m pytest -qThe demo spins up a fictional loopback-only purchase system, captures samples, builds a profile, then — over a real MCP stdio connection — reads a record, previews an approval, approves once, verifies the result by reading it back, and blocks the duplicate submission. All data is synthetic; no real AI or browser is involved.
| Web2MCP | Browser-automation MCP servers | An official API | |
|---|---|---|---|
| What runs on each call | Plain HTTP requests learned from a recording | A real browser, driven step by step | Documented HTTP endpoints |
| Needs the vendor to provide something | No | No | Yes |
| Tends to break when | The app's backend requests change | The page layout changes | The API version changes |
| Writes | Hidden until a reviewed contract is installed; then preview → approval → read-back → duplicate lock | Depends on the tool | Whatever the API allows |
| Use it when | You are authorized to use an app that has no API, and you call it repeatedly | The site needs in-browser logic (signatures, challenges), or it is a one-off task | One exists — prefer it |
Web2MCP does not bypass CAPTCHAs, proof-of-work challenges or device binding. When a site uses them, it stops and tells you the site is not supported this way.
The shortest path from a URL to a read-only MCP server, on macOS, Linux and Windows. Needs the optional recorder:
pip install 'web2mcp[record]'
playwright install chromium
web2mcp record https://app.example.com --out work/siteA Chromium window opens; log in and click through the parts you care about, then close the window to finish. The recorded traffic becomes work/site/capture.json, and record prints the per-origin summary and a ready-to-paste discover command. You type passwords and verification codes yourself in the window — any request carrying a password-like field is dropped before anything is written, and the raw recording is deleted after conversion. Then:
web2mcp discover work/site/capture.json \
--out work/site-profile --origin https://api.example.com --read-only-safe
web2mcp serve work/site-profileWorks on any OS with any browser and no extra tooling at all. Only use captures of sites and accounts you are authorized to automate.
Fastest path — web2mcp quick: inspect, auto-pick the API origin, build a read-only-safe profile and print a paste-ready MCP config, in one command. It proceeds automatically when there's a single clear API origin, and stops to let you choose with --origin when there are several:
web2mcp quick work/site.harPrefer the explicit steps? Not sure which --origin to pass? inspect shows per-origin operation counts, read/write split and login presence, and prints a ready-to-paste discover command (third-party/analytics hosts are flagged and excluded):
web2mcp inspect work/site.harOne step to a safe read-only MCP server — only read tools are exposed, every write is hidden and blocked at the execution layer (read_only_mode):
web2mcp discover work/site.har \
--out work/site-profile --origin https://api.example.com --read-only-safe
web2mcp serve work/site-profileHAR import reconstructs the cookie snapshot from request/response headers, so your login travels with the HAR — cookie-authenticated sites work immediately. Add --policy examples/policy.json (adapted to your actual endpoints) to name tools and mark read/write semantics explicitly; HTTP method alone is not sufficient and side-effect paths (logout/export/approve/…) are never auto-classified as reads.
To enable writes: review semantics, then use trial-read / publish-reads, or the pack flow draft-pack → check-pack → trial-pack → install-pack, and install a reviewed write contract. Full walkthrough in docs/INTEGRATION.md; pack syntax in web2mcp/pack_reference.md.
Just one endpoint? Paste a DevTools "Copy as cURL" (bash) command and add that single operation to a profile — no HAR needed:
pbpaste | web2mcp add-curl work/site-profile # macOS; use your clipboard tool of choiceRepeated add-curl calls accumulate into the same profile; the real response shape is filled in later by a trial-read.
Already have an OpenAPI spec? Build a profile straight from it, no capture needed — web2mcp's job becomes adding a reviewed write-safety layer on top of an API you already have:
web2mcp import-openapi api-spec.json --out work/api-profile # OpenAPI 3.x JSON
web2mcp import-postman collection.json --out work/api-profile --var baseUrl=https://api.example.comReads are exposed read-only-safe by default (add --writes to expose writes too). The spec carries no credentials, so add them to the profile's private credentials.json — the reported security schemes say what's needed — then trial-read tightens the placeholder response shapes. A Postman collection's saved example responses are used as real response shapes where present.
Needs a browser backend, selected with --backend (default: auto):
playwright— bundled Chromium, cross-platform (pip install 'web2mcp[record]').ego— ego-browser (optional; free; macOS and Windows).cdp— attach to a Chrome you started with--remote-debugging-port=9222, reusing its live login.
python -m web2mcp explore-start work/exploration \
--url https://example.com --backend playwright \
--goal 'read the task list and details, verify two different tasks'
python -m web2mcp serve-explorer work/explorationA connected AI observes pages, drives bounded reviewed UI actions, drafts candidate configs, runs trials and installs tools. You complete logins yourself in the browser — the program never receives passwords or verification codes. source-map / explore-survey / synth-profile can map an app's API surface from its shipped JavaScript plus runtime capture; synthesized profiles default to read_only_mode. (The HAR path and web2mcp record need no backend at all.)
A local HTTP API accepts a URL and a goal; a configurable model plans exploration, trials, questions and publishing. The loop and its safety gates are covered by tests with a simulated model, but no real model has yet driven a real site end to end — see ROADMAP.md.
cp model.example.json model.local.json # set endpoint/model; API key via WEB2MCP_MODEL_API_KEY
python -m web2mcp serve-integrations work/integrations \
--model-config model.local.json --port 8766The service listens on 127.0.0.1 only and requires a local bearer token (path printed at startup). Jobs pause with waiting_user for logins, business choices and every write authorization.
| API | Purpose |
|---|---|
POST /v1/integrations |
Create an integration job |
GET /v1/integrations/{id} |
Progress and pending questions |
POST /v1/integrations/{id}/responses |
Answer questions / approve specific actions |
POST /v1/integrations/{id}/pause · /resume |
Pause after the current step; resume with a bounded budget |
GET /v1/integrations/{id}/mcp-config |
MCP config for the verified tools |
Let install wire the profile into a client for you — it previews by default and only writes with --write (backing up the file first):
web2mcp install work/site-profile --client cursor --write # also: claude-desktop
web2mcp install work/site-profile --client claude-code # prints the `claude mcp add` command
web2mcp install work/site-profile --client codex # prints the TOML / `codex mcp add`Claude Code and Codex keep other state in their config, so for those install prints the exact command to run rather than editing the file. Or configure manually — each profile also ships an mcp.json:
{
"mcpServers": {
"my-product": {
"command": "/absolute/path/to/.venv/bin/python",
"args": ["-m", "web2mcp", "serve", "/absolute/path/to/profile"]
}
}
}from web2mcp import Product
with Product("work/site-profile") as product:
print(product.tools())
result = product.call("my_product__read", {"id": "123"})For step-by-step answers with commands, see the documentation site.
Record the app once with web2mcp record <url> --out <dir> (or export a HAR from your browser), run web2mcp quick on the capture, then run web2mcp install <profile> --client cursor --write (also claude-desktop; for claude-code and codex it prints the command to run). After that the agent calls the app over plain HTTP; no browser is involved.
Run web2mcp quick site.har. It picks the API origin, builds a read-only-safe profile and prints a paste-ready MCP config. web2mcp serve <profile> runs the server over stdio.
Yes. web2mcp add-curl adds one "Copy as cURL" request to a profile, web2mcp import-openapi builds a profile from an OpenAPI 3.x document, and web2mcp import-postman does the same from a Postman v2.x export.
Yes, if you can capture their traffic. Route the app through mitmproxy, export a HAR, and use it like any other HAR. Only capture apps and accounts you are authorized to automate.
Writes are off by default. A write tool exists only after you install a reviewed contract. Each write is then previewed, needs explicit approval, is read back from the server, and is protected by a persistent duplicate-submission lock. Writes are never retried automatically, and the lock does not replace the upstream system's own idempotency guarantees.
They stay on your machine and are only sent to the app they belong to. A HAR carries your login cookies, so treat it as a credential and keep it out of version control. Profiles, sessions and audit logs are private local data. If you configure a model for exploration, page content from that context may be sent to that model service.
Only use Web2MCP on sites and accounts you are authorized to automate. Check the terms of service of the product you integrate; prefer an official API where one exists.
- When a site deploys anti-automation protection (CAPTCHAs, proof-of-work challenges, device binding), the right behavior is to detect it, stop, and tell you the site is not supported this way — not to bypass it.
- Capture files can contain credentials and business payloads. Profiles, sessions, diagnostics and audit logs are private local runtime data; never commit them (the shipped
.gitignorecovers the defaults). - If you configure a model, page content and business samples from the exploration context may be sent to that model service. Use a model environment you trust with that data.
- Writes are never retried automatically. On timeouts or ambiguous results the state is preserved and execution stops; the duplicate-submission lock does not replace upstream idempotency guarantees.
- Credentials expire. Re-capture and run
refresh-login/refresh-storage; a live identity probe must pass before credentials are updated. There is no generic automatic token renewal for arbitrary sites, and unknown signature schemes are never replayed blindly. - On Windows, credential files rely on user-profile ACLs rather than POSIX
0600permissions. - Not built in: site-specific signature algorithms, WebSocket protocols, file uploads, streaming responses. These need reviewed adapter extensions.
web2mcp/ executor, discovery, contracts, browser bridge, job orchestration
examples/ fictional local product, end-to-end demo, JSON pack samples
tests/ regression tests; no production accounts involved
docs/ integration guide and demo assets
model.example.json model config template without keys
Built something with Web2MCP? Share it in Show and tell.
MIT.