getInterceptInfo
Retrieve base64-encoded interception details for specific URLs, including request and response data, to monitor and analyze network traffic using Whistle MCP Server. Supports regex and optional time and count parameters for precise results.
Instructions
获取URL的拦截信息(请求/响应皆以base64编码)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | 请求数量(可选) | |
| startTime | No | 开始时间ms(可选) | |
| url | No | 要检查拦截信息的URL (支持正则表达式) |
Implementation Reference
- src/WhistleClient.ts:598-632 (handler)Core handler function in WhistleClient class that fetches intercepted request data from Whistle's /cgi-bin/get-data API endpoint using startTime, count, and other parameters.async getInterceptInfo( options: { startTime?: string; count?: number; lastRowId?: string; } = {} ): Promise<any> { const timestamp = Date.now(); const clientId = `${timestamp}-${Math.floor(Math.random() * 100)}`; const params = { clientId, startLogTime: -2, startSvrLogTime: -2, ids: "", startTime: options.startTime || `${timestamp}-000`, dumpCount: 0, lastRowId: options.lastRowId || options.startTime || `${timestamp}-000`, logId: "", count: options.count || 20, _: timestamp, }; const response = await axios.get(`${this.baseUrl}/cgi-bin/get-data`, { params, headers: { Accept: "application/json, text/javascript, */*; q=0.01", "Cache-Control": "no-cache", Pragma: "no-cache", "X-Requested-With": "XMLHttpRequest", }, }); return response.data.data || []; }
- src/index.ts:387-416 (registration)FastMCP tool registration for 'getInterceptInfo', including schema, description, and execute wrapper that filters results by 'url' using regex or string match, then formats response.server.addTool({ name: "getInterceptInfo", description: "获取URL的拦截信息(请求/响应皆以base64编码)", parameters: z.object({ url: z.string().optional().describe("要检查拦截信息的URL (支持正则表达式)"), startTime: z.string().optional().describe("开始时间ms(可选)"), count: z.number().optional().describe("请求数量(可选)"), }), execute: async (args) => { const { url = '', startTime = (Date.now() - 1000).toString(), count } = args; const result = await whistleClient.getInterceptInfo({ startTime, count }); const filteredResult = Object.values(result.data).filter((item: any) => { if (url) { try { const regex = new RegExp(url); return Array.isArray(item.url) ? item.url.some((u: string) => regex.test(u)) : regex.test(item.url); } catch (e) { // 正则表达式无效时,回退到简单的字符串包含检查 return Array.isArray(item.url) ? item.url.some((u: string | string[]) => u.includes(url)) : item.url.includes(url); } } return true; }); return formatResponse(filteredResult); }, });
- src/index.ts:390-394 (schema)Input schema using Zod for validating tool parameters: optional url (string, supports regex), startTime (string ms timestamp), count (number).parameters: z.object({ url: z.string().optional().describe("要检查拦截信息的URL (支持正则表达式)"), startTime: z.string().optional().describe("开始时间ms(可选)"), count: z.number().optional().describe("请求数量(可选)"), }),