MCP Integration
Pry ships a Model Context Protocol (MCP) server so AI agents (Claude, Cursor, Hermes, and any MCP client) can scrape and extract the web natively — and pay via x402 automatically.
- Server name:
pry, version3.0.0 - Protocol version:
2024-11-05 - API base URL:
http://localhost:8002(override withPRY_API_URL) - Enable with
PRY_MCP_ENABLED=true(default)
Running the MCP server
stdio transport (default, for local agents)
pry mcp serve
Or directly: python -m mcp_production
HTTP + SSE transport (remote agents)
mcp_sse.py implements the official MCP HTTP+SSE transport:
- Client connects to
GET /mcp/sse - Server sends an
endpointevent with a POST URL (/mcp/messages/{session_id}) - Client POSTs JSON-RPC messages to that URL
- Server replies by enqueueing JSON-RPC responses as
messageevents on the SSE stream
Sessions are kept in memory (5-minute idle TTL). For production multi-worker deployments, use a Redis-backed queue or sticky sessions.
Claude Desktop / Cursor configuration
{
"mcpServers": {
"pry": {
"command": "python",
"args": ["-m", "mcp_production"]
}
}
}
For Hermes or any stdio MCP client, the equivalent config is
command: "pry", args: ["mcp", "serve"].
Tools
The MCP server exposes these tools:
| Tool | What it does |
|---|---|
pry_scrape | Scrape any URL to clean markdown (POST /v1/scrape) |
pry_crawl | Crawl a site up to N pages (POST /v1/crawl) |
pry_extract | Extract structured data with CSS selectors or a JSON schema (POST /v1/extract/css) |
pry_template | Execute a pre-built scraper template |
pry_search_templates | Search the 110+ scraper templates |
pry_monitor | Create a scheduled page monitor |
pry_compliance | Run a GDPR/compliance check on a URL |
pry_enrich | Enrich a page (tech stack, metadata) |
pry_parse_document | Parse PDF/DOCX/OCR documents (POST /v1/parse) |
pry_screenshot | Take a screenshot of a URL |
pry_x402_pricing | Query x402 pay-per-call pricing |
pry_referrals | Referral tracking |
Example tool call (JSON-RPC):
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "pry_scrape",
"arguments": {
"url": "https://example.com",
"formats": ["markdown"]
}
}
}
Legacy HTTP bridge
The repo's README references an HTTP bridge (POST /mcp/call with
{"name": "pry_scrape", "arguments": {...}} and GET /mcp/tools). These
endpoints exist only in mcp_production.py, which is not deployed — use
pry mcp serve (stdio) or the HTTP+SSE server (mcp_sse.py) for MCP access.
GET /v1/ai/mcp-config also serves the current MCP server config.
Agent onboarding SKILL.md
When you give an agent access to Pry, provide a skill file so it knows how to
use the tools correctly. A minimal onboarding SKILL.md:
# Pry — Web Scraping & Browser Automation
Use the `pry_*` MCP tools to scrape and extract web content.
## Rules
- Prefer `pry_extract` with CSS selectors for structured data (deterministic, free).
- Use `pry_scrape` for markdown content; add `bypassCloudflare: true` for WAF-protected sites.
- Use `pry_parse_document` for PDF/DOCX/OCR documents.
- Use `pry_crawl` (maxPages ≤ 10) before reaching for `pry_scrape` on multi-page sites.
- For AI extraction of messy pages, use `pry_extract` with an instruction + schema.
- Check `pry_x402_pricing` before calling paid operations when x402 is enabled.
- Never scrape login-walled content without authorization; respect robots.txt and ToS.
## Example
1. `pry_scrape` https://example.com → markdown
2. `pry_extract` with schema `{"name": "string", "price": "number"}` → JSON
x402 + MCP
When PRY_X402_ENABLED=true, paid MCP operations go through the x402 flow —
agents pay per call from their wallet without an account. See
x402 Pay-per-call for the full flow.
Next steps
- Quickstart — run the API first
- x402 Pay-per-call — automated payments for agents