Skip to main content
Glama

Deploy Custom Rule

deploy_rule

Deploy a persistent custom rule to enforce evaluation checks on every future matching output, active immediately.

Instructions

Deploy a custom rule that fires on every future evaluate_output call of its bundle — persisted, active immediately, audited.

What it does. Writes the rule to ~/.iris/custom-rules.json, appends a rule.deploy audit entry and registers it with the running engine, so it fires on the very next call and survives restarts. eval_type says WHEN it fires (that bundle, and eval_type="all"); severity says what a failure DOES: low and medium only lower the weighted score, high and critical force passed to false and list the rule in critical_failures. definition.type picks the check (regex_match, regex_no_match, min_length, max_length, contains_keywords, excludes_keywords, json_schema, cost_threshold) and definition.config carries its keys (pattern; min_length; max_length; keywords; max_cost). Any bundle and type combine. Names are unique: a taken name is refused unless replace is true, which retires the earlier rule(s) first and reports them. Argument names are snake_case; the camelCase aliases evalType and sourceMomentId are accepted — pass one spelling of each.

When not to use it. To try a rule first: POST /api/v1/rules/custom/preview on the dashboard replays a definition against stored traces without deploying. For a one-off check on one call: the custom_rules argument of evaluate_output. To pause a rule: delete_rule with enabled: false.

Returns. JSON with rule (the rule as persisted: id (rule-, keep it for delete_rule), name, description, evalType, severity, definition, enabled, createdAt, updatedAt, version, sourceMomentId); replaced (with replace: true, the earlier rule(s) of the same name that were retired); warning (with replace: true, one sentence naming what was retired).

Errors. IRIS_DUPLICATE_RULE when the name is deployed and replace is false (the message names the existing id). IRIS_INVALID_RULE_CONFIG when the definition is rejected — a regex that fails the ReDoS check or exceeds 1000 characters, a missing config key — naming the field; nothing is deployed. IRIS_STORAGE_ERROR when the store cannot be written. An unknown key in definition, a name over 80 characters, a non-positive weight or both spellings of an alias are refused before the handler runs. Every failure returns {"error":{"code","message","recovery":[]}} with isError true; follow recovery before retrying.

