Skip to main content
Glama

disableRule

Disable specific proxy rules in Whistle MCP Server by providing the rule name, allowing precise control over network request management.

Instructions

禁用规则

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ruleNameYes规则名称

Implementation Reference

  • The main handler function that implements disabling a rule. It retrieves the rule details, constructs form data, and sends a POST request to Whistle's API endpoint (/cgi-bin/rules/unselect or /disable-default) to unselect/disable the specified rule.
    async unselectRule(ruleName: string): Promise<any> { const rules = await this.getRules(); if (!rules) { throw new Error("No rules found"); } const isDefaultRule = ruleName.toLowerCase() === "default"; let ruleContent; if (isDefaultRule) { ruleContent = rules.defaultRules; } else { const rule = rules.list.find((rule: any) => rule.name === ruleName); if (!rule) { throw new Error(`Rule with name '${ruleName}' not found`); } ruleContent = rule.data; } const formData = new URLSearchParams(); formData.append("clientId", `${Date.now()}-0`); formData.append("name", ruleName); formData.append("value", ruleContent); formData.append("selected", "true"); formData.append("active", "true"); formData.append("key", `w-reactkey-${Math.floor(Math.random() * 1000)}`); formData.append("hide", "false"); formData.append("changed", "true"); const endpoint = isDefaultRule ? `${this.baseUrl}/cgi-bin/rules/disable-default` : `${this.baseUrl}/cgi-bin/rules/unselect`; const response = await axios.post(endpoint, formData, { headers: { "Content-Type": "application/x-www-form-urlencoded", }, }); return response.data; }
  • src/index.ts:106-116 (registration)
    Registers the disableRule tool with the FastMCP server, specifying its name, description, input schema, and execute function that delegates to WhistleClient.unselectRule and formats the response.
    server.addTool({ name: "disableRule", description: "禁用规则", parameters: z.object({ ruleName: z.string().describe("规则名称"), }), execute: async (args) => { const result = await whistleClient.unselectRule(args.ruleName); return formatResponse(result); }, });
  • Zod schema for the disableRule tool input, requiring a 'ruleName' string parameter.
    parameters: z.object({ ruleName: z.string().describe("规则名称"), }),
  • Helper function used by disableRule (and other tools) to format responses in the expected MCP content structure.
    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