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

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

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

Built distribution (wheel)

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

Total release size: 76.5 MB

Release files / lite_locator_mcp-0.1.1.tar.gz

Download URL lite_locator_mcp-0.1.1.tar.gz
Size 38.2 MB
Tags Source
SHA-256 checksum
How to use checksums
e2f905181eba1e4d8c33f67d6670a3cc8266d5c4dec4b30ced0ba736e48b98d8
BLAKE2b-256 checksum
How to use checksums
46e08bae824a7e3b3757d216d4746bc7544c8db636046f1ece8917efb469d946
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.1-py3-none-any.whl

Download URL lite_locator_mcp-0.1.1-py3-none-any.whl
Size 38.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a190a4add4b5a96f70e5c2a1f796bd711b0c66a1b420e4bb6a65c6a2a4b7eace
BLAKE2b-256 checksum
How to use checksums
063c7b8e5002697f0ae18bdbbe38f390a715aaf6e552a35bc5532ae6b607a454
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.1

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