TagOut: Safe MCP Tool Restriction Without Over-Refusal

TagOut (arXiv:2612.04470) is a training-free three-channel defense for restricted AI agent sessions such as read-only SQL analysts or memory-disabled guest chats. Deriving runtime dispatch, tool schema visibility, and a brief redirect notice from one allowed-tool list, TagOut hits 0% leaked calls, 0% false promises, and 98% constructive redirects.
TagOut: Safe MCP Tool Restriction Without Over-Refusal: TagOut (arXiv:2612.04470) is a training-free three-channel defense for restricted AI agent sessions such as read-only SQL analysts or memory-disabled guest chats. Deriving runtime dispatch, tool schema visibility, and a brief redirect notice from one allowed-tool list, TagOut hits 0% leaked calls, 0% false promises, and 98% constructive redirects. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- Zero Leaked Calls & Zero False Promises: Evaluated across 10,800 live requests on Gemma 4 31B IT and 26B-A4B IT, TagOut eliminates both unauthorized calls and hallucinated success claims.
- 98% Constructive Redirection: Replaces dead-end refusals (62% under composite prompt bans) with actionable alternatives explaining what stays disabled and how to proceed.
- Lower Harmless Over-Refusals Than Unrestricted Agents: Drops OR-Bench-Hard false refusals from 56.7% (4-tool composite ban) and 30.7% (unrestricted) down to 20.7% on 31B.
- 53% Fewer Tool-Prompt Tokens: Pruning unavailable tool schemas from the declaration payload shrinks restricted-session context from 609 tokens to 285 tokens.
import { createAgent } from '@smoke-monkey/harness';// Three-channel TagOut pattern: runtime allowlist + pruned schema + redirect contractconst ALLOWED_READONLY_TOOLS = ['read_file', 'query_readonly_sql'] as const;const agent = createAgent({agentId: 'tagout-readonly-analyst',provider: 'openai-compatible',baseUrl: 'http://127.0.0.1:8000/v1',model: 'google/gemma-4-31b-it',workspacePath: process.cwd(),systemPromptSuffix:'Session restriction: write/memory tools are omitted from your active tool list. Never promise to save or mutate state; offer read-only analysis or copyable SQL instead.',permissions: {read_file: 'allow',write_file: 'deny',run_command: 'deny',},});async function main() {const result = await agent.run('Analyze slow queries in logs/pg.log and suggest an index migration script without modifying files.');console.log('Constructive Output:', result.summary);}main().catch(console.error);
Watch: Related Video Guides
Building a Secure AI Agent with MCP Tools & RBAC
AI Agent Tool Governance: Permission Sandboxes, MCP & Safe Execution (Ch 6)
What Is TagOut and Why Do Prompt Bans and Silent Tool Removal Fail?
TagOut (arXiv:2612.04470) is a training-free permission enforcement architecture that derives three agent channels—runtime tool dispatch, visible tool schema declarations, and system redirect rules—from a single allowed-tool list. Evaluated across guest-session memory, read-only SQL, and cloud operations, it prevents both unauthorized tool execution and over-refusal.
When engineers restrict an MCP session using only a system-prompt ban while leaving the tool schema attached, models still leak calls or over-refuse benign security/coding prompts (driving OR-Bench-Hard false refusals up to 56.7% on Gemma 4 31B). Conversely, silently stripping schemas without telling the model causes 40%–52% false promises where the assistant confidently tells users it saved data or ran an action it could never invoke.
| Configuration (Gemma 4 31B / 26B-A4B) | Prompt Tokens | OR-Bench-Hard False Refusal ↓ | Leaked Call ↓ | False Promise ↓ | Dead End ↓ | Constructive Redirect ↑ |
|---|---|---|---|---|---|---|
| Unrestricted Baseline (4 tools) | 609 | 30.7% / 34.7% | 44.0% / 44.0% | 50.0% / 52.0% | 2.0% / 4.0% | 0.0% / 0.0% |
| Silent Schema Removal (Orig Prompt) | 218 | 28.0% / 32.7% | 52.0% / 36.0% | 40.0% / 52.0% | 2.0% / 4.0% | 0.0% / 0.0% |
| Composite Safety + Tool Ban (4 tools) | 626 | 56.7% / 40.0% | 0.0% / 0.0% | 0.0% / 0.0% | 62.0% / 60.0% | 34.0% / 38.0% |
| TagOut Three-Channel (1 tool) | 285 | 20.7% / 25.3% | 0.0% / 0.0% | 0.0% / 0.0% | 2.0% / 0.0% | 98.0% / 98.0% |
Pre-Dispatch Consistency Checks and Prefix-Cache Stability in MCP Gateways
TagOut enforces pre-dispatch consistency before every LLM completion: the tool-schema array sent to the model must equal the exact intersection of registered MCP tools and the session allowlist, and the redirect notice must reflect only the disabled capability group. Keeping the redirect notice concise preserves prefix-cache alignment while cutting token overhead in half.
# Verify TagOut pre-dispatch invariant in TypeScript/Node MCP proxy
node -e '
const registered = ["memory_save", "memory_search", "sql_read", "sql_write"];
const sessionAllowlist = new Set(["sql_read"]);
const exposedSchemas = registered.filter(t => sessionAllowlist.has(t));
const blockedTools = registered.filter(t => !sessionAllowlist.has(t));
console.log({ exposedSchemas, blockedTools, tokenSavingsEst: (registered.length - exposedSchemas.length) * 110 });
'Never Leave Stale Prompt References to Hidden Tools
If your system prompt instructs the agent to "use memory_save to remember preferences" while memory_save is omitted from the schema list, silent-removal failure rates jump back to 40%+ false promises.
Frequently Asked Questions
Q:Why does banning a tool in the system prompt increase false refusals?
Leaving a banned tool schema visible alongside prohibitive safety language triggers safety-boundary over-generalization, raising OR-Bench-Hard false refusals to 56.7% and causing 62% dead-end refusals on Gemma 4 31B.
Q:What goes wrong with silently hiding MCP tool schemas?
Without a brief redirect notice, the model remains unaware of the session limit and hallucinates successful actions—producing 30% to 52% false promises across restricted requests.
Q:How does TagOut reduce prompt token consumption?
By stripping disallowed tool JSON schemas while keeping only a compact benign-scope redirect rule, TagOut shrinks tool-prompt size from 609 tokens to 285 tokens.
Q:Does TagOut require fine-tuning or RL weights?
No. TagOut is completely training-free and operates purely through runtime allowlist synchronization across dispatch, tool declarations, and system redirect rules.
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.