Skip to content

fix(web-tools): align web_fetch domain matching with spec-correct web_search matcher#209

Merged
stuffbucket merged 1 commit into
mainfrom
fix/web-fetch-domain-matching
Jul 3, 2026
Merged

fix(web-tools): align web_fetch domain matching with spec-correct web_search matcher#209
stuffbucket merged 1 commit into
mainfrom
fix/web-fetch-domain-matching

Conversation

@stuffbucket

Copy link
Copy Markdown
Owner

What

Routes web_fetch's domain policy check through the same spec-correct isHostAllowed matcher that web_search result post-filtering already uses, and deletes the now-unused legacy hostMatches.

Before this change the two tools disagreed on an identical allowed_domains/blocked_domains list: web_fetch used exact-only + *.-glob matching, while web_search (shipped in #205) used subdomain-inclusive matching per Anthropic's server-tools spec.

Why it matters

Concrete leak the old matcher allowed: a client declaring blocked_domains: ["example.com"] on web_fetch and fetching https://tracker.example.com/x — spec says block (subdomain of a blocked domain), old hostMatches allowed it (exact-only). The symmetric allowlist case wrongly rejected legitimate subdomains.

Changes

  • checkDomainPolicy (web_fetch) now delegates to isHostAllowed(host, decl) — subdomains auto-included, blocked-first mutual exclusion, path/wildcard entries matched on host portion. Error semantics unchanged (url_not_allowed).
  • Deleted hostMatches (grep-confirmed no other callers).
  • Added checkFetchPolicy — domain policy test coverage: blocklist/allowlist subdomain inclusion, suffix-lookalike rejection, path-entry host match, and the intentional *.-glob behavior change.

Behavior change

web_fetch clients relying on the old exact-only or *.-glob semantics are affected — intended, aligning both tools with the published spec.

Verification

  • bun run typecheck — pass
  • bun run lint:all — pass, 0 problems
  • bun test tests/web-tools-state.test.ts — 12 pass / 0 fail
  • web-tools executor/agent/stream suites — 49 pass / 0 fail

Closes #208. Refs #205.

…_search matcher

Route checkDomainPolicy (web_fetch) through the shared isHostAllowed
matcher instead of the spec-divergent hostMatches (exact-only + `*.`
glob). Subdomains of a listed domain are now auto-included, suffix
lookalikes rejected, and path/wildcard entries matched on their host
portion — matching web_search post-filtering. Delete the now-unused
hostMatches. Add checkFetchPolicy coverage.

Behavior change: web_fetch clients relying on exact-only or `*.`-glob
semantics are affected; this aligns both tools with the published spec.

Refs #208, #205.
@stuffbucket
stuffbucket merged commit 0cccb40 into main Jul 3, 2026
4 checks passed
@stuffbucket
stuffbucket deleted the fix/web-fetch-domain-matching branch July 7, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(web-tools): align web_fetch domain matching with spec-correct web_search matcher

1 participant