skip to content

How do Claude Code permission rules name a web domain and an MCP server's tools, and where may wildcards appear in each?

level: middleimportance: nice to knowfreq 8%

answer

  1. a prefix inside the parentheses
  2. apex is not a subdomain
  3. double underscores, server first
  4. allow globs need an anchor

basics

~10 s

Web fetches use WebFetch(domain:host), where *.example.com covers subdomains but not example.com itself; MCP tools use mcp__server or mcp__server__tool, and an allow glob must follow a literal mcp__server__ prefix.

solid answer

~40 s

`WebFetch(domain:example.com)` matches the hostname of the requested URL, case-insensitively. `*.example.com` matches subdomains at any depth but not the apex, and a wildcard anywhere else matches only text between two dots, so `example.*` matches `example.org` but not `example.evil.com`. A bare `WebFetch` rule and `WebFetch(domain:*)` both cover every URL but differ: as a deny, the bare form removes the tool, while the domain form keeps it and refuses each fetch. MCP rules use the server name as configured: `mcp__tracker` or `mcp__tracker__*` covers every tool of that server, `mcp__tracker__create_issue` one tool. Deny and ask rules may glob the whole name, so `mcp__*` denies every MCP tool, but an allow glob works only after a literal `mcp__<server>__` prefix; `mcp__*` in allow is skipped with a warning.

go deeper

for a junior

Recall the two shapes: WebFetch(domain:host) for web fetches and mcp__server or mcp__server__tool for MCP tools.

for a middle

Explain the wildcard rules: *.example.com excludes the apex, mid-name wildcards stay between dots, and MCP allow globs need a literal server prefix.

for a senior

Spot silent failures: an unanchored allow glob that approves nothing, a parenthesised MCP rule skipped at load, and a WebFetch allowlist that Bash curl walks around.

for a principal

Decide which servers and domains get blanket allows, which tools stay behind ask, and when a network policy must move to the sandbox instead of tool rules.

## Two rule forms outside Bash and file paths Claude Code permission rules have the shape `Tool` or `Tool(specifier)`. Bash rules match command text and Read or Edit rules match gitignore-style paths, but two other forms come up constantly: **web fetches** and **tools from MCP servers**. Each has its own rules about where a `*` may go, and getting one character wrong either approves too much or silently approves nothing. ## WebFetch rules A WebFetch rule uses a `domain:` prefix and is compared with the **hostname** of the requested URL. Matching is case-insensitive, and a trailing `.` is stripped from both sides, so `example.com.` equals `example.com`. | Rule | Matches | Does not match | | :- | :- | :- | | `WebFetch(domain:example.com)` | `example.com` | `api.example.com` | | `WebFetch(domain:*.example.com)` | `api.example.com`, `a.b.example.com` | `example.com` itself | | `WebFetch(domain:example.*)` | `example.org` | `example.evil.com` | | `WebFetch(domain:*)` | every host | nothing | The third row is a safety feature: a wildcard other than a leading `*.` or a bare `*` matches only the text between two dots, so a trailing wildcard cannot match a domain an attacker could register. ### Bare `WebFetch` against `domain:*` Both cover every URL, yet they behave differently: - In **deny**, a bare `WebFetch` removes the tool from Claude's context entirely, while `WebFetch(domain:*)` keeps the tool and refuses each fetch. - Only the `domain:` form is also copied into the sandbox's allowed or denied domain list; the bare form leaves sandboxed shell commands' network access unchanged. Without any rule, Manual and `acceptEdits` modes prompt before a fetch, except for a built-in set of preapproved documentation domains. An explicit `WebFetch(domain:...)` rule in any list overrides that set, so you can block or force a prompt for a preapproved domain. **WebFetch rules govern one tool.** If Bash is allowed, `curl` and `wget` can still reach any URL; a WebFetch allowlist is not a network policy on its own. ## MCP rules Tools from an MCP server are named `mcp__<server>__<tool>`, where the server name is the one configured in Claude Code. Rules use the same names: - `mcp__tracker` matches every tool from the `tracker` server. - `mcp__tracker__*` matches the same set with wildcard syntax. - `mcp__tracker__create_issue` matches that one tool. - `mcp__tracker__get_*` matches the server's tools whose names start with `get_`. ### Where an MCP wildcard may go 1. **Deny and ask rules** accept a glob over the whole tool name. `"mcp__*"` in deny removes every MCP tool from every server. 2. **Allow rules** accept a glob only **after a literal `mcp__<server>__` prefix**, and the server segment must be glob-free so the rule names a server you configured. An unanchored allow glob such as `"mcp__*"` is skipped with a warning and approves nothing. 3. **Parentheses are not an MCP specifier in settings files.** Claude Code skips any `mcp__` rule with parentheses when loading a settings file and lists it as invalid; parameter-level deny rules for MCP tools go through `--disallowedTools` instead. Two cases override an allow rule regardless: a tool the server marks as requiring user interaction still prompts, and a claude.ai connector tool your organization set to `ask` prompts on every call. ## Putting it together ```json { "permissions": { "allow": [ "WebFetch(domain:docs.example.com)", "mcp__tracker__get_*" ], "ask": ["mcp__tracker__create_issue"], "deny": ["WebFetch(domain:*.paste.example.com)"] } } ``` This lets Claude read one documentation host and call the tracker's read tools freely, prompts before it files an issue, and refuses fetches to any subdomain of the paste host. Because deny is checked before ask and ask before allow, the order of the arrays in the file does not matter. ## Common mistakes - **Forgetting the apex.** Allowing `*.example.com` alone leaves `example.com` prompting; list both when both are wanted. - **Typing the server name differently.** The rule must use the server name exactly as it is configured in Claude Code, not the vendor’s product name. - **Using a display label.** Rules match canonical tool names, not the label shown in the transcript. - **Expecting an allow to silence every prompt.** Tools flagged as requiring user interaction, and organization-set connector asks, keep prompting. ## Why it is asked These rules are where web and third-party tool access is actually set, so a reviewer must spot an apex domain left uncovered, an allow glob that silently does nothing, and a WebFetch allowlist mistaken for a network boundary.

  • Why does `"mcp__*"` work in deny but not in allow?
    A deny or ask glob only restricts, so matching every MCP tool is safe. An allow glob grants, and Claude Code requires it to name a specific configured server: the glob may appear only after a literal `mcp__<server>__` prefix. An unanchored allow such as `"mcp__*"` is skipped with a startup warning, so it approves nothing and every MCP call keeps prompting.
  • Does allowing only `WebFetch(domain:docs.example.com)` keep Claude off the rest of the internet?
    No. The rule governs the WebFetch tool alone. If Bash commands are allowed, `curl` or `wget` can reach any host, and a Bash deny on them matches only the usual spelling. A network restriction that must hold needs the sandbox's domain allowlist, which the `domain:` form of a WebFetch rule also feeds.

  • WebFetch(domain:*.example.com) also covers example.com itself
  • An allow rule of mcp__* approves every MCP tool
  • A WebFetch domain allowlist stops curl from reaching other hosts
  • Bare WebFetch and WebFetch(domain:*) behave identically in deny
  • MCP rules take the tool's arguments in parentheses in settings.json