Harness Web Access and MCP Interaction
The harness reads the web and answers MCP servers under the same governance as every
other tool call (spec 3.1 §7.20, §7.21). web_fetch and web_search are governed tools
whose class comes from the URL's host; everything they return reaches the model inside a
delimited untrusted block, screened before it is stored. An MCP server's elicitation
reaches the person through the approval prompter or the approval inbox, its sampling
request runs the harness model with no tools under the run's budget, and its resources
enter the context only through a Read tool or an explicit @server:resource mention.
| Feature | Default | Adds |
|---|---|---|
web | off in the library, on in adk-rust | web_fetch, web search (the model provider's built-in search, or web_search over a SearchProvider), screening, ProviderWebTools, SearxngSearch, DeepSeekSearch |
mcp | off in the library, on in adk-rust | the elicitation, sampling and resource bridges; mcp_list_resources, mcp_read_resource |
web-fixture | off | a loopback HTTP server stands in for the web in tests; never on in adk-rust |
The umbrella crate forwards them as harness-web and harness-mcp.
Web
Tools
| Tool | Declaration | Class | Behaviour |
|---|---|---|---|
web_fetch | { url, max_bytes?, as?: "text" | "markdown" } | Web { allowlisted } from the URL's host | One GET; the body becomes text; the result carries the url, final url, status, content type, byte count and SHA-256 |
web_search | { query, limit?: ≤ 10, site?: host } | Web { allowlisted } from site, other when absent | Runs the operator's SearchProvider; returns [{ title, url, snippet }] in the same block; fetches no page |
The governed web_search is declared only when a SearchProvider is set; without one, web
search is the model provider's built-in search (Web search).
Mode table rows
| Class | ReadOnly | Plan | Ask | Auto |
|---|---|---|---|---|
| Web, allowlisted host | Allow | Allow | Allow | Allow |
| Web, other host | Deny | Deny | RequireApproval | RequireApproval |
A standing rule may cover a web call. The prompt for a host outside the allowlist shows the
host, path and query separately, names the class, and offers one rule: DomainIn on the
exact host the call named, never a wildcard the person did not type.
A call whose url names a host outside fetch_domains is denied in every mode before the
table is read, as harness.web.domain_not_allowed; no approval or standing rule widens the
filter.
Configuration
use std::sync::Arc;
use adk_harness::web::UrlProvenance;
use adk_harness::{HarnessAgent, SearchDomains, WebConfig};
let harness = HarnessAgent::builder("harness")
.model(model)
.workspace(adk_devtools::Workspace::new("."))
.web(WebConfig {
allowed_domains: vec!["docs.rs".into(), "*.rust-lang.org".into()],
fetch_domains: Some(SearchDomains::Blocked(vec!["pastebin.com".into()])),
url_provenance: UrlProvenance::Always,
search_domains: Some(SearchDomains::Blocked(vec!["pinterest.com".into()])),
..WebConfig::default()
})
.build()?;
WebConfig field | Default | Meaning |
|---|---|---|
allowed_domains | empty | Hosts web_fetch and the browser pack's navigation reach without approval: exact hosts or *.example.com, the DomainIn grammar. Never forwarded to a search |
fetch_domains | None: every domain | The fetch filter: SearchDomains::Allowed(..) (only these) or SearchDomains::Blocked(..) (never these), each entry covering the domain and its subdomains; applies to the URL and every redirect hop; no approval widens it |
url_provenance | UrlProvenance::Unattended | When a fetched URL must already appear in the conversation; see URL provenance |
url_sources | user messages and every tool result except bash and shell_output | Which parts of the conversation count for url_provenance (adk_core::egress::UrlSources) |
search_domains | None: every domain | The search filter (spec 3.1 §7.32): SearchDomains::Allowed(..) or SearchDomains::Blocked(..), each entry covering the domain and its subdomains; see Search scope |
max_bytes | 1 MiB | Read on the wire; 64 KiB of text are delivered, the rest cut with a marker |
max_url_len | 2,048 | Longest URL sent |
max_query_len | 512 | Longest search query |
timeout | 20 s | Per request |
max_redirects | 5 | Followed within one call |
max_fetches_per_turn | 20 | Further fetches of the turn are refused with harness.web.turn_cap |
user_agent | adk-harness/<version> | The User-Agent header |
Rules
| Rule | Mechanism |
|---|---|
GET only, no body, no credentials | The harness's own reqwest client: no cookie store, no proxy from the environment, no credential from the broker; a new client per request |
| Resolution | The URL parses under the DomainIn grammar (no user information, backslashes, percent-encoded hosts or characters outside [a-z0-9.-]); the host resolves before connecting, and a loopback, link-local, private, IPv4-mapped or .local/.internal address is refused as harness.web.private_target; a literal of those kinds is hard-denied by the policy before the tool runs |
| Redirects | Followed by the tool: each target is parsed, resolved and re-classified; a redirect off the host, to a host outside the allowlist, is returned as redirect_to for a new call; a redirect to a private target, or to a host outside fetch_domains, is refused |
| Content | text/html becomes text (scripts, styles and hidden elements dropped; with as: "markdown", links kept as [text](url) with relative links written as absolute URLs); text/* and application/json pass; application/pdf is a stub naming the bytes and digest; any other type is refused with its mime type |
| Delivery | { url, final_url, status, content_type, sha256, bytes, truncated, screening, content } with content inside <untrusted-content source="web" url="…" sha256="…"> and the closing tag neutralized inside |
| Screening | Injection patterns (imperatives addressed to the agent, tool-call syntax, role markers) label the line [screened: injection-pattern]; secret patterns are replaced by [redacted: secret-pattern]; both before the result is stored, and recorded as harness.web.screened. The result's screening says what happened: clean (screened, nothing found), labelled, redacted, labelled, redacted, or not_screened for content that is not screened, such as a PDF stub; web_search and the browser pack's results carry the same field |
| Exfiltration | A URL over max_url_len, whose query or fragment matches a secret pattern or carries more than 256 bytes outside the path, is refused before any request; so is a query over max_query_len or matching a secret pattern; under URL provenance, so is a URL the conversation does not hold; the record carries a digest, never the value |
URL provenance
A model that has read untrusted text can be told to put data it holds into a URL and fetch
it: a query string, a path segment or a host name carries the data out. Under
url_provenance, web_fetch and the browser pack's navigation take a URL only when it
already appeared in the conversation: in a user message or a tool result, exactly as
written there. A URL found only in what the model wrote is refused with
harness.web.url_not_in_context before the URL is parsed further or its host resolved.
UrlProvenance | The rule applies |
|---|---|
Off | Never |
Unattended (default) | In Auto mode, where no person sees a call before it runs: edits run unasked, a held web call may be answered by the auto reviewer (a model), and kernel partitions and goals run unwatched |
Always | In every mode, as Anthropic's server-side web_fetch applies it |
In Ask, Plan and Read-only modes every fetch outside allowed_domains waits for a person who
sees the URL, so Unattended leaves those modes as they were; an allowlisted host still
receives a composed URL there without asking, which Always closes. The mode is read from
the session's mode store at each call, and the rule applies when the store cannot be read.
Source (url_sources) | Counts |
|---|---|
| User-role text, file references and embedded resources | Yes (user_input) |
| Tool results, by tool name | Every one except bash and shell_output by default (tool_results: All, None, Only(..) or Except(..)) |
| The provider's built-in search and fetch results | Under All and Except(..) |
| Model text, thinking and tool calls, and the system instruction | Never |
| Matching | Rule |
|---|---|
| Normalization | Scheme and host lowercased, the default port dropped, an empty path written /, dot segments resolved, and the fragment, which never leaves the client, removed |
| Query and path | Compared exactly: a URL with data appended to its query or path is a different URL |
| Bare hosts | In user text, docs.rs/serde admits https://docs.rs/serde and http://docs.rs/serde |
| Links on a fetched page | Written as absolute URLs in as: "markdown", so a link the page gives is fetchable as written |
| Redirects | Chosen by the server, so each hop passes fetch_domains, the private-target check and the egress policy, not the rule; a redirect to another host comes back as redirect_to, a tool result, so the next call may fetch it |
The refusal is recorded as harness.web.fetched with phase: "refused",
refusal: "notInContext" and the URL's digest only, since any part of a composed URL,
its host included, may carry the data; a host refused by fetch_domains is recorded with
refusal: "domainNotAllowed", the host, and whether a redirect led to it.
| Limit | Mitigation |
|---|---|
| A tool that echoes model text launders a URL: a shell that prints what a command built, a file the model wrote and read back | The shell's results are not sources by default; ToolResultSources::Only naming web_search and web_fetch is the strictest reading |
| The choice of which admitted URL to fetch, and in what order, is a channel | max_fetches_per_turn bounds it |
| A call held for approval in Auto mode is put to the approver before the tool applies the rule | The tool description tells the model the rule, so such a call is rare; the refusal follows the approval |
adk_core::egress::ContextUrls is the same rule for any tool: ContextUrls::from_tool_context
collects a call's conversation under a UrlSources, and contains decides a URL.
adk-browser's BrowserToolset::with_url_provenance applies it to browser_navigate,
browser_new_tab and browser_new_window outside the harness.
Web search
HarnessAgentBuilder::web(..) turns web search on with web_fetch. Search runs on one of
two paths, chosen at build (spec 3.1 §7.20):
| Configuration | Path | Governed |
|---|---|---|
.web(..) alone (the default) | The search built-in of the provider the model's client serves | No: the search runs inside the model; the run records it afterwards |
.web(..) and .search_provider(..) | The governed web_search over that provider | Yes: policy, screening and a per-call record |
.web(..) and .provider_web_tools(ProviderWebTools::off()) | None | — |
No .web(..) | None, unless .provider_web_tools(..) asks for a built-in explicitly | — |
A configured search provider always wins over the model provider's built-in search.
HarnessInfo::web_search reports the path and its search filter as a WebSearchPath;
adk-rust prints it on the Search line of the banner and under /web, and the
capability block names it on its Web search line.
Search scope
The fetch allowlist and the search filter are separate settings (spec 3.1 §7.32, §13 Q8,
I73): provider search covers every domain unless search_domains says otherwise, and
allowed_domains never reaches a search.
| Setting | Meaning |
|---|---|
WebConfig::allowed_domains | Hosts web_fetch and the browser pack's navigation reach without approval; never forwarded to a search |
WebConfig::search_domains | The search filter: forwarded where the provider's search takes one, applied to the governed web_search's results, and named in the banner where the provider takes none |
| Operator ceiling | [web] search = "off" or search_domains in the operator's or user's configuration; a workspace file may only narrow them (I3) |
| Search | Allowed(..) | Blocked(..) |
|---|---|---|
Anthropic web_search | Forwarded as allowed_domains | Forwarded as blocked_domains |
OpenAI openai_web_search | Forwarded as filters.allowed_domains | Not applied: the banner says OpenAI takes no such filter |
Gemini google_search, DeepSeek deepseek_web_search | Not applied: the banner says the provider takes no search filter | Not applied |
The governed web_search | Results outside the list are dropped, counted as filtered | Results inside the list are dropped |
SearchDomains::narrow(ceiling, workspace) applies a workspace's filter to the operator's:
two allowed lists keep what both cover, an allowed list loses the entries a blocked list
touches, and two blocked lists combine. An allowed list left empty declares no search, and
HarnessInfo::web_search says why.
Note: Provider search is declared only to runs that start in Ask or Auto (I49), so the tool list changes when a session moves between Plan and Ask, and Anthropic's prompt cache is written again once per such move.
The provider's built-in search
The provider is read from the model's client through Llm::native_web_search(), never
from what the model writes:
| Client | Built-in | Declared as | Search filter |
|---|---|---|---|
GeminiModel (generateContent, Gemini API or Vertex AI) | GoogleSearchTool | google_search | None: every domain, and the request banner says Gemini takes no search filter when one is configured |
GeminiModel on the Interactions transport | None | — | The transport refuses a built-in tool beside function tools |
AnthropicClient on api.anthropic.com | WebSearchTool | web_search | allowed_domains or blocked_domains |
AnthropicClient on DeepSeek's Anthropic endpoint (https://api.deepseek.com/anthropic) | WebSearchTool | web_search | None documented: every domain |
OpenAIResponsesClient on api.openai.com | OpenAIWebSearchTool | openai_web_search | filters.allowed_domains |
OpenAIResponsesClient on https://api.deepseek.com with deepseek-v4-pro | DeepSeekWebSearchTool | deepseek_web_search | None documented: every domain |
OpenAIClient (Chat Completions), DeepSeekClient, OllamaModel, GroqClient, BedrockClient, mistral.rs, any other endpoint | None | — | Configure a search provider |
adk-rust --provider openai builds OpenAIResponsesClient for GPT-5.6 and every later GPT
generation, so a session on those models searches with OpenAI's web_search by default; an
older model stays on OpenAIClient (Chat Completions) and has no provider search.
DeepSeek runs its search on the Responses endpoint for deepseek-v4-pro (deepseek-flash
ignores the tool) and on its Anthropic-compatible endpoint; its Chat Completions endpoint,
which DeepSeekClient uses, accepts function tools only
(Responses API,
Anthropic API).
The guards (spec 3.1 §9.2 I49):
| Guard | Mechanism |
|---|---|
| Mode | Declared only to a run that starts in Ask or Auto; ReadOnly and Plan keep the Web class denial (I13). A tightening to ReadOnly or Plan while one is live ends the turn with harness.web.provider_tightened |
| Search filter | WebConfig::search_domains is forwarded where the provider takes it; the request banner names it, or says the provider cannot take it. The fetch allowlist is never forwarded (I73) |
| Banner | Each request of the run names the live built-ins and says web_fetch is the governed path |
| Refusal | A provider that refuses a request because it declares a built-in (no search quota on the account, no permission, a model without the tool: a rate-limit, forbidden, invalid-input or unsupported error before the first response) gets the request once more without the built-ins; when that succeeds they stay off for the harness and a warning names the reason |
| Records | harness.web.provider_enabled once per run; after each model response that carries a provider search, harness.web.searched with source: "provider", the queries (secret patterns redacted) and their digests, the cited URLs and their hosts |
Gemini reports its queries in groundingMetadata.webSearchQueries and its sources as
grounding chunks, whose URLs are Google's redirect links; Anthropic in server_tool_use
and web_search_tool_result blocks; OpenAI and DeepSeek in web_search_call items.
use adk_harness::ProviderWebTools;
// Turn the built-in search off, and add Gemini's URL context explicitly.
let builder = builder.provider_web_tools(ProviderWebTools {
gemini_url_context: true,
..ProviderWebTools::off()
});
ProviderWebTools::provider_default() (also Default) is the provider's search alone. The
per-provider flags attach only for the provider the model's client serves. Every other
provider-executed builtin passed to .tool(..) is refused at build: search and URL context
are enabled here, computer use through its pack, and the rest have no governed form.
A search provider
| Provider | Configure | Behaviour |
|---|---|---|
SearxngSearch::new(url) | The instance's base URL; the instance lists json under search.formats in settings.yml | GET <url>/search?q=…&format=json; no key |
DeepSeekSearch::from_env() / DeepSeekSearch::new(key) | DEEPSEEK_API_KEY | POST https://api.deepseek.com/v1/tools/search (Search API); the hit's snippet is DeepSeek's summary |
Your own SearchProvider | — | name() and search(query, limit, site) |
use std::sync::Arc;
use adk_harness::{HarnessAgent, SearxngSearch, WebConfig};
let harness = HarnessAgent::builder("harness")
.model(model)
.workspace(adk_devtools::Workspace::new("."))
.web(WebConfig::default())
.search_provider(Arc::new(SearxngSearch::new("http://localhost:8888")?))
.build()?;
A site restricts results with the site: operator both providers read. The harness caps,
screens and delimits what a provider returns, as for every governed search.
MCP interaction
Servers are declared to the builder as McpServerSets. Operator-declared servers start
with the first run; workspace-declared servers (.mcp.json in the workspace, read by
adk-rust) start only once the workspace is trusted, and their elicitations are high-risk
approvals.
use std::collections::HashMap;
use adk_harness::{HarnessAgent, McpInteractionConfig, McpServerSet};
use adk_tool::mcp::McpServerConfig;
let servers = HashMap::from([(
"docs".to_string(),
McpServerConfig { command: "docs-mcp".into(), ..McpServerConfig::default() },
)]);
let harness = HarnessAgent::builder("harness")
.model(model)
.workspace(adk_devtools::Workspace::new("."))
.mcp_servers(McpServerSet::operator(servers))
.mcp_interaction(McpInteractionConfig { sampling: true, ..McpInteractionConfig::default() })
.build()?;
McpInteractionConfig field | Default | Meaning |
|---|---|---|
elicitation | true | Prompt or park; false declines |
sampling | false | Whether servers may sample the harness model |
sampling_max_tokens | 4,096 | Cap on max_tokens |
sampling_model | the member model, else the harness model | The model sampling runs on |
idle_sampling | false | A request outside any run is refused |
resources | true | mcp_list_resources and mcp_read_resource are declared |
max_elicitations_per_call | 3 | Per tool call |
max_sampling_per_call | 5 | Per tool call |
| Interaction | Behaviour |
|---|---|
| Elicitation, form | A prompt through the ApprovalPrompter: "MCP server name asks", the message, the schema rendered as typed fields with defaults; the answer is validated against the schema before it is returned; Deny declines, DenyAllRemaining cancels; never remembered as a rule |
| Elicitation, URL | The prompt shows the URL's host and path, screened as a composed URL; the harness never opens it; the person opens it and approves |
| Elicitation without a prompter | An ApprovalRequest named mcp:<server>/elicitation in the approval inbox with allowed_actions = [Edit, Reject] (Edit carries the form answer), risk from the server's trust and the run id; the tool call waits for the decision up to confirmation_timeout, then declines |
| Elicitation without either | Declined |
| Sampling | Runs on the harness model with no tools, max_tokens capped, the server's system prompt delimited as untrusted after one harness line, metered under the run's RunBudget and SpendKey::org(app).with_agent("mcp:<server>"); a request outside any run is refused unless idle_sampling |
| Resources | mcp_list_resources { server } and mcp_read_resource { server, uri }, class Read; contents inside <untrusted-content source="mcp:<server>" uri="…" sha256="…"> |
Elicitations share the prompter's serial mutex and per-turn cap, so a server cannot flood prompts. Nothing a server sends changes its trust, its tools' class or any rule.
adk-rust
| Surface | Behaviour |
|---|---|
--web / --no-web | web_fetch is declared by default; --no-web removes it |
--allow-domain HOST | Repeatable; allow_domains in the user config too; a project file may only turn web off. Hosts web_fetch reads without approval, never a search filter |
[web] search_domains | The search filter, { allowed = [..] } or { blocked = [..] }, in the user config; a project file's narrows it |
/web | The allowlist; /web allow HOST grants a DomainIn rule for web_fetch to the user |
.mcp.json | Servers in the workspace, started once the workspace is trusted |
/mcp | The servers and their status; /mcp resources SERVER lists what one publishes |
@server:uri | In a turn, appends the resource inside its untrusted block, recorded as harness.mcp.resource.read with via: mention; Tab completes the mention from the resources the servers publish, refreshed after each turn and after /mcp resources SERVER |
Audit records
| Action | Fields |
|---|---|
harness.web.fetched | functionCallId, phase (request, response, refused), url, host, finalHost, allowlisted, status, bytes, contentSha256, redirects, truncated, screening, refusal (privateTarget, urlTooLong, secretInQuery, …), urlDigest |
harness.web.searched | provider, queryDigest, site, results, hosts, dropped, filtered (results outside search_domains), refusal |
harness.web.screened | url, contentSha256, patterns, lines, redactions, action |
harness.web.provider_enabled | provider, tool, searchDomains (the filter forwarded, when one was), mode |
harness.mcp.elicited | server, kind, schemaDigest, decision, by, surface (prompt, inbox, none), approvalRequestId |
harness.mcp.sampled | server, spendKey, modelCalls, tokens, costMicroUsd, budgetRemaining, maxTokens, refused |
harness.mcp.resource.read | server, uri, mimeType, bytes, sha256, via (tool, mention) |
Invariants
| Invariant | Test |
|---|---|
I46 One plain GET, the target resolved and classified before connecting and at every redirect | adk-harness/tests/web_tests.rs (private literal, redirect to a private target), web/domain.rs unit tests |
| I47 Fetched text reaches the model only delimited, size-capped, labelled and redacted | web_tests.rs (injection page), web_property_tests.rs (delivered text) |
| I48 A composed URL is capped and refused on a secret pattern, audited by digest | web_tests.rs (secret in query), web_property_tests.rs (secrets and oversized queries) |
| I49 Provider tools attached per provider in Ask or Auto with the search filter where the provider takes it, recorded | web_tests.rs (provider web tools), web_search_default_tests.rs |
| I73 The fetch allowlist is never forwarded as a search filter | web_search_default_tests.rs (the_fetch_allowlist_is_never_a_search_filter), adk-cli/tests/harness_search_cli.rs |
| I50 An elicitation is answered only through the prompter or the inbox, validated, never auto-accepted | adk-harness/tests/mcp_interaction_tests.rs |
| I51 Sampling runs with no tools under the run's budget and the server's spend key | mcp_interaction_tests.rs (sampling) |
I52 Resources enter only through a Read tool or a mention, delimited | mcp_interaction_tests.rs (resources) |
examples/harness_agent runs the H12 scenarios scripted (web_fetch_allowlist_and_screening,
mcp_elicitation_and_sampling) and live (live_web_allowlist).