Skip to main content
Glama

LocatorLabs MCP Server

🎯 Intelligent Playwright locator generation powered by AI

An MCP (Model Context Protocol) server that provides smart locator generation for Playwright test automation.

Works directly in VS Code (with GitHub Copilot), Cursor, Windsurf, Cline, and Claude Desktop. No extra apps needed - just your favorite IDE!

npm version npm downloads

⚡ Quick Install

VS Code Cursor

VS Code (v1.99+) - Copy & run in terminal:

code --add-mcp '{"name":"locatorlabs","command":"npx","args":["-y","locatorlabs-mcp"]}'

Cursor:

cursor --add-mcp '{"name":"locatorlabs","command":"npx","args":["-y","locatorlabs-mcp"]}'

Windows PowerShell:

code --add-mcp '{\"name\":\"locatorlabs\",\"command\":\"npx\",\"args\":[\"-y\",\"locatorlabs-mcp\"]}'

✨ Features

Feature

Description

🎯 Get Locators

Get all possible locators for any element (Playwright + Selenium formats)

📊 Analyze Page

Scan pages and identify all interactive elements

🏗️ Generate POM

Auto-generate Page Object classes for Playwright & Selenium

Run Tests

Execute Playwright tests and get pass/fail results

📝 Generate Tests

Create executable test scripts

Related MCP server: RunAutomation MCP Server

🔧 Supported Frameworks

Framework

Locators

Page Object Model

Playwright

getByRole, getByTestId, etc.

✅ TypeScript, JavaScript, Python

Selenium

By.id, By.xpath, By.cssSelector

✅ Java, Python, C#

🚀 Quick Start

For VS Code (v1.99+ with GitHub Copilot)

One-Line Install (Mac/Linux):

code --add-mcp '{"name":"locatorlabs","command":"npx","args":["-y","locatorlabs-mcp"]}'

One-Line Install (Windows PowerShell):

code --add-mcp '{\"name\":\"locatorlabs\",\"command\":\"npx\",\"args\":[\"-y\",\"locatorlabs-mcp\"]}'

Or Manual Setup:

  1. Open Command Palette (Cmd+Shift+P / Ctrl+Shift+P)

  2. Type: MCP: Add Server

  3. Select: Command (stdio)

  4. Command: npx

  5. Args: -y locatorlabs-mcp

Using with GitHub Copilot:

  1. Enable Agent Mode: Settings → Search chat.agent.enabled → Enable

  2. Open Copilot Chat (Ctrl+Cmd+I / Ctrl+Alt+I)

  3. Switch to Agent mode (dropdown at top)

  4. Chat: "Get locators for login button on https://saucedemo.com"

For Claude Desktop

Step 1: Open config file

  • Mac: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Step 2: Add this configuration:

{
  "mcpServers": {
    "locatorlabs": {
      "command": "npx",
      "args": ["-y", "locatorlabs-mcp"]
    }
  }
}

Step 3: Restart Claude Desktop

For Cursor IDE

One-Line Install:

cursor --add-mcp '{"name":"locatorlabs","command":"npx","args":["-y","locatorlabs-mcp"]}'

Or Manual: Go to Cursor Settings → MCP → Add new MCP Server

  • Name: locatorlabs

  • Command: npx -y locatorlabs-mcp

For VS Code + Cline Extension

Add to Cline MCP settings:

{
  "mcpServers": {
    "locatorlabs": {
      "command": "npx",
      "args": ["-y", "locatorlabs-mcp"]
    }
  }
}

📖 Usage Examples

Just chat naturally:

Get Locators for an Element

"Get me all locators for the login button on https://www.saucedemo.com"

Response:

Type

Locator

Reliability

testId

getByTestId('login-button')

98%

role

getByRole('button', { name: 'Login' })

95%

id

locator('#login-button')

90%

Analyze Entire Page

"Analyze all form elements on https://www.saucedemo.com"

Generate Page Object Model

Playwright:

"Generate a TypeScript Page Object for https://www.saucedemo.com and call it LoginPage"

Selenium:

"Generate a Java Selenium Page Object for https://www.saucedemo.com and call it LoginPage"

"Generate a C# Selenium Page Object for https://www.saucedemo.com called LoginPage"

