getRules
Retrieve all rules and groupings from the Whistle MCP Server to manage proxy settings, monitor network requests, and streamline proxy server operations.
Instructions
获取所有规则&分组
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:37-40 (handler)The execute handler for the 'getRules' MCP tool. It calls whistleClient.getRules() to fetch the rules and wraps the result using formatResponse.execute: async () => { const rules = await whistleClient.getRules(); return formatResponse(rules); },
- src/index.ts:33-41 (registration)Registration of the 'getRules' tool using FastMCP server's addTool method, including name, description, empty input schema, and inline handler.server.addTool({ name: "getRules", description: "获取所有规则&分组", parameters: z.object({}), execute: async () => { const rules = await whistleClient.getRules(); return formatResponse(rules); }, });
- src/index.ts:36-36 (schema)Zod schema for input parameters of getRules tool (empty object, no parameters required).parameters: z.object({}),
- src/WhistleClient.ts:15-18 (helper)Core helper method in WhistleClient that performs the HTTP GET request to Whistle's /cgi-bin/rules/list endpoint to retrieve all rules and groups.async getRules(): Promise<any> { const response = await axios.get(`${this.baseUrl}/cgi-bin/rules/list`); return response.data; }
- src/index.ts:21-30 (helper)Utility function used by all tools to format responses in MCP-compatible structure with JSON-stringified data.function formatResponse(data: any) { return { content: [ { type: "text" as const, text: JSON.stringify(data), }, ], }; }