Python SDK
Create an agent with a starting URL and a goal, then iterate over its steps. Each state includes elapsed time, status, and the latest decision.
from meshsurfer import Agent with Agent( "https://www.example-travel.com/flights", "Find one-way flights from Zurich to London on September 20, 2026, " "for one adult in economy. Stop when matching flight options are visible.", ) as agent: for state in agent.run(): print(state["elapsed_ms"], state["status"])
The same policy runs any task. Change the URL and the goal; nothing else.
Agent tools over MCP
Let any MCP client (coding assistants, IDE agents, your own harness) drive a browser. The calling agent breaks the work into narrow goals; MeshSurfer executes each one with the same loop.
calling agent ──goal──▶ meshsurfer-mcp ──▶ decision loop ──CDP──▶ browser tab
▲ │
└──── actions + page text + elements ─────┘ (caller verifies)
| Tool | Arguments | What it does |
|---|---|---|
browser_do | goal, url | session_id | Runs one goal until DONE, BLOCKED, or an error |
browser_observe | session_id | Re-reads the page without acting |
browser_close | session_id | Closes the tab |
Pass url to open a new tab, or session_id to continue in an existing one with fresh history and budgets. Invalid input (non-HTTP URLs, unknown sessions, too many tabs) returns a tool error and opens nothing.
{
"mcpServers": {
"meshsurfer": {
"command": "meshsurfer-mcp"
}
}
}Result shape
| Field | Meaning |
|---|---|
session_id | Pass to later calls to keep using this tab |
status | done, blocked, or error |
url, title | The final page |
elapsed_ms | First decision to last observation |
model_calls | {"decisions": n, "text": n} |
actions | Executed actions: operation, element label, typed text, whether the page changed |
page_text | Visible page text (up to 6,000 chars) |
elements | Indexed element table, e.g. [3] combobox Where to? · London |
done is a claim, not proof. Check url, page_text and elements against your goal before relying on the outcome.Bring your models
MeshSurfer uses two models, both reached over HTTP:
- Decision model: a structured-choice model that answers the operation and target heads. Use our hosted endpoint, a compatible model router, an edge inference provider, or a self-hosted server.
- Text model: any OpenAI-compatible
/chat/completionsendpoint. Small, fast, non-reasoning models work best. JSON mode can be disabled for engines that don't support it; replies are still validated before anything is typed.
Keys stay in the server process. A key is only ever sent to the host it was configured for, and self-hosted endpoints without a key receive no Authorization header. Provider errors name the URL that failed, and no action is executed.
Best practices
- One narrow goal per call. Chain them on a session: search, then open a result, then set a filter.
- Verify after every call. Read the final URL and elements yourself.
- After an error, observe first. Actions in the result already ran and are never retried automatically.
- Treat
blockedas a signal to switch tools for pages outside the DOM reader (canvas, iframes, uploads). - Raise your client's tool timeout for long goals. Each goal is budgeted at 60 actions and 120 decisions, and stops after three no-op actions in a row.