rules.create

Live

Create a new rule candidate in the Cortex rulebook.

CategoryRules
JSON-RPCtools/call
EndpointPOST /mcp
Sourcepackages/mcp-tools/src/tools/rules-create.ts

Description

Submits a natural-language rule as a *candidate*. Candidates are not active until the user confirms them in the operator dashboard — this protects the rulebook from prompt-injection-driven rule additions.

Input schema

FieldTypeRequiredDescription
rule_textstringyesNatural language rule text.
contextstringnoOptional context for rule creation.

Output shape

typescript
{
  ok: boolean;
  rule_id?: string;
  candidate_id?: string;
  error?: string;
}

In Phase 0, new rules return as `candidate_id` only — they activate after user confirmation.

Example call

JSON-RPC tools/call request body (omit the JSON-RPC envelope when using an SDK; the SDK adds it for you):

jsontools/call params
{
  "name": "rules.create",
  "arguments": {
    "rule_text": "Never schedule meetings on Fridays before noon.",
    "context": "Founder writing block, weekly"
  }
}

Example response

Tool results are always wrapped as content[0].text with a stringified JSON body. The shape below is what you get back from JSON.parse(result.content[0].text):

jsonparsed result body
{
  "ok": true,
  "candidate_id": "rcand_01HXP7"
}

Errors this tool can return

CodeMeaning
invalid_argumentsTool input failed Zod validation.
unauthorizedMissing or invalid bearer token.

See the full error catalog for resolution steps on each code, plus the standard transport-layer responses (401, 429).