Skip to main content
Glama
This connector has been deprecated

This listing duplicates LexQ (io.lexq/lexq), which follows the official MCP Registry entry. Use that listing instead.

Create Rule

lexq_rules_create

Create a rule in a DRAFT version. Requires name, condition tree, and actions array. priority is auto-assigned (appended last); use lexq_rules_reorder to change order.

Before creating rules with new fact keys, call lexq_facts_list to check existing facts. If a required key is missing, ask the user to confirm the type, isRequired, and description before calling lexq_facts_create — registering facts enables type validation, Console UI autocomplete, and the dry-run requirements analyzer.

An action's targetVar (SET_FACT, MUTATE_FACT) must be a registered fact. Saving or publishing a rule whose targetVar is not registered fails with ACT-032, so register it with lexq_facts_create first. Keys a rule only reads (condition fields, refVar) may stay unregistered.

After saving, lexq_facts_unregistered lists any keys this version references but has not defined (non-blocking, version-wide) — use it to decide what to register.

Condition: { type: "SINGLE", field, operator, value, valueType } or { type: "GROUP", operator: "AND"|"OR", children: [...] } Value types: STRING, NUMBER, BOOLEAN, LIST_STRING, LIST_NUMBER Limits: a condition tree may hold at most 25 conditions (SINGLE nodes; GROUP nodes do not count) and nest at most 10 levels below the root. A version holds at most 100 rules.

Operators are constrained by the LEFT fact's type (from lexq_facts_list). Using one outside its type is rejected by the server — check the fact type before choosing an operator.

  • STRING fact: EQUALS, NOT_EQUALS, CONTAINS, IN, NOT_IN

  • NUMBER fact: EQUALS, NOT_EQUALS, GREATER_THAN, GREATER_THAN_OR_EQUAL, LESS_THAN, LESS_THAN_OR_EQUAL, IN, NOT_IN

  • BOOLEAN fact: EQUALS, NOT_EQUALS

  • LIST_* fact: HAS_ANY, HAS_ALL, HAS_NONE (only these)

HAS_* query list-typed facts. Value is always an array whose element type matches the fact:

  • HAS_ANY: fact has at least one of the given values

  • HAS_ALL: fact has all of the given values

  • HAS_NONE: fact has none of the given values Example: { "type": "SINGLE", "field": "userTags", "operator": "HAS_ANY", "value": ["VIP","GOLD"], "valueType": "LIST_STRING" }

Do NOT use CONTAINS on a list fact — CONTAINS is substring match on STRING facts only. IN is the mirror of HAS_*: IN takes a scalar fact with a list value; HAS_* takes lists on both sides.

Actions: [{ type, parameters }]

Action parameter schemas:

  • MUTATE_FACT: { targetVar: string, operator: "ASSIGN"|"ADD"|"SUB"|"MUL"|"DIV", method: "PERCENTAGE"|"AMOUNT", operand: number, refVar?: string, rounding?: RoundingOption } targetVar is the fact this action reads and writes. It must be a registered fact (ACT-032 otherwise), and the request must send it (P-015 otherwise). Its value must be a number when the action runs. A missing required fact throws (no 0 default). operand is the arithmetic operand; the unit is dictated by method (percent when PERCENTAGE, absolute amount when AMOUNT). Ranges are not constrained — negative values and >100 percentages are valid (refunds, surcharges). refVar is the base for percentage calculation and is OPTIONAL — omit it to use targetVar itself. It is only meaningful in PERCENTAGE × {ASSIGN, ADD, SUB}; specifying it in any other cell is an error. Use it when the base differs from the target, e.g. "points += orderTotal × 5%" → { targetVar: "points", refVar: "orderTotal", operator: "ADD", method: "PERCENTAGE", operand: 5 }. operator × method matrix: ASSIGN targetVar = operand | targetVar = refVar × operand/100 ADD targetVar += operand | targetVar += refVar × operand/100 SUB targetVar -= operand | targetVar -= refVar × operand/100 MUL targetVar *= operand | targetVar *= (operand/100 + 1) DIV targetVar /= operand | invalid Constraints: DIV + PERCENTAGE is invalid (use MUL with the inverse). DIV + AMOUNT requires operand !== 0.

  • SET_FACT: { targetVar: string, value: string|number|boolean } targetVar must be a registered fact (ACT-032 otherwise). The request does not have to send it: SET_FACT is the only action whose targetVar may be absent from the input facts. MUTATE_FACT requires its target to be present in the input facts.

  • BLOCK: { reason?: string } Records a rejection decision. It does NOT halt rule execution — subsequent actions and subsequent winning rules still run. Enforcement is the caller's responsibility; the decision surfaces as isBlocked (true) and blockReason (reason, or "Policy Violation" when omitted). Only BLOCK writes those two keys: saving or publishing a rule whose SET_FACT or MUTATE_FACT targets either one fails with ACT-033.

