Skip to content

All posts

AI

How to deny specific MCP tools in Claude Code

Ritesh Patel

AI: How to deny specific MCP tools in Claude Code

To deny one MCP tool in Claude Code, add a deny rule with its full name, mcp__<server>__<tool>, to the deny array in a settings file. To deny every tool from a server, use mcp__<server>__*. Deny rules are checked before allow rules, and a tool denied at any settings level cannot be re-enabled by another level.

Checked against the Claude Code permissions and MCP documentation as fetched on 2026-11-29. Those pages don’t name a CLI version for these rules, so confirm the behavior against your installed release.

How MCP rule names are written

An MCP rule starts with mcp__, then the server name, two underscores, and the tool name. The permissions docs give three forms. mcp__puppeteer matches any tool from the puppeteer server. mcp__puppeteer__* uses wildcard syntax for the same set. mcp__puppeteer__puppeteer_navigate matches only the puppeteer_navigate tool.

Characters such as . or a space in a server name become _ in the rule. A server configured as my.server is written mcp__my_server__*. A server that a plugin provides takes the scoped form mcp__plugin_<plugin-name>_<server-name>__<tool-name>, so the database-tools server in a plugin named my-plugin is written mcp__plugin_my-plugin_database-tools__*. The MCP docs use the same scoped naming for these tools. Use the full name in permission rules, not the bare server key.

Deny one tool

  1. Write the rule with the server name as it appears in that server’s tool names, then the tool name: mcp__<server>__<tool>.
  2. Open the settings file for the scope you want. Rules from every settings level combine, so a deny in any level still applies.
  3. Add the rule to the deny array, as in the block below.
  4. Save the file, then run /permissions. The dialog lists all permission rules and the settings.json file each rule comes from.
{
  "permissions": {
    "deny": [
      "mcp__puppeteer__puppeteer_navigate"
    ]
  }
}

Deny every tool from one server

Use the wildcard form when a whole server is out of scope. mcp__puppeteer__* matches every tool from the puppeteer server, so you don’t list each tool. Put it in the same deny array as any single-tool rules you need.

{
  "permissions": {
    "deny": [
      "mcp__puppeteer__*"
    ]
  }
}

Server names that contain __, or that end in _, need care. The permissions page gives this example: for a server named reports__v2, write mcp__reports__v2__*. As a deny rule, the bare mcp__reports__v2 and the shorter mcp__reports each also cover every tool of reports__v2. To cover a server named reports alone, write one rule per tool in the mcp__reports__<tool> form, or rename one of the servers.

What a deny rule removes

A deny rule that names a whole tool works differently from a rule that matches part of one. The permissions docs say a bare tool name such as Bash removes the tool from Claude’s context, so Claude never sees it. A scoped rule leaves the tool available and blocks only the matching calls. The table shows how the MCP forms fall.

Rule form Example What Claude sees What is blocked
Full tool name mcp__puppeteer__puppeteer_navigate Not stated for MCP names in the permissions docs; confirm in a session Every call to the tool
Server wildcard mcp__puppeteer__* The docs state this for tool-name globs such as mcp__*. They don’t name mcp__puppeteer__*; confirm in a session Every call to those tools
Parameter match A param:value rule passed with --disallowedTools Not in a settings file; see the parameter section below Only calls whose parameter matches

Match a parameter value

To block one argument value on an MCP tool, the permissions page says to pass a deny rule with the --disallowedTools flag. A settings file can’t hold that rule. When Claude Code loads a settings file, it skips any mcp__ rule that has parentheses, and it lists the skipped rule in the invalid-settings dialog and in claude doctor output.

The parameter must be a direct field of the tool’s input, so nested fields can’t be matched. The value matches exactly unless you use *, which matches any sequence of characters. A parameter the model leaves out is never matched. The docs also warn that a rule matching the tool’s primary content field, such as command for Bash, is ignored, because a compound command could bypass it.

How allow and deny interact

Claude Code evaluates rules in this order: deny, then ask, then allow. The first match decides, and a narrower allow rule doesn’t change that order. A deny rule in one scope blocks an allow in another, so a user-level deny blocks a project-level allow. A deny in managed settings can’t be overridden by --allowedTools, while --disallowedTools can add restrictions beyond managed settings.

A checklist before you ship a deny

  1. Use the full tool name or the server wildcard. Check the _ mapping for any server name with a dot, a space or a double underscore.
  2. Use a bare name or wildcard when the tool should disappear from Claude’s context. Use a parameter rule only when the tool must stay available.
  3. Run /permissions and confirm each rule shows the settings file you expect.
  4. Read the startup warnings and the claude doctor output for rules that were skipped or match no tool.
  5. Check for allow rules in other scopes. A deny anywhere wins, so an allow elsewhere does not restore the tool.

For a view of which servers can connect at all, read how to restrict which MCP servers Claude Code can use. To decide which tools belong on a deny list first, read how to classify MCP tools by risk.

Enforcing this with AIControls

The rules in this post are Claude Code’s own settings, so they apply on the machine where Claude Code runs. This post makes no AIControls claim about tool-level denies. For the wider MCP control plan, including which servers reach developers at all, see the MCP security page. The AIControls coding agents page covers the coding agent product.

Frequently asked questions

Does denying one MCP tool in Claude Code block the whole server?

No. A rule with a full name, such as mcp__puppeteer__puppeteer_navigate, matches that one tool and nothing else from the puppeteer server. The other tools from that server stay available unless you add a rule for them or use the server wildcard, mcp__puppeteer__*. Open /permissions after you save the rule to confirm which rules are active and which settings file each one comes from.

Does a denied MCP tool disappear from Claude's context?

It depends on the rule form. A bare tool name removes the tool from Claude's context, so Claude never sees it. The permissions docs state this for tool-name globs such as `mcp__*`, but do not say whether a full MCP name or `mcp__server__*` does the same, so check the session after you add one. A parameter rule is passed with --disallowedTools, not in a settings file.

Which wins when an allow rule and a deny rule both match an MCP tool?

The deny rule wins. Claude Code evaluates deny rules first, then ask rules, then allow rules, and an allow rule cannot carve an exception out of a deny rule. A deny in one settings scope also blocks an allow in another, and a deny in managed settings cannot be overridden by --allowedTools.

Why does Claude Code warn about my MCP deny rule?

Claude Code warns when a deny or ask rule names a tool that matches no known tool, which catches typos. Settings files also skip any mcp__ rule that has parentheses, and the invalid-settings dialog and claude doctor output list the skipped rules.

Can I deny one parameter value of an MCP tool in a settings file?

Not with a parentheses rule in settings.json. Claude Code skips mcp__ rules that have parentheses when it loads a settings file. The permissions docs say to pass a parameter deny rule with the --disallowedTools flag instead. The parameter must be a direct field of the tool's input, and the value matches exactly unless you include an asterisk.

Ritesh Patel, Founder & VP Product, Nirmata

Ritesh Patel is a founder of Nirmata and leads its products. He writes about governing AI coding agents, MCP security and Kubernetes policy as code.

LinkedIn

Govern AI agents with AIControlsControl what AI agents do, and prove it.
Share

Stay up-to-date with the latest in AI, governance, and infrastructure

Subscribe to our free monthly newsletter to get industry news, DevOps tips, and articles right to your inbox on Kyverno, containerization, Kubernetes deployment & management and more.