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

Actions return what changed, not a new snapshot (snapshots no longer pile up in the history):

from lite_locator import act
act(page, hits[0], "fill", "standard_user")   # 'Same page. Changes: ~ textbox "Username" -> ...: standard_user'
act(page, loc.find(page, "login button")[0], "click")   # 'Navigated to a new page. Page: ... Has: 20 buttons, ...'
# or "No visible change on the page (the action may not have worked)."

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

from lite_locator.langchain import with_lite_locator, page_tool, snapshot_hook, 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
agent = create_react_agent(llm, tools, pre_model_hook=snapshot_hook)  # drops superseded full snapshots

With with_lite_locator, browser_click / browser_type / browser_navigate … return the change (navigation summary, added/removed/changed elements, or no change) instead of a full snapshot; diffs=False keeps them unchanged. Measured on a 7-step SauceDemo flow: 31,145 → 8,272 tokens re-read across the agent's LLM calls (−73%).

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.3

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.3
File Size Uploaded Provenance Actions
lite_locator_mcp-0.1.3.tar.gz 38.2 MB Without provenance Details for lite_locator_mcp-0.1.3.tar.gz

Built distribution (wheel)

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

Total release size: 76.5 MB

Release files / lite_locator_mcp-0.1.3.tar.gz

Download URL lite_locator_mcp-0.1.3.tar.gz
Size 38.2 MB
Tags Source
SHA-256 checksum
How to use checksums
4e9c702d0edabd40d4fb8cd8a302bc4671b0332cb2eabcf287e6d89f37b6fc74
BLAKE2b-256 checksum
How to use checksums
9d7c7717a9be8d6e952de9228013f9311765774002211e58efd5ac29749f8b0d
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.3-py3-none-any.whl

Download URL lite_locator_mcp-0.1.3-py3-none-any.whl
Size 38.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
37ee14f58186eb8fcf32d895d1e2c139ec6ab80f71f4ebdbc9bacadc440552d0
BLAKE2b-256 checksum
How to use checksums
ab96fdbfc464aeb0cbab2d5642eb31e719fcbc61885212f1743dc6d0ee4f714d
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.3

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