FormFill Broker
An isolated browser API: Chromium runs in a locked-down container and a small FastAPI service drives it over CDP, so an agent can fill web forms without ever holding the browser session itself. It also ships an MCP (stdio) server, so any MCP-capable client can call the same open / fill / verify / egress / OTP / upload primitives as tools. Field values are passed per request and are never stored by the broker:
docker build -t ff-browser . && bash scripts/slot_up.sh 0 && pip install -r requirements.txt && uvicorn app.broker:app --host 127.0.0.1 --port 8030
Broker listens on http://127.0.0.1:8030.
HTTP API
| Method | Path | Purpose |
|---|---|---|
| GET | /health |
Broker and CDP health |
| POST | /open |
Open a URL ({"url": "...", "slot"?: 0}) |
| GET | /snapshot |
List visible interactive elements with refs |
| POST | /click |
Click a snapshot ref ({"ref": "e3"}) |
| POST | /fill |
Fill by ref/label/selector, optional submit ref |
| POST | /verify |
Check text/url_contains, save screenshot evidence |
| POST | /otp |
Read a verification code from an IMAP inbox (read-only) |
| POST | /upload |
Decode base64 to a 0600 file under FF_UPLOADS, return sha256 |
| POST | /press, /type |
Send a key or type text into the page |
| POST | /egress |
Report browser public IP and geolocation |
| POST | /close |
Close page and browser context |
MCP server
mcp_server.py is a stdio Model Context Protocol server (JSON-RPC 2.0,
one JSON object per line) that wraps the HTTP API. It uses only the Python
standard library and writes logs to stderr only, so stdout stays clean.
Tools:
formfill_open{url}formfill_snapshot{}formfill_fill{fields: [{ref|label|selector, value}], submit?}formfill_click{ref}formfill_verify{text?, url_contains?}formfill_egress{}formfill_close{}formfill_health{}
The broker URL defaults to http://127.0.0.1:8030 and can be overridden with
FF_BROKER_URL. Requests time out after 60 seconds.
opencode MCP config
{"mcp": {"formfill": {"type": "local", "command": ["python3","/path/to/formfill-broker/mcp_server.py"], "enabled": true}}}
Run and verify
# broker must already be running on 127.0.0.1:8030
python3 -m pytest tests -q
bash scripts/mcp_smoke.sh
scripts/mcp_smoke.sh sends initialize, notifications/initialized,
tools/list, and a formfill_health call, then prints every response.
OTP retrieval
Codes are read from an IMAP inbox with BODY.PEEK[], so messages stay unread.
FF_MAIL_ACCOUNTS=./mail_accounts.json python3 -m app.otp --account demo --timeout 60
mail_accounts.json is not part of this repo; supply your own:
{"accounts": [{"id": "demo", "email": "demo@example.com",
"imap": {"host": "imap.example.com", "port": 993, "tls": "SSL"},
"app_password": "<app password>"}]}
Browser slots
bash scripts/slot_up.sh 0 # start ff-slot0, CDP on 127.0.0.1:9330
bash scripts/slot_down.sh 0 # guarded: needs FF_ALLOW_SLOT0=1
Configuration
| Variable | Default | Meaning |
|---|---|---|
FF_CDP |
http://127.0.0.1:9330 |
Chrome DevTools endpoint |
FF_EVIDENCE |
evidence |
Screenshot output directory |
FF_UPLOADS |
/tmp/ff_uploads |
Upload directory (0700, files 0600) |
FF_MAIL_ACCOUNTS |
mail_accounts.json |
IMAP accounts file |
FF_MAIL_ACCOUNT |
default |
Default account id for /otp |
FF_SLOTS |
0,1,2 |
Slots slot_up.sh may start |
FF_PROXY |
socks5://172.17.0.1:1080 |
Proxy passed to the container |
FF_EGRESS_HOST |
— | user@host for scripts/egress_up.sh |
Screenshots in evidence/ are runtime output and are git-ignored.
Deployment (systemd)
Three units make the stack survive reboots. Unit files live in
/etc/systemd/system/.
| Unit | Type | Role |
|---|---|---|
ffbroker.service |
simple, Restart=always |
uvicorn app.broker:app on 127.0.0.1:8030 |
ff-iptables.service |
oneshot, RemainAfterExit=yes, Before=docker.service |
re-adds the rule that lets containers reach the SOCKS5 egress on 172.17.0.1:1080 (idempotent iptables -C ... || iptables -I ...) |
ff-slot0.service |
oneshot, RemainAfterExit=yes, After=docker.service ff-iptables.service |
scripts/slot_up.sh 0, ExecStop=docker rm -f ff-slot0 |
Install / enable (once):
systemctl daemon-reload
systemctl enable ff-iptables.service ffbroker.service ff-slot0.service
systemctl start ff-iptables.service
systemctl start ff-slot0.service
systemctl start ffbroker.service
Prerequisite for egress (not a unit; the SSH tunnel is external):
FF_EGRESS_HOST=user@egress-host.example bash scripts/egress_up.sh
Verify:
systemctl is-enabled ff-iptables ffbroker ff-slot0 # enabled enabled enabled
systemctl is-active ff-iptables ffbroker ff-slot0 # active active active
iptables -C INPUT -i docker0 -s 172.17.0.0/16 -p tcp --dport 1080 -j ACCEPT && echo rule-ok
curl -s http://127.0.0.1:8030/health # {"ok":true,...}
curl -s http://127.0.0.1:9330/json/version | jq -r .Browser
Restart cycle (container is recreated by the unit, not by docker alone):
systemctl stop ff-slot0 && systemctl start ff-slot0
curl -s http://127.0.0.1:9330/json/version # 200 after ~2 s
Notes:
- The container runs with
--restart unless-stoppedand no--removeflag, so a docker daemon restart brings it back without losing the name. ff-slot0.serviceis idempotent: ifff-slot0is already running the script exits 0 and leaves it alone; usedocker rm -f ff-slot0(orsystemctl restart ff-slot0) to apply new flags.iptablesis persisted byff-iptables.service. A snapshot is also kept at/etc/iptables/rules.v4(iptables-save), butnetfilter-persistentis not installed, so that file is a reference/restore artifact only.- Broker environment overrides: drop
KEY=valuelines in/etc/ffbroker.env(loaded viaEnvironmentFile=-/etc/ffbroker.env).
License
MIT — see LICENSE.
Metadata
Release files for formfill-broker 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| formfill_broker-0.1.2.tar.gz | 26.9 kB | Without provenance | Details for formfill_broker-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| formfill_broker-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for formfill_broker-0.1.2-py3-none-any.whl |
Total release size: 47.7 kB
Release files / formfill_broker-0.1.2.tar.gz
| Download URL | formfill_broker-0.1.2.tar.gz |
|---|---|
| Size | 26.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92466febce73e44efa7bc98f4602d271709f6612dd93584495ee60df61610141
|
|
BLAKE2b-256 checksum How to use checksums |
ce5d1b8a6a25f09f1dd60f5164bbf5c0544f93b45251cb86f468cc2eb9642e7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / formfill_broker-0.1.2-py3-none-any.whl
| Download URL | formfill_broker-0.1.2-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f47ef25f80c4770173b49f625cff4640470d660f71e2e7238752bc6e596f596
|
|
BLAKE2b-256 checksum How to use checksums |
b0d1e6af18406211bc39e47eaaab3b21c85902c3559197f557ff94ecc23dbbdd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for formfill-broker 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.