Skip to main content
Glama

proxy_mock_response

Create mock HTTP responses for matched requests to simulate API behavior, test error handling, or develop without live backends.

Instructions

Return a mock response for matched requests. Creates a mock rule.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNoHTTP method to match (optional)
url_patternNoURL regex pattern to match (optional)
hostnameNoHostname to match (optional)
statusYesResponse status code
bodyNoResponse body
content_typeNoContent-Type headerapplication/json
priorityNoRule priority (default: 10, high priority)

Implementation Reference

  • The handler and registration for the 'proxy_mock_response' tool. It creates a mock rule using the 'proxyManager'.
    server.tool(
      "proxy_mock_response",
      "Return a mock response for matched requests. Creates a mock rule.",
      {
        method: z.string().optional().describe("HTTP method to match (optional)"),
        url_pattern: z.string().optional().describe("URL regex pattern to match (optional)"),
        hostname: z.string().optional().describe("Hostname to match (optional)"),
        status: z.number().describe("Response status code"),
        body: z.string().optional().default("").describe("Response body"),
        content_type: z.string().optional().default("application/json").describe("Content-Type header"),
        priority: z.number().optional().default(10).describe("Rule priority (default: 10, high priority)"),
      },
      async ({ method, url_pattern, hostname, status, body, content_type, priority }) => {
        try {
          const matcher: RuleMatcher = {};
          if (method) matcher.method = method;
          if (url_pattern) matcher.urlPattern = url_pattern;
          if (hostname) matcher.hostname = hostname;
    
          const handler: RuleHandler = {
            type: "mock",
            status,
            body: body ?? "",
            headers: { "content-type": content_type ?? "application/json" },
          };
    
          const rule = await proxyManager.addRule({
            priority,
            enabled: true,
            description: `Mock ${status} for ${method || "ANY"} ${url_pattern || hostname || "*"}`,
            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