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.

FeatureDefaultAdds
weboff in the library, on in adk-rustweb_fetch, web search (the model provider's built-in search, or web_search over a SearchProvider), screening, ProviderWebTools, SearxngSearch, DeepSeekSearch
mcpoff in the library, on in adk-rustthe elicitation, sampling and resource bridges; mcp_list_resources, mcp_read_resource
web-fixtureoffa 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

ToolDeclarationClassBehaviour
web_fetch{ url, max_bytes?, as?: "text" | "markdown" }Web { allowlisted } from the URL's hostOne 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 absentRuns 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

ClassReadOnlyPlanAskAuto
Web, allowlisted hostAllowAllowAllowAllow
Web, other hostDenyDenyRequireApprovalRequireApproval

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 fieldDefaultMeaning
allowed_domainsemptyHosts 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_domainsNone: every domainThe 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_provenanceUrlProvenance::UnattendedWhen a fetched URL must already appear in the conversation; see URL provenance
url_sourcesuser messages and every tool result except bash and shell_outputWhich parts of the conversation count for url_provenance (adk_core::egress::UrlSources)
search_domainsNone: every domainThe search filter (spec 3.1 §7.32): SearchDomains::Allowed(..) or SearchDomains::Blocked(..), each entry covering the domain and its subdomains; see Search scope
max_bytes1 MiBRead on the wire; 64 KiB of text are delivered, the rest cut with a marker
max_url_len2,048Longest URL sent
max_query_len512Longest search query
timeout20 sPer request
max_redirects5Followed within one call
max_fetches_per_turn20Further fetches of the turn are refused with harness.web.turn_cap
user_agentadk-harness/<version>The User-Agent header

Rules

RuleMechanism
GET only, no body, no credentialsThe harness's own reqwest client: no cookie store, no proxy from the environment, no credential from the broker; a new client per request
ResolutionThe 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
RedirectsFollowed 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
Contenttext/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
ScreeningInjection 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
ExfiltrationA 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.

UrlProvenanceThe rule applies
OffNever
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
AlwaysIn 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 resourcesYes (user_input)
Tool results, by tool nameEvery one except bash and shell_output by default (tool_results: All, None, Only(..) or Except(..))
The provider's built-in search and fetch resultsUnder All and Except(..)
Model text, thinking and tool calls, and the system instructionNever
MatchingRule
NormalizationScheme 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 pathCompared exactly: a URL with data appended to its query or path is a different URL
Bare hostsIn user text, docs.rs/serde admits https://docs.rs/serde and http://docs.rs/serde
Links on a fetched pageWritten as absolute URLs in as: "markdown", so a link the page gives is fetchable as written
RedirectsChosen 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.

LimitMitigation
A tool that echoes model text launders a URL: a shell that prints what a command built, a file the model wrote and read backThe 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 channelmax_fetches_per_turn bounds it
A call held for approval in Auto mode is put to the approver before the tool applies the ruleThe 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.

HarnessAgentBuilder::web(..) turns web search on with web_fetch. Search runs on one of two paths, chosen at build (spec 3.1 §7.20):

ConfigurationPathGoverned
.web(..) alone (the default)The search built-in of the provider the model's client servesNo: the search runs inside the model; the run records it afterwards
.web(..) and .search_provider(..)The governed web_search over that providerYes: 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.

SettingMeaning
WebConfig::allowed_domainsHosts web_fetch and the browser pack's navigation reach without approval; never forwarded to a search
WebConfig::search_domainsThe 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)
SearchAllowed(..)Blocked(..)
Anthropic web_searchForwarded as allowed_domainsForwarded as blocked_domains
OpenAI openai_web_searchForwarded as filters.allowed_domainsNot applied: the banner says OpenAI takes no such filter
Gemini google_search, DeepSeek deepseek_web_searchNot applied: the banner says the provider takes no search filterNot applied
The governed web_searchResults outside the list are dropped, counted as filteredResults 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 is read from the model's client through Llm::native_web_search(), never from what the model writes:

