> ## Documentation Index
> Fetch the complete documentation index at: https://docs.toorow.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Rules & System Instructions

> Invariants and system instructions for AI agents consuming toorow FastMCP data tools.

When interacting with **toorow**, AI agents must adhere to strict behavioral rules to ensure data accuracy, tenant isolation, and non-causal provenance.

***

## Core Agent Rules

### Rule 1: Always Discover Capabilities First

Before constructing queries or requesting custom metric/dimension combinations, agents **must** inspect source metadata using `get_source_capabilities(project_id, connection_ref_id)`. Never guess column names or supported grains.

### Rule 2: Never Aggregate Non-Additive Metrics Directly

Ratio metrics (CTR, CPA, ROAS, Average Position) are non-additive. Agents must **never** perform direct `SUM()` operations over ratio metrics in `fact_daily_kpi` (AD-4). Always query calculated semantic ratio views (`semantic_ctr`, `semantic_cpa`, `semantic_roas`, `semantic_avg_position`).

### Rule 3: Enforce Tenant & Project Scoping (AD-5)

Every tool invocation must supply an explicit `project_id`. Agents must never attempt cross-tenant reads or bypass the organization-rooted AD-5 resource graph.

### Rule 4: Preserve `structuredContent` for MCP App UI Rendering

When generating responses, present a concise text summary (≤ 30 lines) while preserving the full `structuredContent` payload in the tool output. This enables host interfaces to render interactive **MCP App UI widgets (`ui/widgets/`)**.

### Rule 5: Non-Causal Phrasing for Context Events (AD-9)

When annotating anomalies with `context_events`, agents must state events as **candidate context** only. Prohibited causal phrasing includes: `"caused by"`, `"due to"`, `"because of"`, `"en raison de"`.

***

## Next Steps & Cross-References

<CardGroup cols={2}>
  <Card title="Agent Tools Reference" icon="wrench" href="/agent-tools">
    Inspect FastMCP tool definitions and parameter schemas.
  </Card>

  <Card title="MCP App Use Cases" icon="layer-group" href="/use-cases-library">
    See how agent rules drive interactive MCP App UI widgets.
  </Card>

  <Card title="Platform Constraints" icon="shield-check" href="/constraints">
    Review full security invariants (AD-1 to AD-32).
  </Card>

  <Card title="Agent Context" icon="database" href="/agent-context">
    Learn how metadata and context events are structured.
  </Card>
</CardGroup>
