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
| Name | Required | Description | Default |
|---|---|---|---|
| enabled | Yes | 是否启用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); }, });
- src/WhistleClient.ts:704-719 (handler)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; }
- src/index.ts:341-343 (schema)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拦截"), }),
- src/index.ts:21-30 (helper)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), }, ], }; }