MCP — Model Context Protocol
MCP (Model Context Protocol) is an open protocol that lets AI models use external tools through a standardized interface. Instead of an AI model being limited to generating text, MCP lets it call functions — read files, click buttons in a browser, run queries — via a consistent request/response contract.
In the Leadmetrics context, MCP is used in two ways:
- Development tooling — Claude Code’s Playwright MCP server is used to automate browser interactions during development, QA, and E2E testing.
- Platform integration (planned) — Leadmetrics can expose its own MCP server so external AI systems (like a client’s Claude-based assistant) can query campaign status, trigger content generation, or read insights by calling structured tools.
Playwright MCP (Development Use)
The Claude Code desktop app ships with a built-in MCP Playwright server. It lets Claude control a browser directly — navigate, click, fill forms, take screenshots, and read the DOM — without needing a Selenium wrapper or separate test runner.
How to use it
The Playwright MCP tools are available when using Claude Code with the MCP Playwright integration enabled. Tools include:
| Tool | What it does |
|---|---|
browser_navigate | Navigate to a URL |
browser_snapshot | Capture the current page’s accessible element tree |
browser_take_screenshot | Take a screenshot |
browser_click | Click an element by ref |
browser_fill_form | Fill a form with field values |
browser_type | Type text into a focused element |
browser_evaluate | Run arbitrary JavaScript in the page context |
browser_wait_for | Wait for a selector, URL, or time |
browser_network_requests | Inspect outgoing network requests |
Windows-specific guidance
On Windows, always use http://127.0.0.1:PORT rather than http://localhost:PORT. The browser sends Origin: http://127.0.0.1:3000 which differs from localhost — the Leadmetrics API CORS config accepts both.
Best practices
- Take a fresh
browser_snapshotafter every navigation — element refs go stale across page loads. - Use
browser_evaluatewithdocument.querySelectorAll+ text matching for robust element targeting rather than relying on snapshot refs. - For React-controlled inputs, use the
nativeInputValueSetterpattern viabrowser_evaluate— direct.value =assignment bypasses React’s synthetic events. - Keep open tabs to ≤ 2 to reduce crash risk.
- Avoid
window.scrollToviabrowser_evaluate— it can crash the browser session. Navigate directly to the target URL instead.
See Known Issues for a full list of Windows-specific bugs and workarounds.
Leadmetrics MCP Server (Planned)
A future apps/servers/mcp service will expose Leadmetrics capabilities as MCP tools, allowing external AI assistants to interact with the platform programmatically.
Proposed tools:
| Tool | Description |
|---|---|
get_tenant_overview | Returns campaign summary, deliverable counts, pending approvals |
list_activities | Lists activities with status filter |
get_activity | Returns full detail for one activity |
approve_content | Approves a content activity (requires auth) |
generate_blog | Triggers the blog writer agent for a given content brief |
get_insights | Returns latest channel insights for a tenant |
search_knowledge_base | Searches the tenant’s RAG knowledge base |
Authentication will use the same JWT system as the existing API. Each MCP client authenticates with a tenant-scoped API key.
Related Docs
- Known MCP Issues — Windows Playwright MCP bugs and workarounds
- Agent Chat — The in-app AI chat that uses a similar tool-calling pattern
- Adapters — How Leadmetrics agents call external LLM runtimes