Skip to Content
ReferenceMCP tools

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.

These tools bring a page into the browser, or save a URL to a file.

ToolTitleHints
gotoOpen a URL and keep the page in memoryidempotent, open-world, page state
searchWeb search, results as markdownidempotent, open-world
downloadFetch a URL with the session’s cookies into a filedestructive, idempotent, open-world

Reading the page

These tools read the loaded page without modifying it.

ToolTitleHints
markdownRender the page or a subtree as markdownidempotent, open-world
htmlRaw HTML of the page or a nodeidempotent, open-world
screenshotScreenshot of the page or a nodedestructive, idempotent, open-world
linksList all links on the pageidempotent, open-world
treeSemantic DOM tree of the pageidempotent, open-world
nodeDetailsInspect a node by backendNodeIdread-only, idempotent
interactiveElementsList interactive elements on the pageidempotent, open-world
structuredDataExtract JSON-LD / microdata / OpenGraph dataidempotent, open-world
detectFormsList forms and their fieldsidempotent, open-world
findElementFind elements by role or nameread-only, idempotent

Data extraction and scripting

These tools return structured results from the loaded page.

ToolTitleHints
evaluateRun JavaScript in the pagedestructive, open-world
extractExtract structured data via a CSS-selector schemaread-only, idempotent
classifyClassify page state using semantic questions or presetsread-only, open-world

Interacting with the page

These tools dispatch real DOM events on the page.

ToolTitleHints
clickClick an elementdestructive, open-world, page state
fillType text into an inputidempotent, page state
scrollScroll the page or an elementpage state
hoverHover over an elementidempotent, page state
pressPress a keyboard keydestructive, open-world, page state
selectOptionSelect an option in a dropdownidempotent, page state
setCheckedCheck or uncheck a boxidempotent, page state
acceptCookiesDismiss a cookie consent bannerdestructive, open-world
loginSign in, picking the fields with Jevdestructive, open-world

Waiting

These tools block until the page reaches a condition.

ToolTitleHints
waitForSelectorWait for an element to appearidempotent
waitForScriptWait until a JS expression is truthyidempotent
waitForStateWait for the page to reach a load stateidempotent

State and debugging

These tools inspect browser state outside the DOM.

ToolTitleHints
consoleLogsRead buffered console messagesread-only
getUrlShow the current page URLread-only, idempotent
getCookiesShow stored cookiesread-only, idempotent
getEnvRead or list LP_* env varsread-only, idempotent
popupsList windows the page opened, or switch to oneidempotent

Page tools (WebMCP)

These tools list and call the tools a page registers for agents through WebMCP.

ToolTitleHints
pageToolsList the page’s WebMCP toolsread-only, idempotent
callPageToolCall one of the page’s WebMCP toolsdestructive, 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 a timeout (or any option) the session didn’t use. Never round-trip a result through lp.*, and never append no-op page.extract(…) probes or page.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:

  • Page is the only global. new Page() makes a page; await page.goto(url) navigates it (async — always await). Every other builtin is a synchronous method on that page: const data = page.extract({...}), never await page.extract. The file runs as an async script, so top-level await is 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 with return page.extract({...}); or return 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.
ArgumentTypeRequiredDescription
pathstringyesRelative path (no ’..’ segments) to write the script to. Created or overwritten. The response reports the absolute location.
scriptstringyesThe 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.

ArgumentTypeRequiredDescription
scriptstringnoThe agent script source, as save writes it or lightpanda run takes it. Pass this or path.
pathstringnoA script file to run instead of script, such as one save wrote. Relative to the server’s working directory.
timeoutintegernoOptional. 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.

ArgumentTypeRequiredDescription
namestringnoOptional 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.

ArgumentTypeRequiredDescription
idstringyesThe 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.

URIMIME typeDescription
mcp://page/htmltext/htmlThe serialized HTML DOM of the current page
mcp://page/markdowntext/markdownThe token-efficient markdown representation of the current page
mcp://skill/pandascripttext/markdownWrite 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.