Skip to main content
Glama

addRuleToGroup

Add a specified rule to a designated group within the Whistle MCP Server to manage proxy configurations efficiently.

Instructions

将规则添加到分组

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
groupNameYes分组名称
ruleNameYes要添加的规则名称

Implementation Reference

  • The core handler function that executes the logic for adding a rule to a group by making a POST request to Whistle's `/cgi-bin/rules/move-to` endpoint with form data specifying the source rule and target group (prefixed with \r).
    async moveRuleToGroup(ruleName: string, groupName: string): Promise<any> { const formData = new URLSearchParams(); formData.append("clientId", `${Date.now()}-1`); formData.append("from", ruleName); formData.append("to", `\r${groupName}`); // Adding carriage return to denote a group formData.append("group", "false"); // Not moving a group, but a rule const response = await axios.post( `${this.baseUrl}/cgi-bin/rules/move-to`, formData, { headers: { "Content-Type": "application/x-www-form-urlencoded", }, } ); return response.data; }
  • Zod input schema defining the required parameters for the tool: groupName (target group) and ruleName (rule to add).
    parameters: z.object({ groupName: z.string().describe("分组名称"), ruleName: z.string().describe("要添加的规则名称"), }),
  • src/index.ts:159-173 (registration)
    Registers the 'addRuleToGroup' tool in the FastMCP server, including name, description, schema, and a thin execute wrapper that calls the WhistleClient handler and formats the response.
    server.addTool({ name: "addRuleToGroup", description: "将规则添加到分组", parameters: z.object({ groupName: z.string().describe("分组名称"), ruleName: z.string().describe("要添加的规则名称"), }), execute: async (args) => { const result = await whistleClient.moveRuleToGroup( args.ruleName, args.groupName ); return formatResponse(result); }, });
  • Helper function used by the tool's execute to format the response in a standard MCP-compatible 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