Siblings. list_rules — see what is deployed and the built-in roster; delete_rule — remove, disable or re-enable; evaluate_output — where the rule fires.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesHuman-readable rule name (1-80 chars; used in eval results). Must be unique among deployed rules unless replace=true
replaceNoWhen a rule with this name is already deployed: false (default) rejects the call; true deletes the existing same-named rule(s) and deploys this one in their place (fresh id; audit rows preserved)
evalTypeNocamelCase alias of eval_type, accepted for compatibility — prefer eval_type (snake_case is canonical across the tools)
severityNoWhat a FAILURE of this rule means. low/medium: informational — contributes to the weighted score only (plus dashboard sort + audit alerts). high/critical: hard-fail — a failing evaluation of this rule forces the overall passed=false regardless of the weighted scoremedium
eval_typeNoEval category this rule belongs to; the rule fires on evaluate_output calls whose eval_type equals it (and on eval_type="all"). Canonical snake_case spelling — pass exactly one of eval_type / evalType
definitionYesCheck definition (regex, length, keyword, cost, or schema). Accepts exactly type, config, weight and an optional name — an unknown key is rejected
descriptionNoWhat this rule checks for and why it matters
sourceMomentIdNocamelCase alias of source_moment_id, accepted for compatibility — prefer source_moment_id
source_moment_idNoOptional Decision Moment ID the rule was derived from (preserves workflow-inversion provenance). Canonical snake_case — pass exactly one of source_moment_id / sourceMomentId

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
ruleYesthe rule as persisted: id (rule-<hex>, keep it for delete_rule), name, description, evalType, severity, definition, enabled, createdAt, updatedAt, version, sourceMomentId
warningNowith replace: true, one sentence naming what was retired
replacedNowith replace: true, the earlier rule(s) of the same name that were retired

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed1 schema field changedv0.9.0
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": {},
      +  "properties": {
      +    "replaced": {
      +      "description": "with replace: true, the earlier rule(s) of the same name that were retired",
      +      "items": {
      +        "additionalProperties": {},
      +        "properties": {
      +          "id": {
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "id"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "rule": {
      +      "additionalProperties": {},
      +      "description": "the rule as persisted: id (rule-<hex>, keep it for delete_rule), name, description, evalType, severity, definition, enabled, createdAt, updatedAt, version, sourceMomentId",
      +      "properties": {
      +        "id": {
      +          "type": "string"
      +        },
      +        "name": {
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "id",
      +        "name"
      +      ],
      +      "type": "object"
      +    },
      +    "warning": {
      +      "description": "with replace: true, one sentence naming what was retired",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "rule"
      +  ],
      +  "type": "object"
      +}
  2. Changed20 schema fields changedv0.8.0
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / definition / additionalProperties
      Added value: +false
    • changedInput schema / properties / definition / description
      Previous value: -"Check definition (regex, length, keyword, cost, or schema)"New value: +"Check definition (regex, length, keyword, cost, or schema). Accepts exactly type, config, weight and an optional name — an unknown key is rejected"
    • addedInput schema / properties / definition / properties / config / description
      Added value: +"Check configuration; required keys depend on type (regex_match: pattern; min_length: min_length; max_length: max_length; contains_keywords/excludes_keywords: keywords; cost_threshold: max_cost; json_schema: none)"
    • addedInput schema / properties / definition / properties / name / description
      Added value: +"Optional and IGNORED if given — the server overwrites it with the top-level `name` so the rule reports under one name everywhere"
    • addedInput schema / properties / definition / properties / name / maxLength
      Added value: +80
    • addedInput schema / properties / definition / properties / name / minLength
      Added value: +1
    • addedInput schema / properties / definition / properties / type / description
      Added value: +"Check type — decides which config keys are required"
    • addedInput schema / properties / definition / properties / weight / description
      Added value: +"Weight in the weighted score (default 1; must be > 0)"
    • addedInput schema / properties / definition / properties / weight / exclusiveMinimum
      Added value: +0
    • changedInput schema / properties / definition / required
      Previous value: -[
      -  "name",
      -  "type",
      -  "config"
      -]New value: +[
      +  "type",
      +  "config"
      +]
    • changedInput schema / properties / evalType / description
      Previous value: -"Eval category this rule belongs to; determines when it fires"New value: +"camelCase alias of eval_type, accepted for compatibility — prefer eval_type (snake_case is canonical across the tools)"
    • addedInput schema / properties / eval_type
      Added value: +{
      +  "description": "Eval category this rule belongs to; the rule fires on evaluate_output calls whose eval_type equals it (and on eval_type=\"all\"). Canonical snake_case spelling — pass exactly one of eval_type / evalType",
      +  "enum": [
      +    "completeness",
      +    "relevance",
      +    "safety",
      +    "cost",
      +    "custom"
      +  ],
      +  "type": "string"
      +}
    • changedInput schema / properties / name / description
      Previous value: -"Human-readable rule name (used in eval results)"New value: +"Human-readable rule name (1-80 chars; used in eval results). Must be unique among deployed rules unless replace=true"
    • changedInput schema / properties / name / maxLength
      Previous value: -120New value: +80
    • addedInput schema / properties / replace
      Added value: +{
      +  "default": false,
      +  "description": "When a rule with this name is already deployed: false (default) rejects the call; true deletes the existing same-named rule(s) and deploys this one in their place (fresh id; audit rows preserved)",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / severity / description
      Previous value: -"Severity used for dashboard sort + audit alerts"New value: +"What a FAILURE of this rule means. low/medium: informational — contributes to the weighted score only (plus dashboard sort + audit alerts). high/critical: hard-fail — a failing evaluation of this rule forces the overall passed=false regardless of the weighted score"
    • changedInput schema / properties / sourceMomentId / description
      Previous value: -"Optional Decision Moment ID the rule was derived from (preserves workflow-inversion provenance)"New value: +"camelCase alias of source_moment_id, accepted for compatibility — prefer source_moment_id"
    • addedInput schema / properties / source_moment_id
      Added value: +{
      +  "description": "Optional Decision Moment ID the rule was derived from (preserves workflow-inversion provenance). Canonical snake_case — pass exactly one of source_moment_id / sourceMomentId",
      +  "type": "string"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "name",
      -  "evalType",
      -  "definition"
      -]New value: +[
      +  "name",
      +  "definition"
      +]
  3. Changed3 schema fields changedv0.4.6
    • removedInput schema / additionalProperties
      Removed value: -false
    • removedInput schema / properties / definition / additionalProperties
      Removed value: -false
    • addedInput schema / properties / definition / properties / config / propertyNames
      Added value: +{
      +  "type": "string"
      +}
  4. Addedv0.1.10

TDQS

A5/5.0
Behavior5/5

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

Annotations only indicate it is not read-only, not idempotent, and not destructive. The description substantially exceeds them by disclosing file writes, audit entries, engine registration, restart persistence, unique-name refusal, replacement semantics, and detailed error behavior. No contradictions with annotations.

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

Conciseness5/5

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

The description is long but deliberately structured with clear sections: what it does, when not to use it, returns, errors, and siblings. It front-loads the core behavior in the first sentence and every paragraph covers a distinct needed concern.

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

Completeness5/5

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

Given the complex nested schema and 9 parameters, the description covers side effects, return shape, error codes, recovery behavior, and sibling relationships. An agent has enough information to decide when to call it, construct a valid definition, and interpret outcomes.

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?

Schema coverage is 100%, but the description adds meaning beyond the schema: alias handling, the 'all' eval_type behavior, severity's hard-fail impact, definition.config key mapping, and rejection of unknown keys. It compensates richly for any ambiguity left by the schema.

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 opening sentence states a specific action and resource: deploying a custom rule that fires on future evaluate_output calls, with persistence, immediate activation, and auditing. It clearly distinguishes this from siblings like list_rules and delete_rule.

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?

Includes an explicit 'When not to use it' section naming preview, evaluate_output's custom_rules argument, and delete_rule for pausing. This gives an agent concrete routing guidance for alternatives.

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

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/iris-eval/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server