Skip to main content
Glama

add_interception_rule

Modify HTTP traffic on the fly by adding interception rules: inject headers, replace request/response bodies, or block URLs. Proxy must be running.

Instructions

Add a rule that modifies HTTP traffic in real-time as it passes through the mitmproxy.

PREREQUISITE: Proxy must be running (call manage_proxy(action="start") first).

NOTE: These rules apply to ALL traffic through the proxy (browser + code-mode + replay). Rules are cached for ~5 seconds, so changes are not instant. For instant browser-only interception, use browser_intercept_request/response instead.

Available actions:

  • "inject_header": Add/override a header. Requires key and value. Example: add_interception_rule(url_pattern=".api.", action="inject_header", key="X-Admin", value="true")

  • "replace_body": Find and replace text in the body. Requires search_pattern and value. Example: add_interception_rule(url_pattern=".*", action="replace_body", search_pattern="false", value="true", resource_type="response")

  • "block": Block matching requests entirely. Example: add_interception_rule(url_pattern=".analytics.", action="block")

Args: url_pattern: Regex pattern to match URLs (e.g. ".api.target.com.", ".*.js$") action: "inject_header", "replace_body", or "block" resource_type: "request" or "response" (default: "request") key: Header name (required for inject_header only) value: Header value (for inject_header) or replacement text (for replace_body) search_pattern: Regex to find in body (required for replace_body only) method: Only match this HTTP method, e.g. "POST" (optional, matches all methods if omitted)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyNo
valueNo
actionYes
methodNo
url_patternYes
resource_typeNorequest
search_patternNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully carries the behavioral transparency burden. It discloses that rules affect all traffic, are cached for ~5 seconds, and explains default resource_type behavior. Also details the semantics of each action (inject_header, replace_body, block) including required parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Despite its length, the description is exceptionally well-structured with clear sections (purpose, prerequisites, actions, args) and examples. Every sentence adds value; no redundancy or filler—a model of how to document a complex tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers purpose, usage, parameters, examples, and alternatives comprehensively. With an output schema present, the description need not explain return values. Fully complete for a 7-parameter tool with multiple action variants.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description compensates comprehensively by explaining all seven parameters, their required conditions, defaults, and examples. Goes far beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the tool's function: adding a rule to modify HTTP traffic in real-time through mitmproxy. Distinguishes from sibling tools like browser_intercept_request/response by noting its broader applicability to all traffic.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit prerequisite (proxy must be running), scope (applies to ALL traffic), and alternatives (browser_intercept_request/response for instant browser-only). Includes examples for each action, making usage guidelines highly actionable.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/BobongKu/nodriver-proxy-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server