getWhistleStatus
Check the current operational status of the Whistle proxy server. Use this tool to monitor and manage proxy settings, rules, and network requests efficiently.
Instructions
获取whistle服务器的当前状态
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:316-324 (registration)Registration of the 'getWhistleStatus' tool with FastMCP server. Includes schema (empty input parameters), description, and the primary handler function that calls WhistleClient.getStatus() and formats the response.server.addTool({ name: "getWhistleStatus", description: "获取whistle服务器的当前状态", parameters: z.object({}), execute: async () => { const status = await whistleClient.getStatus(); return formatResponse(status); }, });
- src/WhistleClient.ts:562-579 (handler)Core handler implementation in WhistleClient class. Fetches server status from Whistle's /cgi-bin/init API endpoint, extracts status data (excluding rules and values), and returns it. This is the key logic executed by the tool./** * 获取服务器状态 * @returns Promise with the server status information */ async getStatus(): Promise<any> { const timestamp = Date.now(); const response = await axios.get(`${this.baseUrl}/cgi-bin/init`, { params: { _: timestamp }, headers: { Accept: "application/json, text/javascript, */*; q=0.01", "Cache-Control": "no-cache", Pragma: "no-cache", "X-Requested-With": "XMLHttpRequest", }, }); const { rules, values, ...restData } = response.data; return restData; }
- src/index.ts:21-30 (helper)Helper function formatResponse used by the tool handler to standardize the MCP response format as a content array containing the JSON-stringified status data.function formatResponse(data: any) { return { content: [ { type: "text" as const, text: JSON.stringify(data), }, ], }; }
- src/WhistleClient.ts:7-9 (helper)WhistleClient constructor initializes the baseUrl used in getStatus for API calls to the Whistle server.constructor(host: string = "localhost", port: number = 8899) { this.baseUrl = `http://${host}:${port}`; }