Evaluation order: every rule's condition is checked against the input facts before any action runs, so a condition never sees a value an action writes in the same request. Then the actions of the winning rules run in priority order. Each action works on the values the actions before it left, in its own rule or an earlier one. To test a value an action writes, send that value as an input fact in a second request. If a rule should run whenever another one does, put its actions in that rule instead.

RoundingOption (optional, MUTATE_FACT only): { scale: integer (0..34), mode?: "UP"|"DOWN"|"CEILING"|"FLOOR"|"HALF_UP"|"HALF_DOWN"|"HALF_EVEN" } mode defaults to HALF_UP. When omitted, calculator output is preserved at full precision (lossless).

Input Schema

NameRequiredDescriptionDefault
ruleYesJSON string of CreateRuleRequest: { name, condition, actions, mutexGroup?, mutexMode?, mutexStrategy?, mutexLimit?, isEnabled? }
groupIdYesPolicy group ID
versionIdYesVersion ID

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / groupId / pattern
      Added value: +"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    • addedInput schema / properties / versionId / pattern
      Added value: +"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
  2. Changed1 schema field changed
    • changedInput schema / properties / rule / description
      Previous value: -"JSON string of CreateRuleRequest: { name, priority, condition, actions, mutexGroup?, mutexMode?, mutexStrategy?, mutexLimit?, isEnabled? }"New value: +"JSON string of CreateRuleRequest: { name, condition, actions, mutexGroup?, mutexMode?, mutexStrategy?, mutexLimit?, isEnabled? }"
  3. First observed

TDQS

A4.6/5.0
Behavior5/5

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

The description goes well beyond the annotations, disclosing auto-assigned priority, validation failure codes such as ACT-032, P-015, and ACT-033, non-blocking BLOCK semantics, evaluation order, condition limits, and action constraints. This is exactly the behavioral context an agent needs for a mutation tool annotated only with readOnlyHint=false and destructiveHint=false.

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 definition is front-loaded with purpose and required fields, then organized into condition, action, evaluation-order, and rounding sections. It is very long, but most detail is justified by the complexity of rule construction; a few explanatory asides could be trimmed without losing critical information.

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?

The description is highly complete on rule contents, facts prerequisites, validation failures, action behavior, and evaluation order. It does not explain the optional mutexGroup, mutexMode, mutexStrategy, mutexLimit, or isEnabled fields exposed in the schema's rule JSON, nor does it mention the response shape, leaving minor completeness gaps.

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

Parameters5/5

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

Although the schema has 100% description coverage, it only describes rule as a JSON string with high-level fields. The description adds extensive semantics for condition trees, value types, operator-by-fact-type constraints, HAS_* behavior, action parameter schemas, arithmetic matrix behavior, and rounding options.

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?

The description opens with a specific verb and resource: 'Create a rule in a DRAFT version,' and immediately states required inputs. It also distinguishes ordering behavior by naming lexq_rules_reorder, so an agent can tell it apart from sibling rule-management tools.

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 gives clear preconditions and follow-ups: call lexq_facts_list before using new fact keys, confirm with the user before lexq_facts_create, and use lexq_facts_unregistered after saving. It does not explicitly say when to use lexq_rules_update instead, but the create-specific guidance is otherwise strong.

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