MCP tools
The Lightpanda MCP server exposes these tools and resources, started with lightpanda mcp. See how to use MCP for practical documentation.
By default the server lists all of them. Start it with --tools to expose only the ones you name.
Each browser tool below links to its full description and arguments in the browser tools reference; the MCP server, the agent and scripts share the same tools. The Hints column carries the tool’s MCP annotations, and page state marks the tools that return structuredContent.
Calling a tool
Every call goes through the MCP tools/call method, with name and arguments populated from the tools below.
{"jsonrpc":"2.0","id":2,"method":"tools/call",
"params":{"name":"fill","arguments":{"selector":"#search","value":"lightpanda"}}}{"result":{"content":[{"type":"text","text":"Filled element (selector: #search) with \"lightpanda\". Page url: https://example.com, HTTP 200 OK, title: Example Domain"}],
"structuredContent":{"url":"https://example.com","httpStatus":200,"title":"Example Domain"},"isError":false}}Tool results
Page state
The tools marked page state return structuredContent, declared by each tool’s outputSchema in tools/list, with these fields:
url: the page URL, always present.httpStatus: the HTTP status, absent before any response arrives.title: the page title.
Their text also ends with the page state. goto ends with Navigated. HTTP <status>., and the tools that act on the page end with:
Page url: <url>, HTTP <status>, title: <title>A 4xx or 5xx status means the page is an error page, not the content. For how goto reports a failed navigation or a timeout, see Known behaviors.
Page notes
When a tool navigates, its text can start with notes on what the page lacks:
- WebGL:
The page asked for WebGL, which Lightpanda does not provide: anything it renders that way is missing. - Iframes:
<n> iframe(s) were not loaded: subframe loading is off. - Refused requests: some of the page’s own requests were refused with HTTP 403/429 or blocked by a bot challenge.
An error page or a bot challenge page starts with:
- 4xx or 5xx page:
HTTP <status>: this is likely an error or rate-limit page, not the requested content. - Bot challenge page:
Blocked by a <vendor> bot challenge (HTTP <status>): this is not the requested content.
Any tool’s text can also start with the WebMCP tools the page registers, when that set changed since the last call:
The page registers WebMCP tools; callPageTool runs one:followed by their JSON.The page no longer registers WebMCP tools.
Navigation and search
These tools bring a page into the browser, or save a URL to a file.
| Tool | Title | Hints |
|---|---|---|
goto | Open a URL and keep the page in memory | idempotent, open-world, page state |
search | Web search, results as markdown | idempotent, open-world |
download | Fetch a URL with the session’s cookies into a file | destructive, idempotent, open-world |
Reading the page
These tools read the loaded page without modifying it.
| Tool | Title | Hints |
|---|---|---|
markdown | Render the page or a subtree as markdown | idempotent, open-world |
html | Raw HTML of the page or a node | idempotent, open-world |
screenshot | Screenshot of the page or a node | destructive, idempotent, open-world |
links | List all links on the page | idempotent, open-world |
tree | Semantic DOM tree of the page | idempotent, open-world |
nodeDetails | Inspect a node by backendNodeId | read-only, idempotent |
interactiveElements | List interactive elements on the page | idempotent, open-world |
structuredData | Extract JSON-LD / microdata / OpenGraph data | idempotent, open-world |
detectForms | List forms and their fields | idempotent, open-world |
findElement | Find elements by role or name | read-only, idempotent |
Data extraction and scripting
These tools return structured results from the loaded page.
| Tool | Title | Hints |
|---|---|---|
evaluate | Run JavaScript in the page | destructive, open-world |
extract | Extract structured data via a CSS-selector schema | read-only, idempotent |
classify | Classify page state using semantic questions or presets | read-only, open-world |
Interacting with the page
These tools dispatch real DOM events on the page.
| Tool | Title | Hints |
|---|---|---|
click | Click an element | destructive, open-world, page state |
fill | Type text into an input | idempotent, page state |
scroll | Scroll the page or an element | page state |
hover | Hover over an element | idempotent, page state |
press | Press a keyboard key | destructive, open-world, page state |
selectOption | Select an option in a dropdown | idempotent, page state |
setChecked | Check or uncheck a box | idempotent, page state |
acceptCookies | Dismiss a cookie consent banner | destructive, open-world |
login | Sign in, picking the fields with Jev | destructive, open-world |
Waiting
These tools block until the page reaches a condition.
| Tool | Title | Hints |
|---|---|---|
waitForSelector | Wait for an element to appear | idempotent |
waitForScript | Wait until a JS expression is truthy | idempotent |
waitForState | Wait for the page to reach a load state | idempotent |
State and debugging
These tools inspect browser state outside the DOM.
| Tool | Title | Hints |
|---|---|---|
consoleLogs | Read buffered console messages | read-only |
getUrl | Show the current page URL | read-only, idempotent |
getCookies | Show stored cookies | read-only, idempotent |
getEnv | Read or list LP_* env vars | read-only, idempotent |
popups | List windows the page opened, or switch to one | idempotent |
Page tools (WebMCP)
These tools list and call the tools a page registers for agents through WebMCP.
| Tool | Title | Hints |
|---|---|---|
pageTools | List the page’s WebMCP tools | read-only, idempotent |
callPageTool | Call one of the page’s WebMCP tools | destructive, open-world |
MCP-only tools
These tools exist only in the MCP server, not in the agent or in scripts. Over the HTTP transport, every tool call runs in the session the Mcp-Session-Id header names, falling back to the always-present default session; the session_* tools create, list and close those sessions.
save
Save the session as an agent script. Save the session as a reusable Lightpanda agent script. You hold the conversation, so synthesize the script yourself — const page = new Page(); await page.goto(url); then call the builtins you used as tools (extract, click, fill, …) as methods on page with the same object arguments. Keep $LP_* placeholders; never inline a resolved secret.
Distill this session into ONE Lightpanda agent script (.js) that, run later on its own, redoes what the user set out to accomplish. You are reproducing the user’s goal, not replaying the transcript:
- Infer the goal from the whole conversation, including corrections — the user’s final intent wins over their first phrasing.
- Keep only the steps a clean re-run needs, in the order that worked. Drop failed attempts, retries, dead ends, and exploratory reads (tree/markdown/extract probes that only informed your next move).
- Reasoning you did between tool calls — comparing, filtering, picking, aggregating across pages — becomes plain top-level JavaScript, so the script reaches the result without you.
- Read pages with page.extract(schema) —
const page = new Page(); await page.goto(url); page.extract({...}). CSS selectors lift text and attributes as strings, and every trim/split/regex/parse/merge on those strings is top-level JavaScript. Do NOT write a page.evaluate(…) that querySelects the page and massages the result — that is page.extract + top-level JS. page.evaluate is ONLY for what must execute inside the page and no builtin can do. Top-level variables also persist across navigation; everything in the page context is wiped. Stay faithful to the calls that worked: same arguments and options each one actually used. Do NOT add atimeout(or any option) the session didn’t use. Never round-trip a result throughlp.*, and never append no-op page.extract(…) probes orpage.evaluate("return lp....")tails to surface output. Annotate the script with short//intent comments so a later reader grasps it at a glance: one comment above each logical block (navigate, extract a list, fan out to detail pages, aggregate, return) stating what that block accomplishes toward the goal — NOT restating the API call. One comment per step, not per line; skip self-evident lines. Output the JavaScript source alone, with no markdown fences or prose around it.
Script rules:
Pageis the only global.new Page()makes a page;await page.goto(url)navigates it (async — alwaysawait). Every other builtin is a synchronous method on that page:const data = page.extract({...}), neverawait page.extract. The file runs as an async script, so top-levelawaitis allowed.- Read pages with page.extract(schema); all processing of the returned strings (trim, split, parse, merge, loops, cross-page aggregation) is plain top-level JavaScript in the script context. page.evaluate(…) is ONLY for JS that must run inside the page and no builtin covers — never a querySelector-and-parse block. It cannot see script variables (interpolate values into its string), and page state is wiped by every navigation while script variables persist.
return <value>is the script’s output, printed automatically (objects/arrays as JSON). End withreturn page.extract({...});orreturn results;— a bare trailing expression is not printed, and neither is console.log or JSON.stringify.- Modern, readable JS:
const/let,for (const x of xs), template literals, destructuring, 2-space indent.
| Argument | Type | Required | Description |
|---|---|---|---|
path | string | yes | Relative path (no ’..’ segments) to write the script to. Created or overwritten. The response reports the absolute location. |
script | string | yes | The JavaScript agent script to write. Synthesize it per this tool’s description. |
Hints: destructive, idempotent
run
Run an agent script. Run a Lightpanda agent script in this session, as lightpanda run does, and return its console output followed by the value it returns. Pass the source as script, or the path of a file save wrote. The script drives pages through const page = new Page(); await page.goto(url); and the builtins as methods on page; $LP_* placeholders are resolved. To read several URLs, make one new Page() per URL and await Promise.all(pages.map((p, i) => p.goto(urls[i]))) so they load in parallel, then read each with page.extract or page.evaluate. Pages the script opens are closed when it ends; cookies and storage stay in the session, so a login carries over to the next call. Script variables do not carry over. A thrown error, a failed step or the timeout ends the script and is reported as an error after the output so far.
| Argument | Type | Required | Description |
|---|---|---|---|
script | string | no | The agent script source, as save writes it or lightpanda run takes it. Pass this or path. |
path | string | no | A script file to run instead of script, such as one save wrote. Relative to the server’s working directory. |
timeout | integer | no | Optional. Milliseconds before the script is stopped and reported as an error with its output so far. At least 1; defaults to 60000. |
Hints: destructive, open-world
session_new
Create an isolated browser session. Create a new isolated browser session (its own page, cookies and memory) and return its id. Use it to give a separate agent its own browsing context, or to obtain an id to share. Pass that id back as the Mcp-Session-Id header to route calls to it. Needs the HTTP transport (lightpanda mcp --port <PORT>); over stdio only the default session exists and this call returns an error.
| Argument | Type | Required | Description |
|---|---|---|---|
name | string | no | Optional id for the new session. Omit to get an auto-generated one. Reusing an existing id returns that session (a way to share one browsing context between agents). |
Hints: idempotent
session_list
List browser sessions. List the active browser sessions with their id and current URL. The default session always exists. Needs the HTTP transport (lightpanda mcp --port <PORT>); over stdio only the default session exists and this call returns an error.
No arguments.
Hints: read-only, idempotent
session_close
Close a browser session. Close a browser session, freeing its page and memory. The default session cannot be closed. Needs the HTTP transport (lightpanda mcp --port <PORT>); over stdio only the default session exists and this call returns an error.
| Argument | Type | Required | Description |
|---|---|---|---|
id | string | yes | The session id. |
Hints: destructive
Resources
The host application reads these with resources/read. The page resources need a loaded page; the skill resources don’t.
| URI | MIME type | Description |
|---|---|---|
mcp://page/html | text/html | The serialized HTML DOM of the current page |
mcp://page/markdown | text/markdown | The token-efficient markdown representation of the current page |
mcp://skill/pandascript | text/markdown | Write PandaScript agent scripts (.js) — Lightpanda’s replayable browser-automation format, run token-free with lightpanda run script.js. |
{"jsonrpc":"2.0","id":2,"method":"resources/read",
"params":{"uri":"mcp://page/markdown"}}The markdown tool and the mcp://page/markdown resource return the same content; the difference is who initiates. The agent calls tools during its workflow, while the host application reads resources, e.g. an IDE displaying page state in the background.