proxy_add_rule
Add interception rules to capture, modify, or mock HTTP/HTTPS traffic based on URL, method, headers, or body patterns.
Instructions
Add an interception rule with a matcher and handler. Rules are evaluated by priority (ascending), first match wins.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | Yes | Human-readable description of this rule | |
| priority | No | Priority (lower = higher priority, default: 100) | |
| matcher | Yes | Conditions to match requests | |
| handler | Yes | What to do with matched requests |
Implementation Reference
- src/tools/rules.ts:61-79 (handler)The handler implementation for the proxy_add_rule tool, which calls proxyManager.addRule to add the interception rule.
async ({ description, priority, matcher, handler }) => { try { const rule = await proxyManager.addRule({ priority, enabled: true, description, matcher: matcher as RuleMatcher, handler: handler as RuleHandler, }); return { content: [{ type: "text", text: JSON.stringify({ status: "success", rule }), }], }; } catch (e) { return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: String(e) }) }] }; } }, - src/tools/rules.ts:52-60 (registration)The registration of the proxy_add_rule tool within the McpServer using server.tool.
server.tool( "proxy_add_rule", "Add an interception rule with a matcher and handler. Rules are evaluated by priority (ascending), first match wins.", { description: z.string().describe("Human-readable description of this rule"), priority: z.number().optional().default(100).describe("Priority (lower = higher priority, default: 100)"), matcher: matcherSchema.describe("Conditions to match requests"), handler: handlerSchema.describe("What to do with matched requests"), },