Module mcp

Module mcp 

Source
Expand description

MCP (Model Context Protocol) server for browser automation.

Exposes stygian-browser capabilities as an MCP server over stdin/stdout using the JSON-RPC 2.0 protocol. External tools (LLM agents, IDE plugins) can acquire browsers, navigate pages, evaluate JavaScript, and capture screenshots via the standardised MCP interface.

§Enabling

[dependencies]
stygian-browser = { version = "0.1", features = ["mcp"] }

§Running the server

STYGIAN_MCP_ENABLED=true cargo run --example mcp_server -p stygian-browser

§Protocol

The server implements MCP 2024-11-05 over JSON-RPC 2.0 on stdin/stdout. Supported methods:

MCP MethodDescription
initializeHandshake, return server capabilities
tools/listList available browser tools
tools/callExecute a browser tool
resources/listList active browser sessions as MCP resources
resources/readRead session state

§Tools

ToolParametersReturns
browser_acquiresession_id: String
browser_open_pagesession_idpage_url: String
browser_navigatesession_id, url, timeout_secs?title, url
browser_evalsession_id, scriptresult: Value
browser_screenshotsession_iddata: base64 PNG
browser_contentsession_idhtml: String
browser_releasesession_idsuccess
pool_statsactive, max, available

Structs§

JsonRpcError
A JSON-RPC 2.0 error object.
JsonRpcRequest
A JSON-RPC 2.0 request.
JsonRpcResponse
A JSON-RPC 2.0 response.
McpBrowserServer
MCP server that exposes BrowserPool over stdin/stdout JSON-RPC.

Functions§

is_mcp_enabled
Returns true if the MCP server is enabled via the STYGIAN_MCP_ENABLED environment variable.