Set a proxy spending cap for a browser agent and verify the exit IP
Set a human-approved proxy budget first, connect the official NexaLayer MCP withnpx -y @nexalayer/mcp, then create an approved session and check its exit from inside the browser. This walkthrough connects those steps without treating a model’s ability to call tools as permission to spend more money.
The result is a bounded network-proxy task: the owner sets the allowance, the agent uses the selected session, and cleanup releases the resource. For IP continuity, use the documented static-session path, which normally does not rotate. An exit check verifies one observation, not a permanent identity guarantee.
What this walkthrough covers — and what it does not
You will configure a budget, connect Claude or Cursor to the network-proxy MCP, select a live product, verify IP and country, and optionally compare two countries’ latency. You will also distinguish target-site 429 responses from NexaLayer API rate limits and clean up after timeouts. You need a funded NexaLayer account, an API key available securely to your client, a working Node.js/npx environment, and a browser integration you control. Use only destinations and tasks you are authorized to access, under the terms. Stop when a destination denies the task; this is not a guide to defeating access controls. The budget covers proxy resources, not LLM tokens, browser-hosting charges, or all agent costs. The MCP manages network sessions; it is not a general MCP gateway or a replacement for your browser automation tools.Set the spending cap before the agent can buy a session
Have the owner call or approvePUT /v1/account/budget. For example:
nexalayer_set_budget in your MCP client and then use nexalayer_get_budget. Humans set the budget; the agent stays inside that guardrail. See spend limits and alerts for complete budget and error behavior.
Install the official network-proxy MCP with npx
Use the official package:Safe tool order
Use this sequence:POST /v1/sessions does not accept include_credentials, and its response does not contain proxy credentials. Poll the session until it is active, then request credentials through a subsequent read with include_credentials=true only when ready to connect. Do not print that response into a conversation or routine logs.
Create a bounded session from a live price
Read the catalog immediately before selecting the purchase:product_no, price, currency, and unit, plus the relevant country and session type. Keep prices cached for no more than 60 seconds. An earlier tutorial’s product identifier is not a promise of inventory.
Examples in this page may use dynamic_2. Always confirm that product_no against GET https://api.nexalayer.net/v1/public/products at purchase time; do not use retired identifiers such as dynamic_dyn3 or out_dynamic_1. A catalog check on 2026-11-29 around 11:20–11:23 Asia/Singapore listed 106 products: only dynamic SKU dynamic_2 at $0.23/GB; shared static prices at $0.75, $1.06, and $2.72/month; and exclusive static prices from $1.43 to $5.88/month. That is a dated observation, not a current quote — inventory can flicker, and the live API is authoritative.
Build the purchase from the current Sessions API contract. Set session_type, the copied live product_no, quantity, and protocol as appropriate. Dynamic quantities are GB and may be fractional; static quantities count IPs and must be integers. The protocol defaults to socks5, and static proxies support SOCKS5 only; requesting another protocol for static returns 400.
Before approval, summarize the selected product, requested quantity, price and unit, intended task, and budget state. Do not turn that approval into permission for more sessions if the first attempt fails. After creation, record the session ID for cleanup even if browser startup has not yet succeeded.
Handle purchase errors without retrying blindly
409 PRICE_MISMATCH: no order was placed. Read the price again, confirm the approved purchase still applies, then retry once with a new idempotency key.402 BUDGET_EXCEEDED: stop. A purchase that would exceed a key or daily cap is rejected with 402 and never pauses the key automatically.pause_on_exceedis deprecated and unused. The same 402 is also returned if the key is already manually paused — only then should the owner unpause withPUT /v1/account/budget. After the owner raises the cap or approves a smaller purchase, retry with a new idempotency key; a completed 402 is stored for 24 hours and would be replayed if you reuse the original key.402 INSUFFICIENT_BALANCE: stop and ask the owner to top up. Do not auto-retry while unpaid. After the owner funds the account, retry with a new idempotency key — the original key would replay the stored 402.409 IDEMPOTENCY_CONFLICT: follow the documented branch for a changed request body or a request still in progress. This is not a price-refresh signal.
Keep the same exit IP for a browser-use or Playwright task
Use one NexaLayer session as the browser task’s proxy. When the task needs IP continuity, choose a static session: static sessions are intended for long-lived identity and normally do not rotate. Keep that session throughout the task, then terminate it. Renew or create a replacement when appropriate rather than treating static rotation as routine. Do not invent a separate sticky product or username session-ID syntax. NexaLayer’s documented path is the static session. Although the API exposesrotation_mode (fixed, timed, or on_demand in the OpenAPI schema), those values have no documented exit-IP continuity or sticky-session definition. In particular, a value named fixed is not sufficient evidence of a sticky-session promise.
Rotation can change network identity and disrupt a browser’s authenticated state. Do not silently swap sessions halfway through an identity-sensitive task. If continuity fails, stop, record the observation without credentials, and ask the owner how to proceed.
Pass the proxy into Playwright or Browser Use
Read credentials only after activation:username and password for HTTP(S) proxies. Playwright and Chromium currently reject a socks5:// server combined with username and password (Browser does not support socks5 proxy authentication; Playwright issue 10567 remains open). Follow the supported Playwright integration and examples, and validate support for your browser and version before relying on this shape. A field-accurate configuration object is not evidence that the bundled browser can authenticate to SOCKS5.
For Browser Use, map the same split fields into the current version’s browser profile or session proxy configuration. Keep the network lifecycle outside the browsing prompt: application code should retain the session ID, enforce approvals, and own cleanup. See the Browser Use guide rather than copying version-specific constructor names from an unrelated example.
Verify the exit IP and country
First make a direct, unproxied control request to an IP checker, outside the task’s proxied context. Then open the same checker inside the browser context configured with the NexaLayer session. Existing examples usehttps://httpbin.org/ip; https://api.ipify.org?format=json is another public IP-only checker.
Compare observations. A proxied result such as 192.0.2.10 differing from a direct result such as 198.51.100.24 would demonstrate the comparison shape; both addresses here are documentation placeholders, not actual measurements. If your real observations are identical, investigate the browser configuration before proceeding. Do not declare success merely because the proxy endpoint was returned by the API.
An IP-only checker does not prove country. Use an approved public IP/geo checker that reports country, from the same proxied browser context. Compare its country with the selected product’s country or the requested country_code, as applicable. Record the checker, timestamp, returned IP, and reported country without recording proxy credentials.
This proves only what that checker saw at that moment. It does not guarantee city-level accuracy, the identity seen by another destination, or the exit of every future request. If the geography is unexpected, stop and inspect the product selection and configuration instead of asserting the provider or checker must be right.
Compare latency from two countries
Select two countries actually available in the live catalog. Obtain approval for both purchases and check that the combined planned spend fits the allowance. Create one bounded session per country and use separate browser contexts so the observations do not share proxy configuration accidentally. Use the same checker URL and measurement boundaries for both. Repeat a small, fixed number of requests, such as three per context, within the approved task. Compare medians rather than presenting one unusually fast request as representative. Record cold versus warm browser conditions and whether startup time is included.When a Playwright request returns 429 — and when to rotate
A target-site 429 is a signal to respect that destination’s limits. Back off or stop as appropriate. Report the session event asevent_type: "rate_limit", then read GET /v1/sessions/{session_id}/health. See telemetry and health for the request contract.
Consider a supported dynamic-session rotation only when the recommendation is consider_rotate or rotate_now, with a documented reason such as http_429. A health recommendation does not grant permission to evade destination limits. If it says pause, stop and ask the owner. Persistent access denial is a reason to end the task, not keep changing IPs.
NexaLayer API 429 RATE_LIMIT_EXCEEDED is different. Wait for error.details.retry_after or Retry-After, then retry the same request according to the error reference. Do not rotate a browser session merely because the control-plane API is rate limited.
Timeout handling and session cleanup
Report a browser timeout astimeout, read session health, and consider a supported rotation with reason timeout only when the recommendation permits it and the authorized task still allows continuation. A timeout alone does not prove the proxy failed.
Keep cleanup outside the success path. The following is lifecycle pseudocode, not additional SDK methods:
Capability limits
- Owners approve paid session creation and policy changes. A cap is not the billing ledger.
- Creation responses omit credentials; retrieve them explicitly only when needed and never log them.
- Use live prices and identifiers. Price mismatch means no order was placed.
- Static sessions normally do not rotate and support SOCKS5 only.
- No undocumented
rotation_modesemantics establish a sticky guarantee. - Exit and latency measurements describe observations, not permanent properties.
- Any trial allowance is a small, one-time credit, not recurring funding.
Questions and answers
How do I install the proxy MCP in Cursor or Claude? Usenpx -y @nexalayer/mcp and the stdio configuration above. Keep owner approval enabled for consequential writes.
How do I keep the same exit IP? Use the documented static-session path, keep one session for the task, and verify the exit from the actual browser context. Static sessions normally do not rotate; this is not an unconditional identity guarantee.
When should I rotate after a 429 or timeout? Report rate_limit or timeout, inspect health, and consider supported rotation only for consider_rotate or rotate_now. For pause, stop and ask the owner. Always terminate during cleanup.