Skip to main content
Glama

replayRequest

Replay captured network requests in Whistle MCP Server to test or debug API calls. Specify URL, method, headers, and body, then retrieve results using the getInterceptInfo interface for analysis.

Instructions

在whistle中重放捕获的请求(本接口请求后不会直接返回结果, 需要使用getInterceptInfo接口获取结果)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyNo请求体,可以是字符串或对象
headersNo请求头,可以是对象或字符串
methodNo请求方法,默认为GET
urlYes请求URL
useH2No是否使用HTTP/2

Implementation Reference

  • Core implementation of replayRequest: constructs form data from options and POSTs to Whistle's /cgi-bin/composer endpoint to replay the request.
    async replayRequest(options: {
      useH2?: boolean; // 是否使用HTTP/2
      url: string; // 请求URL
      method?: string; // 请求方法,默认GET
      headers?: Record<string, string> | string; // 请求头,可以是对象或字符串
      body?: string | Record<string, any>; // 请求体
    }): Promise<any> {
      // 准备请求参数
      const formData = new URLSearchParams();
    
      // 是否使用HTTP/2
      formData.append("useH2", options.useH2 ? "true" : "");
    
      // 添加URL (必需)
      formData.append("url", options.url);
    
      // 添加请求方法
      formData.append("method", options.method || "GET");
    
      // 处理请求头
      if (options.headers) {
        let headerStr = "";
        if (typeof options.headers === "string") {
          headerStr = options.headers;
        } else {
          headerStr = Object.entries(options.headers)
            .map(([key, value]) => `${key}: ${value}`)
            .join("\r\n");
        }
        formData.append("headers", headerStr);
      }
    
      // 处理请求体
      if (options.body) {
        if (typeof options.body === "string") {
          formData.append("body", options.body);
        } else {
          // 对象类型的请求体转为JSON字符串
          formData.append("body", JSON.stringify(options.body));
        }
      }
    
      // 发送重放请求到composer接口
      const response = await axios.post(
        `${this.baseUrl}/cgi-bin/composer`,
        formData,
        {
          headers: {
            "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
            "X-Requested-With": "XMLHttpRequest",
            Accept: "application/json, text/javascript, */*; q=0.01",
            "Cache-Control": "no-cache",
            Pragma: "no-cache",
          },
        }
      );
    
      return response.data;
    }
  • Zod schema defining the input parameters for the replayRequest MCP tool.
    parameters: z.object({
      url: z.string().describe("请求URL"),
      method: z.string().optional().describe("请求方法,默认为GET"),
      headers: z.string().optional().describe("请求头,可以是对象或字符串"),
      body: z.string().optional().describe("请求体,可以是字符串或对象"),
      useH2: z.boolean().optional().describe("是否使用HTTP/2")
    }),
  • src/index.ts:418-432 (registration)
    Registers the replayRequest tool with the FastMCP server, providing schema and thin wrapper execute handler that delegates to WhistleClient.
    server.addTool({
      name: "replayRequest",
      description: "在whistle中重放捕获的请求(本接口请求后不会直接返回结果, 需要使用getInterceptInfo接口获取结果)",
      parameters: z.object({
        url: z.string().describe("请求URL"),
        method: z.string().optional().describe("请求方法,默认为GET"),
        headers: z.string().optional().describe("请求头,可以是对象或字符串"),
        body: z.string().optional().describe("请求体,可以是字符串或对象"),
        useH2: z.boolean().optional().describe("是否使用HTTP/2")
      }),
      execute: async (args) => {
        const result = await whistleClient.replayRequest(args);
        return formatResponse(result);
      },
    });
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds valuable context: the tool doesn't return results directly ('本接口请求后不会直接返回结果'), requiring a separate call to 'getInterceptInfo'. This is crucial for understanding the asynchronous or multi-step nature of the operation. However, it lacks details on permissions, rate limits, or error handling, which are important for a tool that likely involves network requests.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, stating the main purpose in the first part: '在whistle中重放捕获的请求'. The second sentence adds critical behavioral context about result retrieval. There's no wasted text, and both sentences earn their place by providing essential information without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a tool for replaying network requests with 5 parameters) and no annotations or output schema, the description is moderately complete. It covers the purpose and a key behavioral trait (indirect result retrieval), but lacks details on error cases, performance implications, or integration with other tools like 'toggleHttpInterception'. For a tool with no structured safety or output info, more context would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with all parameters well-documented (e.g., 'url' as required, 'method' defaults to GET). The description doesn't add any parameter-specific semantics beyond what the schema provides, such as explaining how 'body' or 'headers' should be formatted for replay. Given the high schema coverage, a baseline score of 3 is appropriate, as the schema handles most of the parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '在whistle中重放捕获的请求' (replay captured requests in whistle). It specifies the verb ('重放' - replay) and resource ('捕获的请求' - captured requests), making the action clear. However, it doesn't differentiate from sibling tools like 'toggleHttpInterception' or 'getInterceptInfo', which are related to request handling but serve different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool: for replaying captured requests in whistle. It also specifies a critical follow-up action: '需要使用getInterceptInfo接口获取结果' (need to use getInterceptInfo interface to get results), which clarifies the workflow. However, it doesn't mention when not to use it or alternatives among siblings, such as other interception-related tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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