Skip to main content
Glama

add_mock_rule

Append a single new conditional response rule to an existing mock API endpoint without replacing or resending its existing rules array. Returns the full updated mock object (including the newly created rule's assigned database 'id' and 'slugId', the complete 'rules' array, and 'responseBodyWarning' if the rule's JSON responseBody looks malformed). USAGE GUIDELINES: Prefer add_mock_rule over update_mock whenever adding a new scenario to an existing mock — it is much more token-efficient and avoids accidentally overwriting existing rules or reassigning their rule IDs. Before calling, inspect existing rule priorities via get_mock_detail so you can set the new rule's 'priority' integer appropriately (rules are evaluated in ascending priority order; first match wins). After adding the rule, call test_mock with a matching request payload and verify the 'X-Rule-Matched' response header.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "projectId": "<projectId>",
      "mockId": "<mockId>",
      "rule": "<rule>"
    },
    "name": "add_mock_rule"
  }
}

Input Schema

NameRequiredDescriptionDefault
ruleYesA single conditional rule. Rules are evaluated in ascending priority order. The first rule whose conditions ALL match will override the mock's default response. If no rule matches, the mock's default responseBody/responseStatus is returned as the fallback.
mockIdYesDatabase ID of the target mock API endpoint to append the rule to (obtain from list_mocks, search_mocks, or get_mock_detail).
projectIdYesDatabase ID of the project workspace containing the mock (obtain from list_projects, search_mocks, or get_mock_detail).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • changedInput schema / properties / mockId / description
      Previous value: -"Database ID of the mock endpoint"New value: +"Database ID of the target mock API endpoint to append the rule to (obtain from list_mocks, search_mocks, or get_mock_detail)."
    • changedInput schema / properties / projectId / description
      Previous value: -"Database ID of the project"New value: +"Database ID of the project workspace containing the mock (obtain from list_projects, search_mocks, or get_mock_detail)."
    • changedInput schema / properties / rule / properties / responseBody / description
      Previous value: -"Response body to return when this rule matches. Supports all dynamic expression placeholders (e.g. {{body.user_id}}, {{path.id}}, {{random_uuid}}). IMPORTANT: For JSON responses, do NOT include raw newline characters (\\n) in the JSON payload as it will make the JSON structure malformed."New value: +"Response body to return when this rule matches. Supports all dynamic expression placeholders:\n- Request: {{path.<var>}}, {{query.<param>}}, {{header.<Name>}}, {{body.<jsonPath>}}, {{form.<field>}} (all support ':default' fallback, e.g. {{body.amount:100000}})\n- Random & UUID: {{random.uuid}} (or {{random_uuid}}), {{random.number:<len>}}, {{random.alphabet:<len>}}, {{random.alphanumeric:<len>}}\n- Date/Time: {{random.date:<format>}} or {{random.date:<format>:<offset>}} (e.g. {{random.date:yyyy-MM-dd:+7d}}, offsets: +/-Ns, m, h, d, M, y)\n- Faker (locales: _id, _jp, _kr, _global or :ID, :JP, :KR, :GLOBAL): {{faker.name_id}}, {{faker.email}}, {{faker.phone_id}}, {{faker.company}}, {{faker.city_jp}}, {{faker.address_id}}, {{faker.jobtitle}}, {{faker.car}}, {{faker.price:<min>:<max>}}\n- State & Env: {{state.<fieldName>}}, {{env.<KEY>:<default>}}, JSON array looping with '__repeat' & {{item}}, Handlebars {{#if (eq a b)}}...{{/if}}\nIMPORTANT: For JSON responses, enclose all {{...}} placeholders in double quotes and do NOT include raw newline characters (\\n) in the JSON payload."
  2. First observed

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses the return payload (full updated mock object, new rule's database id and slugId, complete rules array, responseBodyWarning for malformed JSON) and the append-only mutation semantics. It does not cover failure modes such as a missing mockId/projectId or permission requirements, which is why this is a 4 rather than a 5.

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?

Front-loaded with the append-only behavior, then a clearly labeled USAGE GUIDELINES block. Every sentence contributes, though the return-value sentence is dense and could be split for scannability.

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

Completeness4/5

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

Given a deeply nested rule object with no output schema, the description fills the two gaps the schema cannot: mutation semantics versus update_mock and the shape of the returned mock object. It stops short of describing error behavior, which is the only meaningful omission for a tool of this complexity.

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?

Schema description coverage is 100%, so all three top-level parameters and every nested rule field are already documented, making 3 the baseline. The description adds the evaluation-order semantics (ascending priority, first match wins) and advises inspecting existing priorities first, but that ordering detail is largely duplicated in the schema's own priority and rule descriptions.

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

Purpose5/5

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

States a specific verb and resource ('Append a single new conditional response rule to an existing mock API endpoint') and immediately scopes it against the closest sibling by clarifying it does not replace or resend the existing rules array. An agent can distinguish this from update_mock or bulk_create_mocks without opening the schema.

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

Usage Guidelines5/5

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

Explicitly says to prefer add_mock_rule over update_mock when adding a scenario and gives the reason (token efficiency, avoiding overwriting rules or reassigning rule IDs). It also prescribes a before/after workflow: inspect priorities via get_mock_detail, then verify with test_mock and the 'X-Rule-Matched' header.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources