Skip to main content
Glama

proxy_rewrite_url

Rewrite URLs in network traffic by matching patterns and replacing them with specified strings, enabling request modification for testing and debugging.

Instructions

Rewrite request URLs matching a pattern. Creates a passthrough rule with body match-replace on the URL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
match_patternYesRegex pattern to match in URLs
replace_withYesReplacement string
hostnameNoLimit to this hostname
priorityNoRule priority (default: 50)

Implementation Reference

  • The tool 'proxy_rewrite_url' is registered and implemented in src/tools/modification.ts. It configures a passthrough rule that applies a match-replace transformation on the request URL.
    server.tool(
      "proxy_rewrite_url",
      "Rewrite request URLs matching a pattern. Creates a passthrough rule with body match-replace on the URL.",
      {
        match_pattern: z.string().describe("Regex pattern to match in URLs"),
        replace_with: z.string().describe("Replacement string"),
        hostname: z.string().optional().describe("Limit to this hostname"),
        priority: z.number().optional().default(50).describe("Rule priority (default: 50)"),
      },
      async ({ match_pattern, replace_with, hostname, priority }) => {
        try {
          const matcher: RuleMatcher = {};
          if (hostname) matcher.hostname = hostname;
          matcher.urlPattern = match_pattern;
    
          const handler: RuleHandler = {
            type: "passthrough",
            transformRequest: {
              matchReplaceBody: [[match_pattern, replace_with]],
            },
          };
    
          const rule = await proxyManager.addRule({
            priority,
            enabled: true,
            description: `URL rewrite: ${match_pattern} → ${replace_with}`,
            matcher,
            handler,
          });
    
          return {
            content: [{
              type: "text",
              text: JSON.stringify({ status: "success", rule_id: rule.id, description: rule.description }),
            }],
          };
        } catch (e) {
          return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: String(e) }) }] };
        }
      },
    );
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/yfe404/proxy-mcp'

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