Skip to main content

lite-locator-mcp

A semantic element finder for Playwright test agents: give it a page and a test step, get back a short list of candidate elements (with Playwright locators or MCP refs) to put in the LLM prompt instead of the whole accessibility tree. Use it as a Python library inside your own agents (LangChain/LangGraph tools included), or as an MCP proxy.

As a library (your own agents)

from lite_locator import Locator
loc = Locator()                                    # loads the bundled models once
hits = loc.find(page, "Enter standard_user in the username field")     # Playwright sync Page
hits = await loc.afind(page, step)                 # Playwright async Page
hits = loc.find(snapshot_text, step)               # Playwright MCP snapshot text you already have
hits[0]["locator"]      # page.locator('[data-test="username"]'), checked on the live page (or hits[0]["ref"])
hits.prompt             # short text for the LLM prompt
hits.tokens, hits.full_tokens, hits.fallback_full_tree   # True: send the LLM the full tree for this step

LangChain / LangGraph, with Playwright MCP through langchain-mcp-adapters (any mcp version):

from lite_locator.langchain import with_lite_locator, page_tool, LOCATOR_HINT
tools = with_lite_locator(await load_mcp_tools(session))   # adds browser_find_element, keeps every tool
tools = [page_tool(page)]                                   # or: a tool over a Playwright Python page

Controls built only from JavaScript (a plain <div>English</div> with a click handler, no button role) are still found: on a Playwright page the library checks click listeners through Chromium's DevTools protocol and marks such text as clickable; on an MCP snapshot, short text without its own ref is offered through its container's ref.

The base install has no MCP dependency, so it sits next to an existing mcp 1.x without changing it.

As an MCP proxy

The proxy runs Playwright MCP as a child process and exposes all of its tools unchanged, plus browser_find_element(step). That tool takes the accessibility snapshot inside the proxy, ranks the elements against the test step with small local models, and returns only a shortlist with refs. The LLM acts on a ref (browser_click target=e990) and calls browser_snapshot only when nothing in the shortlist fits.

Measured on the hard held-out test set (2,875 steps, 38 sites never seen in training), the correct element was in a shortlist of about 150–500 tokens 82–90% of the time. The full page averaged 12,229 tokens. Playwright MCP runs exactly as configured; --lean adds --snapshot-mode none, so clicks and typing no longer return a full snapshot each time.

Install

Needs Python 3.10+ and Node 18+ (for Playwright MCP itself).

pip install lite-locator-mcp          # library
pip install "lite-locator-mcp[mcp]"   # MCP proxy (needs mcp>=2.3: use its own venv if you have an older mcp)
npx playwright install chromium                           # once, if no browser is installed

Use in an MCP client

.mcp.json (Claude Code, Cursor, etc.):

{"mcpServers": {"playwright": {"command": "lite-locator-mcp", "args": ["--", "--headless", "--isolated"]}}}

Arguments after -- are passed to Playwright MCP. --lam sets the cut policy (0.002, 0.005, 0.01 or 0.02; a higher value shows fewer candidates; the default is 0.01).

Environment variables:

  • PLAYWRIGHT_MCP overrides the child command (default npx -y @playwright/mcp@0.0.83).
  • ELEM_RANK_LITE points to a different model bundle.

Build the wheel (from the repo)

.venv/bin/python -m elem_rank.export_onnx --out elem_rank/models-lite   # ONNX int8 models, 57 MB
.venv/bin/python -m build      # sdist + wheel in dist/

Credits and licences

Metadata

Release files for lite-locator-mcp 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lite-locator-mcp 0.1.2
File Size Uploaded Provenance Actions
lite_locator_mcp-0.1.2.tar.gz 38.2 MB Without provenance Details for lite_locator_mcp-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lite-locator-mcp 0.1.2
File Interpreter ABI Platform Actions
lite_locator_mcp-0.1.2-py3-none-any.whl Python 3 none any Details for lite_locator_mcp-0.1.2-py3-none-any.whl

Total release size: 76.5 MB

Release files / lite_locator_mcp-0.1.2.tar.gz

Download URL lite_locator_mcp-0.1.2.tar.gz
Size 38.2 MB
Tags Source
SHA-256 checksum
How to use checksums
2069428436169861d385c967f088d74fa1fab46e5b7477549af199b282ab5b6a
BLAKE2b-256 checksum
How to use checksums
94b01fb2a371be49a4c46d20270d3af7444a306128d262db1b6d77997a8434ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / lite_locator_mcp-0.1.2-py3-none-any.whl

Download URL lite_locator_mcp-0.1.2-py3-none-any.whl
Size 38.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b3062b057bdd4b100c57e6f4451dcd57399c31a764380023325b96c9c92692d9
BLAKE2b-256 checksum
How to use checksums
15cf2e2457fcb88a3e67a81766a2591c7743da9ea164297fe1506605e5431cca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for lite-locator-mcp 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page