Skip to main content
Glama

Normalize Strategy Representations

tt_normalize_strategy
Read-onlyIdempotent

Recompile a hand-edited strategy body so its three forms agree.

Every AST-backed field is stored as a family: condition_json (the builder tree) / condition_value (the engine expression) / condition_display, and the same triple for a leg's strike, expiry, qty, limit_price and SL_trigger. Where a *_json exists it is the SOURCE OF TRUTH — this tool parses it (which validates it), canonicalizes it, and re-emits the paired text + display from it. Text-only fields are passed through untouched.

WRITES NOTHING. Pure transform, no TT call, no auth. Pass the body from tt_get_strategy(id) (dict or JSON string); feed the returned strategy back through tt_update_strategy to persist it.

IT ALSO CHECKS THE KEYWORDS IT COMPILES. A tree naming a keyword Tradetron does not have (an invented RSIX, a display name used as a function) fails with STRATEGY_NORMALIZE_FAILED and details.keyword_errors, instead of returning tt_RSIX(...) for a later write to refuse. Keyword errors the input body already carried are not counted, so an older strategy still normalizes.

WHEN TO USE IT. After a PATCH_REP_DISAGREEMENT — the tree and the expression describe different logic and you want the TREE's meaning to win everywhere. For a targeted single-field edit you usually do NOT need this: send the *_json member ALONE to tt_apply_strategy_patch / tt_update_strategy and the server derives that one family's text for you, leaving the rest of the body byte-identical. This tool walks the WHOLE body, so the blast radius depends on how the strategy was last written: on an ASB-authored body it rewrites roughly half to two-thirds of the condition members (re-minted kids, whitespace canonicalisation, missing argument-slot backfill), on a body that already went through this transform it rewrites 0. Either way changed lists exactly which members moved — read it, do not assume a number.

WHERE A TREE IS MISSING ENTIRELY, it is REBUILT from the stored condition_value. A condition can reach TT with the engine text and no tree (an imported body whose conditions never carried one): it runs correctly and cannot be edited, because the ASB condition builder seeds itself from condition_json alone and so opens EMPTY. A rebuilt tree is adopted only when re-emitting it reproduces the stored expression, so the repair can never change what the engine evaluates; the count comes back as condition_trees_rebuilt, and anything unreadable is listed in condition_trees_unrecoverable and left untouched. Legs are excluded on purpose — a text-only qty or expiry is TT's own normal shape.

This is NOT a general text-to-tree edit path. Where a tree already EXISTS it stays the source of truth, so editing condition_value and calling this will NOT update condition_json — it will overwrite your edit with the tree's meaning.

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": {
      "strategy": "<strategy>"
    },
    "name": "tt_normalize_strategy"
  }
}

Input Schema

NameRequiredDescriptionDefault
strategyYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.9/5.0
Behavior5/5

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

Annotations declare readOnlyHint=true and destructiveHint=false, and the description reinforces this ('WRITES NOTHING. Pure transform, no TT call, no auth') while adding what the annotations cannot: the blast radius varies by body provenance (half to two-thirds of condition members on an ASB-authored body, zero on an already-normalized one), the `changed` list is authoritative, unknown keywords fail with STRATEGY_NORMALIZE_FAILED plus details.keyword_errors, and trees are rebuilt only when re-emission reproduces the stored expression.

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?

Long (~350 words) but organized under scannable headers and front-loaded with the identity and safety profile before the nuance. Almost every sentence carries non-redundant information; the overview paragraph re-enumerating the triples for each leg field is the one place that could be tightened.

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?

There is no output schema, yet the description names the meaningful return fields (changed, condition_trees_rebuilt, condition_trees_unrecoverable, details.keyword_errors) and the error path. For a whole-body transform with variable blast radius, it supplies the follow-up step (feed the returned `strategy` back through tt_update_strategy) that an agent would otherwise have to guess.

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 0% and the lone parameter is a bare `strategy` string, so the description must carry the load — and it does: it says where to get the value (the body from tt_get_strategy(id)), that it may be a dict or JSON string, and what internal structure (the *_json / *_value / *_display families) the argument is expected to contain. The dict-or-string wording is slightly at odds with the schema's string-only type, but the semantic enrichment is otherwise strong.

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?

A specific verb ('Recompile') plus resource ('a hand-edited strategy body so its three forms agree'), immediately followed by a concrete model of what the three forms are (condition_json / condition_value / condition_display and the same triple for strike, expiry, qty, limit_price, SL_trigger). An agent can tell this apart from tt_apply_strategy_patch and tt_update_strategy without opening any 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?

An explicit 'WHEN TO USE IT' block names the triggering condition (after a PATCH_REP_DISAGREEMENT where the tree's meaning should win) and an explicit when-NOT (a targeted single-field edit should send the `*_json` member alone to tt_apply_strategy_patch / tt_update_strategy). A closing section warns the tool is not a general text-to-tree edit path and explains exactly why not.

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