Lens MCP
Provides browser-grade web access by rendering pages to markdown, taking screenshots, and fetching images using headless Chromium/Firefox (Playwright) and httpx.
README
Lens MCP
A FastMCP server that gives an MCP client browser-grade web access: render pages to markdown, screenshot them, and fetch images — backed by headless Chromium/Firefox (Playwright) and httpx.
Tools
| Tool | Signature | Returns | Description |
|---|---|---|---|
fetch_page |
url, wait_for_selector=None, timeout_ms=15000 |
markdown str |
Renders the page in headless Chromium, falls back to Firefox on HTTP/2 or connection errors, and converts HTML to markdown with links and images preserved. |
screenshot_page |
url, full_page=False, timeout_ms=15000 |
PNG Image |
Screenshots the page in a 1280×800 viewport. Same Chromium→Firefox fallback. Set full_page=True for the full scrollable page. |
fetch_image |
image_url, referer=None |
Image |
Downloads an image over HTTP with a desktop Chrome User-Agent and optional Referer. Format is inferred from Content-Type. |
Requirements
- Python
>=3.14 - uv
- Playwright browsers (
uv run playwright install chromium firefox)
Configuration
| Variable | Default | Description |
|---|---|---|
LENS_PORT |
8788 |
HTTP port the server listens on. |
LENS_REDIRECT_URL |
(unset) | If set, GET / and any non-MCP URL redirects (302) here. Returns 404 when unset. |
LENS_DB_PATH |
lens.db |
Path to the SQLite request log database. |
Running locally
uv sync
uv run playwright install chromium firefox
uv run python app/server.py
The server listens on http://0.0.0.0:8788.
Running with Docker
docker compose up --build
The image is based on mcr.microsoft.com/playwright/python with Chromium and Firefox preinstalled.
Endpoints
| Path | Description |
|---|---|
/mcp |
MCP HTTP transport endpoint |
/icon.svg |
Server icon |
/get |
302 redirect to LENS_REDIRECT_URL, or 404 |
Request logging
Every tool call is logged to a SQLite database (lens.db by default) via a background queue writer. The requests table stores tool name, arguments, status (ok/error), response preview, error message, and duration in ms.
Resilient navigation
fetch_page and screenshot_page use a two-level fallback:
- Firefox fallback — if Chromium raises
ERR_HTTP2_PROTOCOL_ERROR,ERR_HTTP2, orERR_CONNECTION_RESET, the request is retried once with Firefox. - networkidle timeout — if
networkidletimes out (analytics/websockets keeping the page "not idle"), the current page state is used rather than failing the call. - Clean errors — unhandled navigation failures surface as a single-line
ToolErrorwith thenet::ERR_*code, not Playwright's verbose call log.
Graceful shutdown
The server handles SIGINT (Ctrl-C) and SIGTERM (docker stop) — in-flight requests drain before exit, and the request log writer flushes its queue cleanly.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.