diff --git a/Cargo.lock b/Cargo.lock index 7b51079..9d539b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1635,6 +1635,7 @@ dependencies = [ "obscura-cdp", "obscura-dom", "obscura-js", + "obscura-mcp", "obscura-net", "serde", "serde_json", @@ -1678,6 +1679,20 @@ dependencies = [ "url", ] +[[package]] +name = "obscura-mcp" +version = "0.1.0" +dependencies = [ + "anyhow", + "obscura-browser", + "obscura-dom", + "obscura-net", + "serde", + "serde_json", + "tokio", + "tracing", +] + [[package]] name = "obscura-net" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 90e073f..6c25409 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ members = [ "crates/obscura-browser", "crates/obscura-cdp", "crates/obscura-js", + "crates/obscura-mcp", "crates/obscura-cli", ] @@ -21,6 +22,7 @@ obscura-net = { path = "crates/obscura-net" } obscura-browser = { path = "crates/obscura-browser" } obscura-cdp = { path = "crates/obscura-cdp" } obscura-js = { path = "crates/obscura-js" } +obscura-mcp = { path = "crates/obscura-mcp" } html5ever = "0.29" markup5ever = "0.14" diff --git a/README.md b/README.md index 30819ef..06945e4 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,63 @@ Scrape multiple URLs in parallel with worker processes. | `--quiet` | off | Suppress scrape progress on stderr | | `--proxy` | — | Inherited global HTTP/SOCKS5 proxy URL for all workers | +## MCP (Model Context Protocol) + +Obscura ships an MCP server that exposes browser automation tools to AI agents (Claude Desktop, Cursor, etc.). + +### Start + +**stdio** (default) — for Claude Desktop and MCP clients that launch a subprocess: + +```bash +obscura mcp +``` + +**HTTP** — for clients that connect over the network: + +```bash +obscura mcp --http --port 8080 +# endpoint: http://127.0.0.1:8080/mcp +``` + +Optional flags (both transports): + +| Flag | Description | +|------|-------------| +| `--proxy ` | HTTP/SOCKS5 proxy | +| `--user-agent ` | Custom User-Agent string | +| `--stealth` | Enable anti-detection mode | + +### Claude Desktop config + +```json +{ + "mcpServers": { + "obscura": { + "command": "obscura", + "args": ["mcp"] + } + } +} +``` + +### Tools + +| Tool | Description | +|------|-------------| +| `browser_navigate` | Navigate to a URL (`url`, optional `waitUntil`: `load` / `domcontentloaded` / `networkidle0`) | +| `browser_snapshot` | Return the current page URL, title, and body text | +| `browser_click` | Click an element by CSS selector | +| `browser_fill` | Set an input value (triggers `input` + `change` events) | +| `browser_type` | Append text to an input | +| `browser_press_key` | Dispatch a keyboard event (`key`, optional `selector`) | +| `browser_select_option` | Select an `