renameRule
Renames existing rules in the Whistle MCP Server to help users organize and manage proxy configurations more effectively. Update rule names quickly for streamlined proxy server control.
Instructions
重命名规则
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| newName | Yes | 规则的新名称 | |
| ruleName | Yes | 规则现有名称 |
Implementation Reference
- src/WhistleClient.ts:70-92 (handler)Core handler function that sends a POST request to Whistle's /cgi-bin/rules/rename endpoint to rename a rule, with validation to prevent renaming the 'default' rule.async renameRule(ruleName: string, newName: string): Promise<any> { // Check if trying to rename the default rule if (ruleName.toLowerCase() === "default") { throw new Error("Cannot rename the 'default' rule"); } const formData = new URLSearchParams(); formData.append("clientId", `${Date.now()}-1`); formData.append("name", ruleName); formData.append("newName", newName); const response = await axios.post( `${this.baseUrl}/cgi-bin/rules/rename`, formData, { headers: { "Content-Type": "application/x-www-form-urlencoded", }, } ); return response.data; }
- src/index.ts:69-80 (registration)Registers the 'renameRule' MCP tool with FastMCP, defining name, description, input schema using Zod, and execute function that delegates to WhistleClient instance.server.addTool({ name: "renameRule", description: "重命名规则", parameters: z.object({ ruleName: z.string().describe("规则现有名称"), newName: z.string().describe("规则的新名称"), }), execute: async (args) => { const result = await whistleClient.renameRule(args.ruleName, args.newName); return formatResponse(result); }, });
- src/index.ts:72-75 (schema)Zod schema defining input parameters for the renameRule tool: ruleName and newName as strings.parameters: z.object({ ruleName: z.string().describe("规则现有名称"), newName: z.string().describe("规则的新名称"), }),