# AI agents and LLM tools

> Use VirginProxy from AI agents: MCP server for Claude, Cursor and other clients, tool definitions for OpenAI and Anthropic function calling, OpenAPI, llms.txt.

Source: https://docs.virginproxy.com/ai-agents/

AI assistants and agents can browse the web through VirginProxy: connect an MCP client with one of your keys or by signing in, or give your model our tool definitions. For reading the documentation itself, every page is also available as Markdown, all of it in one file, and the API as an OpenAPI description.

## MCP server

The API is a remote MCP server (Model Context Protocol, transport "Streamable HTTP", stateless). Apps with a sign-in for remote servers, such as Claude.ai and ChatGPT, connect [without a key](#oauth); any other client that supports remote servers connects with a header:

|  |  |
| --- | --- |
| Address | `https://api.virginproxy.com/mcp` |
| Authentication | `Authorization: Bearer vp_live_…` – one of your API keys, or [sign-in with OAuth](#oauth) |
| Methods | `tools/list`, `tools/call`, `resources/list`, `resources/read`, `resources/templates/list`, `prompts/list`, `prompts/get`, `server/discover` (and `initialize`, `ping` for older clients) |
| Server card | [`https://api.virginproxy.com/mcp/server-card`](https://api.virginproxy.com/mcp/server-card) – no key needed |

*MCP client configuration (JSON):*

```json
{
  "mcpServers": {
    "virginproxy": {
      "url": "https://api.virginproxy.com/mcp",
      "headers": {
        "Authorization": "Bearer vp_live_…"
      }
    }
  }
}
```

*Claude Code:*

```
claude mcp add --transport http virginproxy https://api.virginproxy.com/mcp \
  --header "Authorization: Bearer $VP_KEY"
```

Many clients (Cursor, VS Code, Windsurf and others) read a configuration in the form above; some name the field `serverUrl` instead of `url`. Put a key of yours where `vp_live_…` stands.

### Connect from Claude.ai, ChatGPT and other apps with sign-in

Apps that add remote MCP servers as connectors with a sign-in need no key:

1. In the app, add a custom connector with the address `https://api.virginproxy.com/mcp`. Leave fields for a client ID or secret empty: the app registers itself.
2. The app opens VirginProxy in your browser. Sign in (with your second factor, if you use one).
3. Check which app asks and where it sends you back to, set a credit limit for it if you like, and choose **Allow**.

| The app can | The app cannot |
| --- | --- |
| Read web pages, take screenshots, map and crawl websites with your account's credits (all ${TOOLS.length} tools below) | Change your plan, your payment details or your API keys |
| Read your plan, credits, usage and request log | Use any endpoint other than `/mcp` |

The connection then appears on the [API keys](https://dash.virginproxy.com/keys) page of the dashboard as a **connected app**. Its tool calls are charged, limited and logged like the calls of any key. Give it a credit limit there (or on the consent screen), or revoke it to end its access at once. There is no key to copy: the app holds short-lived tokens that work only on the MCP server.

> **Note:** Allow only an app you are connecting right now. The consent screen warns when an app receives the answer on your own computer or through its own link type instead of a secure web address.

### Sign-in for client developers

|  |  |
| --- | --- |
| Discovery | A 401 from `/mcp` carries `WWW-Authenticate: Bearer resource_metadata="https://api.virginproxy.com/.well-known/oauth-protected-resource/mcp", scope="mcp"`. Authorization server metadata: [`https://api.virginproxy.com/.well-known/oauth-authorization-server`](https://api.virginproxy.com/.well-known/oauth-authorization-server) |
| Registration | `POST https://api.virginproxy.com/oauth/register` (RFC 7591), public clients (`token_endpoint_auth_method: "none"`) or with a secret; redirect URIs https, `http://localhost` / `127.0.0.1` / `[::1]` with any port, or an app's own scheme |
| Authorization | Authorization code with PKCE (`S256` only), scope `mcp`, `resource` (RFC 8707) optional and if sent `https://api.virginproxy.com/mcp`; the answer carries `iss` (RFC 9207) |
| Tokens | `POST https://api.virginproxy.com/oauth/token`: access tokens valid one hour, refresh tokens valid 30 days and replaced on every use (using a replaced one again ends the sign-in). `POST https://api.virginproxy.com/oauth/revoke` (RFC 7009) |
| Use | Send the access token as `Authorization: Bearer …` to `/mcp` only; every other endpoint refuses it |

### Tools

| Tool | What it does | REST call |
| --- | --- | --- |
| `scrape` | Fetch one web page through VirginProxy and return its content, by default as Markdown of the main content (navigation, header and footer removed). | `POST /v1/requests` |
| `batch_scrape` | Fetch up to 10 pages in one call, in parallel, and get all answers together (Markdown of the main content by default). | `POST /v1/batch` |
| `screenshot` | Load a page in a real browser and return a screenshot of the visible area, the full page or one element. | `GET /v1/screenshot` |
| `pdf` | Load a page in a real browser and print it as a PDF (returned as an embedded document). | `GET /v1/pdf` |
| `search` | Search DuckDuckGo and get the results as JSON (title, address, snippet, plus ads, related searches and questions where the engine shows them). | `POST /v1/search` |
| `map` | Find the addresses of a website: the links on the given page plus the entries of its sitemaps (robots.txt, sitemap.xml). | `POST /v1/map` |
| `crawl` | Start a crawl in the background: it reads the start page, follows the links of the same site up to max_depth, and stops at max_pages. | `POST /v1/crawl` |
| `export_job` | The results of a job or crawl as NDJSON (one line per page) or CSV, without page bodies unless include_body is true. | `GET /v1/jobs/{id}/export` |
| `retry_job` | Starts a new job with the requests of a finished job that failed, exactly as they were sent. | `POST /v1/jobs/{id}/retry` |
| `get_job` | Status of a job or crawl and the pages it has finished, 20 at a time (use offset to page through).. | `GET /v1/jobs/{id}/results` |
| `list_jobs` | Your recent jobs and crawls, newest first, with their status and counts.. | `GET /v1/jobs` |
| `cancel_job` | Cancel a job or crawl: pages that have not started are dropped and not charged; pages already running finish. | `DELETE /v1/jobs/{id}` |
| `estimate` | The least and the most credits a scrape with these arguments can cost with your plan, and whether it fits into the credits left. | `POST /v1/estimate` |
| `account` | The account's plan, credits left in the current period and its limits.. | `GET /v1/account` |
| `usage` | Requests, successful requests, credits and data per day (UTC) for the last days.. | `GET /v1/usage` |
| `list_requests` | Your request log, newest first: target, status, error code, credits (not the content). | `GET /v1/requests` |
| `limits` | Parallel requests and rate of the plan with their current use, the daily credit cap and the key's limits. | `GET /v1/limits` |
| `get_answer` | The answer itself (body, extracted data …) of an earlier request, when it is kept: sent with an Idempotency-Key (24 hours) or cached. | `GET /v1/requests/{id}/answer` |
| `list_presets` | The account's presets: named request options to use with the "preset" argument of scrape.. | `GET /v1/presets` |
| `get_request` | The figures of one of your requests by its id (req_…): target, status, error, credits, timing.. | `GET /v1/requests/{id}` |

Every tool call is an ordinary API call: the same limits, the same credits, the same request log. `scrape` returns Markdown of the main content by default and cuts very long pages after 100,000 characters (with a note). Errors come back as a tool result with `isError`, so the model can read `error.code` and decide.

*The same call without a client:*

```bash
curl https://api.virginproxy.com/mcp \
  -H "Authorization: Bearer $VP_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/call",
       "params": {"name": "scrape", "arguments": {"url": "https://example.com/"}}}'
```

> **Tip:** Give an agent its own key with a credit limit (dashboard → API keys → Edit). It then cannot spend more than you allow, and its requests are easy to find in the log.

### Resources and prompts

Besides tools, the server offers read-only resources and ready-made prompts that clients can show to their users:

| Resource | Content |
| --- | --- |
| `virginproxy://guide` | Which tool for which task, what things cost, how to handle errors – written for a model. |
| `virginproxy://errors` | Every error code with its HTTP status and whether to retry. |
| `virginproxy://openapi` | The OpenAPI description. |
| `virginproxy://account` | Plan, credits left and limits, right now. |
| `virginproxy://jobs/{id}` | A job or crawl with its first 20 results. |
| `virginproxy://requests/{id}` | One request of your log. |

Prompts: `summarize_page` (url, focus), `extract_data` (url, fields) and `research_site` (url, question, max_pages).

### Protocol versions and discovery

The server speaks the current revision `2026-07-28` – no handshake; every request names its version in `params._meta` and in the `MCP-Protocol-Version`, `Mcp-Method` and `Mcp-Name` headers, and `server/discover` describes the server – and, for older clients, the revisions with `initialize`: `2025-11-25`, `2025-06-18`, `2025-03-26`, `2024-11-05`. Your client picks what it supports; nothing to configure. Every tool says what it does to your account in its annotations: only `cancel_job` changes something you cannot undo, only `crawl` and `cancel_job` are not read-only.

Clients and catalogues can find the server without a key: the server card at [`https://api.virginproxy.com/mcp/server-card`](https://api.virginproxy.com/mcp/server-card), listed in [`/.well-known/ai-catalog.json`](https://api.virginproxy.com/.well-known/ai-catalog.json).

> **Tip:** Try a workflow with a [test key](https://docs.virginproxy.com/test-mode/) first: the agent gets sample pages, nothing is fetched and nothing is charged.

## Function calling

The same tools as JSON definitions, generated from the same source as the MCP server:

| File | For |
| --- | --- |
| [`/ai/openai-tools.json`](https://docs.virginproxy.com/ai/openai-tools.json) | OpenAI Chat Completions (`tools`) |
| [`/ai/openai-responses-tools.json`](https://docs.virginproxy.com/ai/openai-responses-tools.json) | OpenAI Responses API |
| [`/ai/anthropic-tools.json`](https://docs.virginproxy.com/ai/anthropic-tools.json) | Anthropic Messages API |
| [`/ai/tools.json`](https://docs.virginproxy.com/ai/tools.json) | Each tool with the REST call it stands for (`endpoint`) and its defaults |

The arguments of a tool call are the body (or the query) of that REST call, so carrying out a call takes a few lines:

*run_tool.py:*

```python
import base64, os, requests

API = "https://api.virginproxy.com"
KEY = os.environ["VP_KEY"]
# The tool definitions with the REST call each one stands for.
SPEC = requests.get("https://docs.virginproxy.com/ai/tools.json", timeout=30).json()
ENDPOINTS = {t["name"]: t["endpoint"] for t in SPEC["tools"]}

def run_tool(name, args):
    """Carries out one tool call of the model and returns what to send back to it."""
    ep = ENDPOINTS[name]
    args = {**ep.get("defaults", {}), **args}
    path = ep["path"]
    if "{id}" in path:
        path = path.replace("{id}", args.pop("id"))
    headers = {"Authorization": "Bearer " + KEY}
    if ep["method"] in ("GET", "DELETE"):
        # query strings: booleans as true/false
        params = {k: str(v).lower() if isinstance(v, bool) else v for k, v in args.items()}
        r = requests.request(ep["method"], API + path, params=params, headers=headers, timeout=180)
    else:
        r = requests.post(API + path, json=args, headers=headers, timeout=180)
    if r.headers.get("content-type", "").startswith("image/"):
        return {"image_base64": base64.b64encode(r.content).decode(), "credits": r.headers.get("X-VP-Credits")}
    return r.json()  # errors too: the model can read error.code and error.message

print(run_tool("virginproxy_scrape", {"url": "https://example.com/"})["body"][:200])
```

**OpenAI (Python)**

```openai-python-
from openai import OpenAI
import json, requests

tools = requests.get("https://docs.virginproxy.com/ai/openai-tools.json", timeout=30).json()
client = OpenAI()
messages = [{"role": "user", "content": "Summarise https://example.com/ in one sentence."}]
reply = client.chat.completions.create(
    model="gpt-4.1",  # any model with tool use
    messages=messages, tools=tools,
).choices[0].message
messages.append(reply)
for call in reply.tool_calls or []:
    result = run_tool(call.function.name, json.loads(call.function.arguments))  # see above
    messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(result)[:100000]})
# … then call the model again with messages
```

**Anthropic (Python)**

```anthropic-python-
import anthropic, json, requests

tools = requests.get("https://docs.virginproxy.com/ai/anthropic-tools.json", timeout=30).json()
client = anthropic.Anthropic()
messages = [{"role": "user", "content": "Summarise https://example.com/ in one sentence."}]
reply = client.messages.create(
    model="claude-sonnet-4-5",  # any model with tool use
    max_tokens=1024, messages=messages, tools=tools,
)
results = [
    {"type": "tool_result", "tool_use_id": b.id, "content": json.dumps(run_tool(b.name, b.input))[:100000]}  # run_tool: see above
    for b in reply.content if b.type == "tool_use"
]
messages += [{"role": "assistant", "content": reply.content}, {"role": "user", "content": results}]
# … then call the model again with messages
```

## OpenAPI

The whole API as an OpenAPI 3.1 description, built from the same lists as this documentation:

- [`https://api.virginproxy.com/openapi.json`](https://api.virginproxy.com/openapi.json) and [`/openapi.yaml`](https://api.virginproxy.com/openapi.yaml) – from the API itself, no key needed
- [`https://docs.virginproxy.com/openapi.json`](https://docs.virginproxy.com/openapi.json) and [`/openapi.yaml`](https://docs.virginproxy.com/openapi.yaml)

Every error code with its HTTP status and whether to retry: [`GET /v1/errors`](https://api.virginproxy.com/v1/errors) (also [`/errors.json`](https://docs.virginproxy.com/errors.json)).

## Documentation for language models

| Address | Content |
| --- | --- |
| [`/llms.txt`](https://docs.virginproxy.com/llms.txt) | A short overview with links to every page as Markdown ([llms.txt](https://llmstxt.org/) format) |
| [`/llms-full.txt`](https://docs.virginproxy.com/llms-full.txt) | The whole documentation as one Markdown text |
| `/<page>/index.md` | Each page as Markdown, e.g. [`/webhooks/index.md`](https://docs.virginproxy.com/webhooks/index.md) or the short form `/webhooks.md` |
| `Accept: text/markdown` | Any page address answers with Markdown when a client asks for it |

Each page also has buttons to copy it as Markdown or to open it in ChatGPT or Claude.

### The complete documentation of your account

After signing in, customers also read the member guides. Hand your AI everything at once, member guides included – with the key in the header, never in the address:

| Way | How |
| --- | --- |
| MCP | Connected clients read the resource `virginproxy://docs` (the complete documentation) next to all tools of your account |
| With your key | `GET https://api.virginproxy.com/v1/docs/llms-full.txt` with `Authorization: Bearer vp_live_…`; `GET https://api.virginproxy.com/v1/docs` lists the complete OpenAPI description, error list and tool definitions. Free, not in the request log. |
| In the dashboard | [For your AI](https://dash.virginproxy.com/ai): download the files, set up Claude, ChatGPT or Cursor, copy a prompt template |

## Good practice for agents

- Check the cost before large work: [POST /v1/estimate](https://docs.virginproxy.com/billing/#estimate-api) runs nothing and charges nothing.
- Bound every call with `max_credits`; a crawl with `max_pages`.
- Send `Idempotency-Key` when a call may be repeated after a broken connection: the repeat gets the first answer and is not charged again ([Send again safely](https://docs.virginproxy.com/limits/#idempotency)).
- Decide by `error.code` and the `retry` advice in the [error list](https://docs.virginproxy.com/errors/); wait `retry_after_ms` (or the `Retry-After` header) when asked to.
- Ask for `format: "markdown"` with `main_content: true`: far fewer tokens than HTML.