"Generate a Python Selenium POM for https://www.saucedemo.com named LoginPage"

Run a Test

"Run a test that logs into saucedemo.com with standard_user and secret_sauce, then verify Products page appears"

Response:

✅ Test PASSED (3.2s)
- Navigate to login page ✅
- Enter username ✅
- Enter password ✅
- Click login ✅
- Verify Products visible ✅

Generate Test Script

"Generate a Python test script for the saucedemo login flow"

🛠️ Available Tools

Tool

Description

get_locators

Get all possible locators (Playwright + Selenium formats)

analyze_page

List all interactive elements on a page

generate_page_object

Create POM class (Playwright: TS/JS/Python, Selenium: Java/Python/C#)

run_test

Execute tests in real browser, get pass/fail

generate_test

Generate executable test scripts

📦 Supported Languages for Page Objects

Language

Framework

Example Output

typescript

Playwright

page.getByRole('button')

javascript

Playwright

page.getByRole('button')

python

Playwright

page.get_by_role('button')

java-selenium

Selenium

@FindBy(id = "btn")

python-selenium

Selenium

By.ID, "btn"

csharp-selenium

Selenium

[FindsBy(How = How.Id)]

🎯 Supported Test Actions

Action

Description

navigate

Go to URL

click

Click element

fill

Enter text

clear

Clear input field

check / uncheck

Toggle checkbox

select

Select dropdown option

hover

Mouse hover

press

Keyboard key press

assert_visible

Verify element visible

assert_hidden

Verify element hidden

assert_text

Verify text content

assert_value

Verify input value

assert_url

Verify page URL

assert_title

Verify page title

wait

Wait for time

wait_for_element

Wait for element

screenshot

Capture screenshot

🏆 Locator Priority

LocatorLabs ranks locators by reliability:

  1. data-testid (98%) - Best, explicitly for testing

  2. Role + Name (95%) - Playwright recommended

  3. Label (90%) - Accessible

  4. ID (90%) - Stable if meaningful

  5. Placeholder (85%) - Good for inputs

  6. Text (75%) - May change

  7. CSS (60%) - Can be brittle

  8. XPath (40%) - Avoid unless necessary

🔄 LocatorLabs vs Playwright MCP

Feature

Playwright MCP

LocatorLabs MCP

Get all locators for element

Locator reliability ranking

Selenium locator format

Generate Playwright POM

Generate Selenium POM (Java/C#/Python)

Run tests with pass/fail

Browser automation

Device emulation

They work great together! Use Playwright MCP for navigation/scraping, LocatorLabs MCP for locators/POMs/tests.

📋 Requirements

  • Node.js 18+

  • Playwright browsers (auto-installed on first run)

🔧 Troubleshooting

Playwright browsers not installed

npx playwright install chromium

Permission issues on Mac

chmod +x ~/.npm/_npx/*/node_modules/.bin/locatorlabs-mcp

View logs (Claude Desktop)

tail -f ~/Library/Logs/Claude/mcp*.log

Auto-approve tools in VS Code

Add to settings.json:

{
  "chat.tools.autoApprove": true
}

🤝 Contributing

Contributions welcome! Please open an issue or PR on GitHub.

📺 Author

Naveen AutomationLabs

📄 License

MIT


Available Tools

5 tools
analyze_pageB

Analyze an entire webpage and return all interactive elements with their best locators. Use this to understand page structure or get all elements at once.

ParametersJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL of the webpage to analyze
elementTypesNoOptional filter by element types: 'button', 'input', 'link', 'select', 'textarea', 'checkbox', 'radio'. Leave empty for all.

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool returns 'all interactive elements with their best locators,' which gives some insight into output behavior. However, it doesn't cover critical aspects like whether this is a read-only operation, potential performance impacts (e.g., loading time for large pages), error handling, or authentication needs. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured with two sentences: the first states the core functionality, and the second provides usage context. Every sentence adds value without redundancy, making it easy to scan and understand quickly. It's appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and usage but lacks details on behavioral traits, output format, or error scenarios. Without annotations or an output schema, the description should do more to compensate, such as explaining what 'best locators' means or potential limitations. It meets a baseline but has clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('url' and 'elementTypes') with clear descriptions. The description doesn't add any meaningful semantic details beyond what the schema provides, such as examples of URL formats or explanations of 'best locators' in context. Baseline 3 is appropriate when the schema handles parameter documentation effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Analyze an entire webpage and return all interactive elements with their best locators.' It specifies the verb (analyze), resource (webpage), and output (interactive elements with locators). However, it doesn't explicitly differentiate from sibling tools like 'get_locators' or 'generate_page_object,' which likely have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides some usage context: 'Use this to understand page structure or get all elements at once.' This implies when to use it (for comprehensive analysis) but doesn't explicitly state when not to use it or name alternatives among sibling tools. It offers basic guidance but lacks detailed comparisons or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

generate_page_objectC

Generate a complete Page Object Model class for a webpage. Supports Playwright (TypeScript/JavaScript/Python) and Selenium (Java/Python/C#).

ParametersJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL of the webpage
classNameYesName for the Page Object class (e.g., 'LoginPage', 'CheckoutPage')
languageNoProgramming language: typescript, javascript, python (Playwright) OR java-selenium, python-selenium, csharp-selenium (Selenium)

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'generates' a class, implying a creation or write operation, but doesn't disclose any behavioral traits like whether it requires internet access, how it handles invalid URLs, if it has rate limits, or what the output format is (e.g., code string, file). For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, stating the core purpose in the first sentence and adding framework support in the second. Both sentences earn their place by clarifying scope, and there's no redundant information. However, it could be slightly more structured by explicitly separating the purpose from usage notes, but it remains efficient overall.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of generating code (a Page Object Model class) and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., a code snippet, a file download), any error conditions, or behavioral details like execution time or dependencies. For a tool with no structured output and no annotations, this leaves the agent with insufficient context to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting all three parameters (url, className, language) with descriptions and an enum for language. The description adds minimal value beyond the schema, only implying that the tool uses the URL to generate the class and mentioning the supported frameworks, which aligns with the language parameter's enum. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't provide additional semantic context like examples or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Generate a complete Page Object Model class for a webpage.' It specifies the verb ('generate') and resource ('Page Object Model class'), and mentions supported frameworks (Playwright and Selenium). However, it doesn't explicitly differentiate from sibling tools like 'get_locators' or 'generate_test', which might also involve page elements or test generation, leaving some ambiguity about its unique role.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions supported frameworks but doesn't specify scenarios where generating a Page Object Model is preferred over using sibling tools like 'analyze_page' or 'generate_test'. There's no mention of prerequisites, such as needing a valid URL or when this tool might be inappropriate, leaving the agent without context for selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

generate_testB

Generate a Playwright test script from test steps. Returns executable code that can be saved and run independently.

ParametersJSON Schema
NameRequiredDescriptionDefault
testNameYesName of the test
stepsYesArray of test steps
languageNoProgramming language for the test script (default: typescript)

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the tool returns 'executable code,' which implies a read-only generation function, but doesn't disclose behavioral traits like whether it requires specific inputs, how errors are handled, or if there are rate limits. The description is minimal and lacks crucial operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded and concise with two sentences that directly state the purpose and output. Every sentence earns its place by explaining the tool's function and result, though it could be slightly more structured by explicitly mentioning input requirements.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a tool with 3 parameters, the description is incomplete. It doesn't explain return values, error handling, or prerequisites, leaving significant gaps for an AI agent to understand how to use this tool effectively in context with its siblings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents parameters like testName, steps, and language. The description adds no additional meaning beyond implying that steps are used to generate code, which is already clear from the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Generate a Playwright test script from test steps') and the resource ('executable code'), distinguishing it from sibling tools like analyze_page or run_test by focusing on code generation rather than analysis or execution.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for creating test scripts from steps, but provides no explicit guidance on when to use this tool versus alternatives like generate_page_object or run_test. It mentions the output can be 'saved and run independently,' which hints at a preparatory role, but lacks clear when/when-not instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_locatorsB

Get all possible Playwright locators for a specific element on a webpage. Returns ranked locators with reliability scores. Use this when user asks for locators for a specific element.

ParametersJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL of the webpage to analyze
elementDescriptionYesDescription of the element (e.g., 'login button', 'username input', 'submit form', 'email field')

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that the tool returns 'ranked locators with reliability scores,' which adds some behavioral context beyond basic functionality. However, it doesn't disclose important traits such as whether this requires network access, potential rate limits, error handling (e.g., if the element isn't found), or performance implications. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, with two sentences that directly state the purpose and usage guidelines. Every sentence earns its place by providing essential information. However, it could be slightly more structured by separating purpose and usage into distinct parts, but it's still efficient and clear.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (involves web analysis and ranking), lack of annotations, and no output schema, the description is moderately complete. It covers the core purpose and usage but misses details on behavioral traits (e.g., how reliability scores are calculated, what 'ranked' means) and output format specifics. Without annotations or output schema, more context on behavior and results would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with clear descriptions for both parameters ('url' and 'elementDescription'). The description doesn't add any additional meaning beyond what the schema provides (e.g., it doesn't explain how 'elementDescription' is interpreted or provide examples beyond those in the schema). According to the rules, with high schema coverage (>80%), the baseline is 3 even with no param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get all possible Playwright locators for a specific element on a webpage. Returns ranked locators with reliability scores.' It specifies the verb ('Get'), resource ('Playwright locators'), and output format ('ranked locators with reliability scores'). However, it doesn't explicitly differentiate from sibling tools like 'analyze_page' or 'generate_page_object', which might also involve element analysis.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear usage context: 'Use this when user asks for locators for a specific element.' This gives a specific trigger for when to use the tool. However, it doesn't mention when not to use it or explicitly compare it to alternatives like 'analyze_page' (which might provide broader page analysis) or 'generate_page_object' (which might generate code).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

run_testB

Execute a Playwright test with given steps and return pass/fail results. Use this to actually run and verify tests in a real browser.

ParametersJSON Schema
NameRequiredDescriptionDefault
testNameYesName of the test
stepsYesArray of test steps to execute
optionsNoTest execution options

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only partially discloses behavioral traits. It mentions execution in a real browser and pass/fail results, but doesn't cover important aspects like error handling, performance characteristics, resource requirements, or side effects. The description is insufficient for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two clear sentences. The first sentence states the core functionality, and the second provides context about real browser execution. Both sentences earn their place, though some behavioral context could be added for better completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex test execution tool with 3 parameters, nested objects, no output schema, and no annotations, the description is incomplete. It doesn't explain what the return values look like (beyond 'pass/fail results'), error conditions, execution environment requirements, or important behavioral constraints that would help an agent use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the baseline is 3. The description adds minimal value beyond the schema by mentioning 'given steps' and 'pass/fail results', but doesn't provide additional context about parameter usage, relationships, or best practices beyond what's already documented in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('execute', 'run', 'verify') and resources ('Playwright test', 'real browser'). It distinguishes from siblings by focusing on actual test execution rather than analysis, generation, or locator retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context ('to actually run and verify tests in a real browser') but doesn't explicitly state when to use this versus alternatives like generate_test or analyze_page. It provides general purpose but lacks specific guidance on tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv1.0.0
    • First observedanalyze_page
    • First observedgenerate_page_object
    • First observedgenerate_test
    • First observedget_locators
    • First observedrun_test

TDQS

A3.6/5.0

Scored across 5 tools

Disambiguation5/5

Each tool has a distinct, non-overlapping purpose: analyze_page for page-wide element analysis, generate_page_object for POM generation, generate_test for test script creation, get_locators for element-specific locator retrieval, and run_test for test execution. The descriptions clearly differentiate their scopes (e.g., get_locators is for specific elements vs. analyze_page for entire pages), eliminating ambiguity.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern with snake_case (e.g., analyze_page, generate_page_object, run_test). The verbs are action-oriented and descriptive (analyze, generate, get, run), creating a predictable and readable naming convention throughout the set.

Tool Count5/5

With 5 tools, the server is well-scoped for its purpose of web automation and testing support. Each tool serves a unique function in the workflow (analysis, POM generation, test creation, locator retrieval, test execution), and none feel redundant or missing, making the count appropriate for the domain.

Completeness4/5

The toolset covers core web automation workflows comprehensively: analysis, POM generation, test creation, locator retrieval, and test execution. A minor gap exists in lacking direct element interaction tools (e.g., click_element or fill_form), but agents can work around this by using generated tests or locators, and the overall surface supports end-to-end testing tasks effectively.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers