Skip to main content
Glama

toggleHttpInterception

Enable or disable HTTP interception to manage network requests, monitor traffic, and control proxy settings using the whistle-mcp server.

Instructions

启用或禁用HTTP拦截

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
enabledYes是否启用HTTP拦截

Implementation Reference

  • src/index.ts:338-348 (registration)
    Registration of the 'toggleHttpInterception' MCP tool using FastMCP's server.addTool method. Includes input schema validation with Zod and a thin execute handler that delegates to WhistleClient.toggleHttpsInterception.
    server.addTool({
      name: "toggleHttpInterception",
      description: "启用或禁用HTTP拦截",
      parameters: z.object({
        enabled: z.boolean().describe("是否启用HTTP拦截"),
      }),
      execute: async (args) => {
        const result = await whistleClient.toggleHttpsInterception(args.enabled);
        return formatResponse(result);
      },
    });
  • Core handler function implementing the HTTP interception toggle logic. Sends a POST request to Whistle's `/cgi-bin/intercept-https-connects` endpoint with the `interceptHttpsConnects` parameter set to '1' (enabled) or '0' (disabled). Called directly by the tool's execute function.
    async toggleHttpsInterception(enabled: boolean): Promise<any> {
      const formData = new URLSearchParams();
      formData.append("clientId", `${Date.now()}-${Math.floor(Math.random() * 100)}`);
      formData.append("interceptHttpsConnects", enabled ? "1" : "0");
    
      const response = await axios.post(
        `${this.baseUrl}/cgi-bin/intercept-https-connects`,
        formData,
        {
          headers: {
            "Content-Type": "application/x-www-form-urlencoded",
          },
        }
      );
      return response.data;
    }
  • Zod schema for input validation: requires a boolean 'enabled' parameter indicating whether to enable or disable HTTP interception.
    parameters: z.object({
      enabled: z.boolean().describe("是否启用HTTP拦截"),
    }),
  • Helper function used by the tool's execute handler to format the response in MCP-compatible structure with JSON-stringified content.
    function formatResponse(data: any) {
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify(data),
          },
        ],
      };
    }

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/7gugu/whistle-mcp'

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