Skip to main content
Glama

updateRule

Modify rule content on the Whistle MCP Server to manage proxy settings, enabling precise control over network request rules and configurations.

Instructions

更新规则内容

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ruleNameYes规则名称
ruleValueYes规则内容

Implementation Reference

  • MCP handler implementation for the 'updateRule' tool, including inline schema validation via Zod and delegation to WhistleClient.updateRule
    server.addTool({ name: "updateRule", description: "更新规则内容", parameters: z.object({ ruleName: z.string().describe("规则名称"), ruleValue: z.string().describe("规则内容"), }), execute: async (args) => { const { ruleName, ruleValue } = args; const result = await whistleClient.updateRule(ruleName, ruleValue); return formatResponse(result); }, });
  • Supporting helper method in WhistleClient that implements the core logic for updating a Whistle rule by posting form data to the appropriate Whistle API endpoint (enable-default for default rule, select for others)
    async updateRule(ruleName: string, ruleValue: string): Promise<any> { const isDefaultRule = ruleName.toLowerCase() === "default"; const formData = new URLSearchParams(); formData.append("clientId", `${Date.now()}-0`); formData.append("name", ruleName); formData.append("value", ruleValue); formData.append("selected", "true"); formData.append("active", "true"); formData.append("key", `w-reactkey-${Math.floor(Math.random() * 1000)}`); // Generate a random key formData.append("hide", "false"); formData.append("changed", "true"); const endpoint = isDefaultRule ? `${this.baseUrl}/cgi-bin/rules/enable-default` : `${this.baseUrl}/cgi-bin/rules/select`; const response = await axios.post(endpoint, formData, { headers: { "Content-Type": "application/x-www-form-urlencoded", }, }); return response.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