Runnable Python examples for the Browserless MCP server. Browserless is a stateful MCP server: a multi-turn browser agent works in a real loop over HTTP, not just batched single-call mode.
The hosted endpoint at https://mcp.browserless.io/mcp exposes 10 tools auto-importable via llama-index-tools-mcp — no partner package needed.
| Stateless tools (8) | Stateful tools (2) | |
|---|---|---|
smartscraper, search, map, crawl, export, performance, function, download |
agent, skill |
|
| Use case | Single-shot scraping, research, data extraction | Multi-turn browser automation, multi-step browser flows with persistent browser state |
Multi-turn agent in LlamaIndex: the default
McpToolSpecflow opens a fresh MCP session per call. To preserve state across multi-turnbrowserless_agentcalls, useasync with client._run_session() as session: ...and callsession.call_tool(...)directly — seepython/README.mdandpython/browser_agent.ipynb.
import os
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec
client = BasicMCPClient(
"https://mcp.browserless.io/mcp",
headers={"Authorization": f"Bearer {os.environ['BROWSERLESS_TOKEN']}"},
timeout=120,
)
tools = await McpToolSpec(client=client).to_tool_list_async()
print([t.metadata.name for t in tools]) # 10 toolsSee python/ for full notebooks: quickstart.ipynb, research_agent.ipynb, browser_agent.ipynb.
LlamaIndexTS does not yet ship a first-party MCP client. Until it does, TypeScript users wanting Browserless via MCP should use @modelcontextprotocol/sdk directly. We may revisit this if upstream lands a @llamaindex/tools-mcp adapter, or contribute one ourselves.
For a TypeScript Browserless example using a different framework, see browserless/browserless-langchain (which uses @langchain/mcp-adapters).
- Hosted MCP server: mcp.browserless.io
- LlamaIndex MCP adapter:
llama-index-tools-mcp - Sister cookbook (LangChain):
browserless/browserless-langchain