Skip to main content
Glama

enableRule

Activate specific rules in the Whistle proxy server using the Model Context Protocol (MCP) to manage network requests, monitor traffic, and enhance proxy control.

Instructions

启用规则

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ruleNameYes规则名称

Implementation Reference

  • src/index.ts:94-104 (registration)
    Registration of the 'enableRule' tool in FastMCP server, including name, description, Zod input schema (ruleName: string), and execute handler that delegates to WhistleClient.selectRule and formats the response.
    server.addTool({
      name: "enableRule",
      description: "启用规则",
      parameters: z.object({
        ruleName: z.string().describe("规则名称"),
      }),
      execute: async (args) => {
        const result = await whistleClient.selectRule(args.ruleName);
        return formatResponse(result);
      },
    });
  • Main handler logic for enabling a rule: fetches rules, gets rule content, prepares form data to select/activate the rule via Whistle's CGI API endpoint (/rules/select or /rules/enable-default for default rule), handling special case for 'default' rule.
    async selectRule(ruleName: string): Promise<any> {
      const rules = await this.getRules();
    
      if (!rules) {
        throw new Error("No rules found");
      }
    
      const isDefaultRule = ruleName.toLowerCase() === "default";
      let ruleContent;
    
      if (isDefaultRule) {
        ruleContent = rules.defaultRules;
      } else {
        const rule = rules.list.find((rule: any) => rule.name === ruleName);
        if (!rule) {
          throw new Error(`Rule with name '${ruleName}' not found`);
        }
        ruleContent = rule.data;
      }
    
      const formData = new URLSearchParams();
      formData.append("clientId", `${Date.now()}-0`);
      formData.append("name", ruleName);
      formData.append("value", ruleContent);
      formData.append("selected", "true");
      formData.append("active", "true");
      formData.append("key", `w-reactkey-${Math.floor(Math.random() * 1000)}`);
      formData.append("hide", "false");
      formData.append("changed", "true");
    
      const endpoint = isDefaultRule
        ? `${this.baseUrl}/cgi-bin/rules/enable-default`
        : `${this.baseUrl}/cgi-bin/rules/select`;
    
      const response = await axios.post(endpoint, formData, {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
        },
      });
    
      return response.data;
    }
  • Helper function used by all tools to format responses as MCP content blocks with JSON-stringified data.
    function formatResponse(data: any) {
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify(data),
          },
        ],
      };
    }
  • Zod schema for enableRule tool input: requires 'ruleName' as string.
    parameters: z.object({
      ruleName: z.string().describe("规则名称"),
    }),
  • Helper method called by selectRule to fetch current rules list from Whistle API.
    async getRules(): Promise<any> {
      const response = await axios.get(`${this.baseUrl}/cgi-bin/rules/list`);
      return response.data;
    }
Behavior1/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. '启用规则' only states the action without explaining what enabling does (e.g., activates a rule for interception, changes its state, requires specific permissions), whether it's reversible, potential side effects, or response format. For a mutation tool with zero annotation coverage, this is a critical gap that leaves the agent guessing about behavior.

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

Conciseness2/5

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

The description is a single phrase '启用规则', which is extremely concise but under-specified rather than efficiently informative. It lacks necessary details for a mutation tool, making it more of an omission than effective brevity. Every sentence should earn its place, but here the single phrase fails to provide adequate value.

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

Completeness1/5

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

Given the tool's complexity (a mutation operation affecting rule states), lack of annotations, no output schema, and rich sibling tools, the description is incomplete. It doesn't explain what enabling a rule does, how it differs from other state-changing tools, or what to expect in return. For a tool in this context, the description is severely inadequate.

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 'ruleName' documented as '规则名称' (rule name). The description adds no parameter information beyond what the schema provides. According to scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description, which applies here.

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

Purpose2/5

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

The description '启用规则' (Enable rule) is a tautology that essentially restates the tool name 'enableRule' in Chinese. While it indicates the action (enable) and resource (rule), it doesn't specify what type of rules, what enabling entails, or how this differs from similar tools like 'toggleMultiRuleMode' or 'setAllRulesState' that also affect rule states. The purpose is minimally stated but lacks differentiation from siblings.

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

Usage Guidelines1/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether the rule must exist or be disabled first), when not to use it, or how it compares to sibling tools like 'disableRule', 'setAllRulesState', or 'toggleMultiRuleMode'. Without any context, an agent would struggle to choose this tool appropriately.

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