removeRuleFromGroup
Remove a specific rule from its group using the Whistle MCP Server. This tool enables precise management of proxy server rules by isolating and deleting unwanted configurations.
Instructions
将规则移出分组
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ruleName | Yes | 规则名称 |
Implementation Reference
- src/index.ts:175-185 (registration)Registration of the 'removeRuleFromGroup' MCP tool, including schema definition, description, and thin inline handler that delegates to WhistleClient.moveRuleOutOfGroup
server.addTool({ name: "removeRuleFromGroup", description: "将规则移出分组", parameters: z.object({ ruleName: z.string().describe("规则名称"), }), execute: async (args) => { const result = await whistleClient.moveRuleOutOfGroup(args.ruleName); return formatResponse(result); }, }); - src/WhistleClient.ts:309-329 (handler)Core handler logic: Moves the specified rule out of any group by repositioning it next to the first rule in the top-level list via POST to Whistle's /cgi-bin/rules/move-to endpoint.
async moveRuleOutOfGroup(ruleName: string): Promise<any> { const rules = await this.getRules(); const firstRuleName = rules.list[0].name; const formData = new URLSearchParams(); formData.append("clientId", `${Date.now()}-1`); formData.append("from", ruleName); formData.append("to", firstRuleName); formData.append("group", "false"); const response = await axios.post( `${this.baseUrl}/cgi-bin/rules/move-to`, formData, { headers: { "Content-Type": "application/x-www-form-urlencoded", }, } ); return response.data; } - src/index.ts:178-180 (schema)Zod schema for tool input: requires 'ruleName' string parameter.
parameters: z.object({ ruleName: z.string().describe("规则名称"), }), - src/index.ts:21-30 (helper)Helper function used by the tool handler to format responses in MCP-expected structure.
function formatResponse(data: any) { return { content: [ { type: "text" as const, text: JSON.stringify(data), }, ], }; }