ClientBuilt-inDeclared asSearch filter
GeminiModel (generateContent, Gemini API or Vertex AI)GoogleSearchToolgoogle_searchNone: every domain, and the request banner says Gemini takes no search filter when one is configured
GeminiModel on the Interactions transportNone—The transport refuses a built-in tool beside function tools
AnthropicClient on api.anthropic.comWebSearchToolweb_searchallowed_domains or blocked_domains
AnthropicClient on DeepSeek's Anthropic endpoint (https://api.deepseek.com/anthropic)WebSearchToolweb_searchNone documented: every domain
OpenAIResponsesClient on api.openai.comOpenAIWebSearchToolopenai_web_searchfilters.allowed_domains
OpenAIResponsesClient on https://api.deepseek.com with deepseek-v4-proDeepSeekWebSearchTooldeepseek_web_searchNone documented: every domain
OpenAIClient (Chat Completions), DeepSeekClient, OllamaModel, GroqClient, BedrockClient, mistral.rs, any other endpointNone—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):

GuardMechanism
ModeDeclared 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 filterWebConfig::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)
BannerEach request of the run names the live built-ins and says web_fetch is the governed path
RefusalA 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
Recordsharness.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

ProviderConfigureBehaviour
SearxngSearch::new(url)The instance's base URL; the instance lists json under search.formats in settings.ymlGET <url>/search?q=…&format=json; no key
DeepSeekSearch::from_env() / DeepSeekSearch::new(key)DEEPSEEK_API_KEYPOST 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 fieldDefaultMeaning
elicitationtruePrompt or park; false declines
samplingfalseWhether servers may sample the harness model
sampling_max_tokens4,096Cap on max_tokens
sampling_modelthe member model, else the harness modelThe model sampling runs on
idle_samplingfalseA request outside any run is refused
resourcestruemcp_list_resources and mcp_read_resource are declared
max_elicitations_per_call3Per tool call
max_sampling_per_call5Per tool call
InteractionBehaviour
Elicitation, formA 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, URLThe 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 prompterAn 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 eitherDeclined
SamplingRuns 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
Resourcesmcp_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

SurfaceBehaviour
--web / --no-webweb_fetch is declared by default; --no-web removes it
--allow-domain HOSTRepeatable; 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_domainsThe search filter, { allowed = [..] } or { blocked = [..] }, in the user config; a project file's narrows it
/webThe allowlist; /web allow HOST grants a DomainIn rule for web_fetch to the user
.mcp.jsonServers in the workspace, started once the workspace is trusted
/mcpThe servers and their status; /mcp resources SERVER lists what one publishes
@server:uriIn 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

ActionFields
harness.web.fetchedfunctionCallId, phase (request, response, refused), url, host, finalHost, allowlisted, status, bytes, contentSha256, redirects, truncated, screening, refusal (privateTarget, urlTooLong, secretInQuery, …), urlDigest
harness.web.searchedprovider, queryDigest, site, results, hosts, dropped, filtered (results outside search_domains), refusal
harness.web.screenedurl, contentSha256, patterns, lines, redactions, action
harness.web.provider_enabledprovider, tool, searchDomains (the filter forwarded, when one was), mode
harness.mcp.elicitedserver, kind, schemaDigest, decision, by, surface (prompt, inbox, none), approvalRequestId
harness.mcp.sampledserver, spendKey, modelCalls, tokens, costMicroUsd, budgetRemaining, maxTokens, refused
harness.mcp.resource.readserver, uri, mimeType, bytes, sha256, via (tool, mention)

Invariants

InvariantTest
I46 One plain GET, the target resolved and classified before connecting and at every redirectadk-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 redactedweb_tests.rs (injection page), web_property_tests.rs (delivered text)
I48 A composed URL is capped and refused on a secret pattern, audited by digestweb_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, recordedweb_tests.rs (provider web tools), web_search_default_tests.rs
I73 The fetch allowlist is never forwarded as a search filterweb_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-acceptedadk-harness/tests/mcp_interaction_tests.rs
I51 Sampling runs with no tools under the run's budget and the server's spend keymcp_interaction_tests.rs (sampling)
I52 Resources enter only through a Read tool or a mention, delimitedmcp_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).