addValueToGroup
Add a specific value to a defined group within the Whistle MCP Server to manage and organize proxy server rules effectively.
Instructions
将值添加到分组
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| groupName | Yes | 分组名称 | |
| valueName | Yes | 要添加的值名称 |
Implementation Reference
- src/index.ts:287-301 (registration)Registers the MCP tool 'addValueToGroup' with FastMCP, including input schema (groupName, valueName), description, and an inline execute handler that delegates to WhistleClient.moveValueToGroup and formats the response.server.addTool({ name: "addValueToGroup", description: "将值添加到分组", parameters: z.object({ groupName: z.string().describe("分组名称"), valueName: z.string().describe("要添加的值名称"), }), execute: async (args) => { const result = await whistleClient.moveValueToGroup( args.valueName, args.groupName ); return formatResponse(result); }, });
- src/WhistleClient.ts:518-535 (handler)Core handler logic for adding/moving a value to a group in Whistle by sending form-encoded POST request to /cgi-bin/values/move-to with from=valueName, to=\rgroupName.async moveValueToGroup(name: string, groupName: string): Promise<any> { const formData = new URLSearchParams(); formData.append("clientId", `${Date.now()}-1`); formData.append("from", name); formData.append("to", `\r${groupName}`); // Adding carriage return to denote a group formData.append("group", "false"); // Not moving a group, but a value const response = await axios.post( `${this.baseUrl}/cgi-bin/values/move-to`, formData, { headers: { "Content-Type": "application/x-www-form-urlencoded", }, } ); return response.data; }
- src/index.ts:290-293 (schema)Zod schema defining input parameters for the tool: groupName and valueName as strings.parameters: z.object({ groupName: z.string().describe("分组名称"), valueName: z.string().describe("要添加的值名称"), }),
- src/index.ts:21-30 (helper)Helper function used by all tools, including addValueToGroup, to format responses as MCP content array with JSON stringified data.function formatResponse(data: any) { return { content: [ { type: "text" as const, text: JSON.stringify(data), }, ], }; }