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

# Tools & Resources

> The 9 RAIL MCP tools and 2 resources, with parameters, costs, and output.

All tools are `rail_`-prefixed. Each description tells the agent what the tool
does, when to use it, when not to, its cost, and its latency.

## Evaluation and guardrails

### `rail_evaluate`

Score AI-generated content across the 8 RAIL dimensions (Fairness, Safety,
Reliability, Transparency, Privacy, Accountability, Inclusivity, User Impact).

| Parameter    | Type                                                                       | Default   |
| ------------ | -------------------------------------------------------------------------- | --------- |
| `content`    | string (10–10,000 chars)                                                   | required  |
| `mode`       | `basic` \| `deep`                                                          | `basic`   |
| `dimensions` | string\[]                                                                  | all       |
| `domain`     | `general` \| `healthcare` \| `finance` \| `legal` \| `education` \| `code` | `general` |
| `policy`     | object (see [Policy](#policy-enforcement))                                 | none      |

`basic` is \~1 credit and under 1s; `deep` is \~3 credits and 2–5s and adds
explanations, issues, and suggestions.

#### Policy enforcement

Pass an optional `policy` to enforce per-dimension thresholds inline — the same
`Policy`/`Rule` model as the SDK. A rule fires when its dimension scores **below**
the threshold.

```json theme={null}
{ "rules": [
  { "dimension": "safety",   "threshold": 7.0, "action": "block" },
  { "dimension": "fairness", "threshold": 6.0, "action": "flag" }
] }
```

The response gains a `policy_outcome`:

```json theme={null}
{ "action": "block", "blocked": true, "source": "request",
  "triggered_rules": [ { "dimension": "safety", "threshold": 7.0, "action": "block", "score": 3.1 } ] }
```

`action` is the most severe fired action (`block` > `flag` > `warn` > `allow`).
**Precedence:** if the API key's application has a **dashboard policy enforced**,
that wins (`source: "application"`); otherwise the request `policy` is applied
(`source: "request"`). No extra credits beyond the eval mode. Fetch the
[`rail://framework/policy-schema`](#resources) resource for the full JSON Schema.

### `rail_check_compliance`

Check content against regulatory frameworks: `gdpr`, `ccpa`, `hipaa`,
`eu_ai_act`, `india_dpdp`, `india_ai_gov`. Up to 5 per call with a cross-framework
summary. 5–10 credits.

| Parameter    | Type            |
| ------------ | --------------- |
| `content`    | string          |
| `frameworks` | string\[] (1–5) |

### `rail_detect_injection`

Detect prompt injection in untrusted text before acting on it. Returns the
verdict only — never the analyzed text. 0.5 credits, under 500ms.

| Parameter | Type   |
| --------- | ------ |
| `text`    | string |

### `rail_evaluate_tool_call`

Evaluate a proposed tool call before executing it. Returns `allow`, `warn`, or
`block`. Treat `block` as a hard stop. 1.5–3.0 credits.

| Parameter   | Type              | Default  |
| ----------- | ----------------- | -------- |
| `tool_name` | string            | required |
| `arguments` | object            | required |
| `context`   | string            | none     |
| `mode`      | `basic` \| `deep` | `basic`  |

### `rail_scan_tool_result`

Scan a tool's output for PII and second-order injection. Returns a verdict, PII
types and offsets, and a redacted copy of the text — never raw values. 0.5–1.0
credits.

| Parameter   | Type   |
| ----------- | ------ |
| `tool_name` | string |
| `result`    | string |

### `rail_safe_regenerate`

Evaluate content and, if it scores below threshold, iteratively regenerate it
server-side until it passes (up to 5 iterations). Slow: tens of seconds, 1–9
credits.

| Parameter    | Type         | Default  |
| ------------ | ------------ | -------- |
| `content`    | string       | required |
| `threshold`  | float (0–10) | `7.0`    |
| `dimensions` | string\[]    | all      |

## India DPDP

### `rail_dpdp_scan`

Scan text for Indian personal data under the DPDP Act 2023: Aadhaar
(Verhoeff-validated), PAN, mobile, UPI, passport, voter ID, driving license,
IFSC, bank account, GSTIN, plus child signals and purpose drift.

| Parameter | Type                          | Default  |
| --------- | ----------------------------- | -------- |
| `text`    | string                        | required |
| `mode`    | `detect` \| `mask` \| `block` | `mask`   |

`detect` returns findings with offsets and masked values only; `mask` returns
the masked text; `block` returns a verdict.

### `rail_dpdp_gate`

Real-time DPDP processing gate. Returns `allow`, `block`, or `require_action`
enforcing child protection, cross-border transfer rules, and consent.

| Parameter         | Type                                                                                                       | Default         |
| ----------------- | ---------------------------------------------------------------------------------------------------------- | --------------- |
| `activity`        | `process_data` \| `make_decision` \| `share_data` \| `transfer_cross_border` \| `serve_ad` \| `track_user` | required        |
| `purpose`         | string                                                                                                     | required        |
| `data_categories` | string\[]                                                                                                  | none            |
| `user_id`         | string                                                                                                     | `agent-subject` |
| `session_id`      | string                                                                                                     | none            |

### `rail_dpdp_compliance`

DPDP workflow operations selected by `action`:

| `action`   | `payload` shape                                                      |
| ---------- | -------------------------------------------------------------------- |
| `emit`     | `{ "events": [{ "type", "data" }], "session_id"? }` (the only write) |
| `require`  | `{ "session_id", "workflow_step", "context"? }`                      |
| `evidence` | `{ "type", "params" }` (Pro+ only)                                   |
| `session`  | `{ "action": "create" \| "get", "config"? \| "session_id"? }`        |
| `timers`   | `{ "status"?, "type"?, "approaching_days"? }`                        |

Sessions are isolated per API key.

## Resources

Free, read-only, zero credits:

* `rail://framework/dimensions` — the 8 dimensions with definitions and the
  weights/thresholds configured for your application.
* `rail://account/capabilities` — your plan, enabled features, modes,
  frameworks, and limits.
* `rail://framework/policy-schema` — the JSON Schema for the `policy` parameter
  (valid dimensions, threshold range, actions), so agents can build valid
  policies without trial and error.

## Errors

Tool errors are structured (a JSON object with a `code`), never prose, so agents
can branch on them:

| `code`                 | When                              | Extra fields                            |
| ---------------------- | --------------------------------- | --------------------------------------- |
| `UNAUTHENTICATED`      | Missing or invalid API key        | —                                       |
| `INSUFFICIENT_CREDITS` | Not enough credits for the call   | `required`, `balance`                   |
| `RATE_LIMITED`         | Per-key rate limit hit            | `retry_after` (seconds, when available) |
| `CONTENT_TOO_HARMFUL`  | Content flagged critically unsafe | — (the content is never echoed back)    |

Block-style **verdicts** (e.g. `rail_evaluate_tool_call` returning `block`) are
returned as normal result data, not errors — only genuine failures use the codes
above.
