Give web-scraping agents clear limits with MCP
Define allowed sites, request budgets and output limits in the application that runs the tools.

A web-reading agent can discover a tool and call it repeatedly. That makes the tool useful, but it leaves a practical question for its owner: what can this job actually do before the application stops it?
MCP gives tools a common way to describe their inputs and return results. Your application still needs to authorize requests and enforce resource limits. A model instruction asking for restraint is not an execution limit.
Start with a narrow collection contract
Give a tool one clear purpose, such as fetching a permitted product page into a defined record format. Describe the accepted arguments and expected output. Avoid a tool that accepts an arbitrary destination, unrestricted headers and a free-form instruction to do anything necessary.
Validate incoming arguments before starting work. Keep credentials in the service that owns them, and use the authenticated caller's permissions. A descriptive annotation on a tool does not replace access control. If a tool is described as read-only, its implementation still needs to behave that way.
Make the collection scope visible to the user. Separate fetching public pages from actions that submit forms or change accounts. A tool that can perform those actions needs an explicit authorization design, not an assumption that every discovered capability is approved.
Enforce where the tool may connect
For a narrow job, use an approved set of destinations. Parse addresses with a maintained URL library. Check scheme, host and port against policy. A substring test is inadequate: an address can contain an approved name without connecting to that destination.
Destination checks must also account for resolved addresses and redirects. Block access to private or otherwise prohibited network destinations through the network layer that actually makes the connection. Disable redirects when they are unnecessary. If they are allowed, validate each new destination before following it.
A browser can issue subresource requests beyond its initial page address. Apply the intended outbound policy to those requests too. An initial URL check alone does not confine a browser to one origin. Treat a model-supplied URL as untrusted input, even when it came from an earlier page.
Give each job a shared budget
Set limits for request attempts, elapsed time and transferred data. Define what each limit counts. If a tool expands one call into several HTTP requests, counting tool invocations alone understates its activity. Count retries and redirect hops under the policy you chose.
The following object is illustrative application configuration. These keys are not standard MCP fields or Crawlhub product settings. The example values are chosen to explain the contract, not recommended limits for every job.
{
"allowed_origins": ["https://catalog.example"],
"max_request_attempts": 6,
"max_elapsed_ms": 15000,
"max_response_bytes": 1048576,
"max_output_records": 100
}
The application must connect each setting to enforcement. Reserve request capacity before dispatch, including when workers run concurrently. Specify whether the byte limit covers each response or the whole job, and whether it measures compressed or decoded data. Stop reading when the enforced cap is reached.
Use one job deadline that includes queued work. A fresh timeout on every retry can otherwise keep extending the task. Keep concurrency and queue size bounded as well; a request counter does not limit memory by itself.
Connect cancellation to the worker
The protocol provides cancellation mechanisms, but your implementation needs to pass the stop condition to its HTTP client or browser worker. A client ceasing to wait is not evidence that every downstream task has released its resources.
Enforce the server-side deadline even when progress messages continue. Test cancellation during navigation and response reading. Stop new dispatches, cancel work where supported and release contexts or connections. Record work that completed before cancellation rather than assuming it was undone.
Check the protocol version and transport your client actually uses before implementing cancellation messages. Do not copy a message shape into every transport. Keep these transport details out of the model's responsibility.
Return a bounded result with an honest status
Limit output records and text length separately from network input. Return the final page address, observation time, completion state and any truncation. An interrupted or capped response must not look like a complete dataset. Keep extraction failures distinct from a valid empty result.
If you declare an output schema, validate the result against it before returning it. Treat fetched page text as data, not as authority to change permissions or launch another tool. Keep credentials and private headers out of model-visible results and routine logs.
Test the boundary before connecting an agent
Use controlled fixtures to exercise an allowed destination, a prohibited destination and a redirect outside scope. Add an oversized response, a slow response and concurrent calls competing for the final request allowance. Check that rejected requests do not reach the network worker.
Keep an audit record of the job identifier, policy decision, attempts used, duration and stop reason. The agent can choose its next question within the permitted task. The application owns the boundary and must enforce it when the model makes a mistake.
