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

# Bigeye

> Check MCP tool calls on TrueFoundry AI Gateway against Bigeye's Access Decision API before they run, and block calls that touch warehouse data Bigeye flags.

Deploy the [`integrations/bigeye`](https://github.com/truefoundry/integrations-custom-guardrails/tree/main/integrations/bigeye) **FastAPI wrapper** on any **public HTTPS** host, such as a TrueFoundry Service or a Docker container. The AI Gateway calls it on the **MCP Tool Pre-Invoke** hook through the [Custom Guardrail](https://www.truefoundry.com/docs/ai-gateway/custom-guardrails.md) contract. The wrapper asks [Bigeye](https://www.bigeye.com) whether the tool call may touch the data it names and returns a `verdict` JSON body on HTTP 200.

> [!NOTE]
>
> Source repository: [`truefoundry/integrations-custom-guardrails/integrations/bigeye/`](https://github.com/truefoundry/integrations-custom-guardrails/tree/main/integrations/bigeye). It contains the Dockerfile, deploy script, example gateway YAML, and tests referenced below.

## What is Bigeye?

[Bigeye](https://www.bigeye.com) is an AI Trust platform for the enterprise, built on its data observability and governance products. It maps which data your AI agents access and enforces policies that keep agents within approved data boundaries. Its [Access Decision API](https://docs.bigeye.com/docs/access-decision-api) takes the tables, columns or SQL statements an agent is about to access and returns a decision based on catalog signals, such as open data-quality issues and sensitive-data findings, and optional Bigeye policies: `ALLOW`, `WARN`, `REQUIRE_CONFIRMATION` or `DENY`. Bigeye records every decision in Agent Trust Hub, an auditable record of the data agents access.

### What the integration does

Before an MCP tool call runs, the wrapper reads the SQL, table names and column names from the tool's arguments and sends them to Bigeye's Access Decision API. It blocks the call when Bigeye's overall decision is in `block_on`, which defaults to `DENY` and `REQUIRE_CONFIRMATION`. MCP pre-invoke guardrails run before the tool, so a blocked tool never runs.

* With the default `block_on`, `ALLOW` and `WARN` pass, and so do assets that are unresolved or `UNSPECIFIED` (see [Table and column names](#table-and-column-names)). Add `UNSPECIFIED` to `block_on` to block them.
* A guardrail can only allow or block a call, so `REQUIRE_CONFIRMATION` blocks the call by default. Remove it from `block_on` to let those calls through. To require human approval for specific tools, use [MCP Tool Approvals](https://www.truefoundry.com/docs/ai-gateway/mcp/mcp-tool-approval.md).
* The wrapper makes one Bigeye call per tool call and never retries.
* If the arguments hold no SQL, table or column names, the wrapper doesn't call Bigeye and allows the call. Set `on_nothing_to_check` to change this.

## Architecture

```
MCP client or agent
       │  tools/call
       ▼
TrueFoundry AI Gateway ──(MCP Tool Pre-Invoke policy)──► Bigeye wrapper ──► Bigeye Access Decision API
       │                                                  <wrapper-host>       <your-bigeye-host>
       │ ◄──────────────── verdict: allow or block ──────────────┘
       ▼
MCP server: the tool runs only when the verdict allows it
```

The wrapper returns `HTTP 200` for both allow and block and puts the decision in the JSON body. Errors return a non-2xx status, which the gateway handles according to the guardrail's enforcing strategy. See [Custom guardrail response contract](https://www.truefoundry.com/docs/ai-gateway/custom-guardrails.md#custom-guardrail-response-contract).

## Response contract

| HTTP | Body | Meaning |
| - | - | - |
| `200` | `{"verdict": true, "bigeye": {...}}` | Allow: Bigeye's decision isn't in `block_on`, or there was nothing to check and `on_nothing_to_check` is `allow` |
| `200` | `{"verdict": false, "message": "Bigeye DENY...", "bigeye": {...}}` | Block: Bigeye's overall decision is in `block_on`, or there was nothing to check and `on_nothing_to_check` is `block` |
| `401` | error JSON | No Bearer token (the Bigeye API key) |
| `422` | error JSON | The payload has the wrong shape. Only field locations are returned; the input isn't echoed |
| `500` | error JSON | Misconfiguration, including a `bigeye_url` host that `BIGEYE_ALLOWED_HOSTS` doesn't allow |
| `502` | error JSON | Bigeye returned a non-2xx status (including a rejected key), a non-JSON body, or an unrecognized decision |
| `504` | error JSON | Bigeye didn't answer within `bigeye_timeout_ms` |

The wrapper never returns 429 or 503, because the gateway retries those. A 429 or 503 from Bigeye becomes 502.

The `bigeye` object lands on the guardrail span in the gateway trace: `{checked, span_external_id, overall_decision, assets: [{name, decision}], unresolved_count, assets_found, latency_ms}`, or `{checked: false, reason}` when there was nothing to check. It never includes SQL text or data values; SQL assets are named `<sql>`.

## Wrapper endpoints

| Path | What it does |
| - | - |
| `POST /mcp-pre-invoke` | MCP tool pre-invoke rail (Operation: Validate) |
| `GET /health` | Health check |
| `GET /debug/loaded-config` | Non-secret runtime summary: wrapper version, allowed Bigeye hosts and config defaults |

The guardrail's Bearer token is your Bigeye API key. The wrapper forwards it to Bigeye as `Authorization: apikey <key>` (set by `auth_scheme`) and stores nothing, so there's no separate wrapper key.

## Prerequisites

* **Bigeye API key**: Bigeye recommends a service-account key scoped to the workspace. The key needs at least Edit access to the target workspace. See [Using API Keys](https://docs.bigeye.com/docs/using-api-keys).
* **Bigeye workspace ID**.
* **Data source name and warehouse type**, as Bigeye shows them for the data source your MCP server queries, for example a Snowflake source.
* **Public HTTPS host for the wrapper** that the AI Gateway can reach. The wrapper must also reach your Bigeye host over HTTPS.
* The MCP server for that data source, registered in the AI Gateway.

## Setup

**1. Deploy the wrapper**

```bash theme={"dark"}
git clone https://github.com/truefoundry/integrations-custom-guardrails
cd integrations-custom-guardrails/integrations/bigeye
```

The wrapper needs no secrets at deploy time: the Bigeye API key arrives with each request from the guardrail config.

> [tab] Docker
>
> ```bash theme={"dark"}
> docker build -t bigeye-guardrails-tfy .
> docker run -d -p 8000:8000 bigeye-guardrails-tfy
> ```
>
> Run it on any platform with a public HTTPS URL (ECS, Cloud Run, Kubernetes, on-prem) and put TLS in front of it. The AI Gateway must reach `https://<wrapper-host>/mcp-pre-invoke`.

> [tab] TrueFoundry Service
>
> Set `TFY_WORKSPACE_FQN`, `TFY_PUBLIC_HOST` and, on a shared host, `TFY_PUBLIC_PATH` in `.env`, then deploy:
>
> ```bash theme={"dark"}
> cp .env.example .env
> python3.11 -m venv .venv
> .venv/bin/pip install -r requirements-dev.txt
> .venv/bin/pip install -U truefoundry
> .venv/bin/tfy login --host https://<your-truefoundry-host>
> .venv/bin/python deploy.py --wait
> ```

Optional environment variables on the wrapper:

| Variable | Default | Purpose |
| - | - | - |
| `BIGEYE_ALLOWED_HOSTS` | `*.bigeye.com` | Comma-separated https hosts the wrapper may send the Bigeye API key to. Exact hostnames, or `*.domain` for any subdomain of `domain` |
| `LOG_PAYLOADS` | `false` | Log incoming payloads with identity values redacted |
| `LOG_LEVEL` | `info` | Log level |

Check the deployment:

```bash theme={"dark"}
curl https://<wrapper-host>/health
# -> {"status":"ok"}
curl https://<wrapper-host>/debug/loaded-config
```

**2. Register a Custom guardrail**

**AI Gateway → Guardrails → Add New Guardrails Group** → **Custom**. Name the group, for example `bigeye`, and add one config per Bigeye data source, because `source_name` and `warehouse_type` apply to every table, column and SQL statement in a call.

| Field | Value |
| - | - |
| **Name** | `access-decision` |
| **Operation** | Validate |
| **Target** | Request |
| **Enforcing Strategy** | Enforce But Ignore On Error |
| **URL** | `https://<wrapper-host>/mcp-pre-invoke` |
| **Auth Data** | Custom Bearer Auth, with your Bigeye API key as the token |
| **Config** | The JSON below |

Use **Enforce But Ignore On Error** while you pilot. For production access to regulated data, use **Enforce**, so calls are blocked when the check can't run. Under **Enforce**, a wrapper outage blocks every tool the policy covers, not only SQL tools.

```json theme={"dark"}
{
  "bigeye_url": "https://<your-bigeye-host>",
  "workspace_id": "<bigeye-workspace-id>",
  "source_name": "<bigeye-data-source-name>",
  "warehouse_type": "<warehouse-type, for example snowflake>",
  "block_on": ["DENY", "REQUIRE_CONFIRMATION"]
}
```

See [Config reference](#config-reference) for every key.

The same group as YAML, for `tfy apply`:

```yaml theme={"dark"}
name: bigeye
type: provider-account/guardrail-config-group
integrations:
  - name: access-decision
    type: integration/guardrail-config/custom
    target: request
    operation: validate
    enforcing_strategy: enforce_but_ignore_on_error
    auth_data:
      type: bearer-auth
      bearer_token: <tfy-secret://... reference to your Bigeye API key>
    config:
      url: https://<wrapper-host>/mcp-pre-invoke
      config:
        bigeye_url: https://<your-bigeye-host>
        workspace_id: <bigeye-workspace-id>
        source_name: <bigeye-data-source-name>
        warehouse_type: <warehouse-type>
        block_on: [DENY, REQUIRE_CONFIRMATION]
```

**3. Create a guardrail policy**

In **AI Gateway → Policies → Guardrails**, add a [guardrail policy](https://www.truefoundry.com/docs/ai-gateway/guardrails-configuration.md) that targets the data source's MCP server and runs the guardrail on **MCP Tool Pre-Invoke**:

```yaml theme={"dark"}
type: gateway-guardrails-config
name: bigeye-access-decision
when:
  target:
    operator: or
    conditions:
      mcpServers:
        condition: in
        values: [<mcp-server-name>]
llm_input_guardrails: []
llm_output_guardrails: []
mcp_tool_pre_invoke_guardrails: [bigeye/access-decision]
mcp_tool_post_invoke_guardrails: []
```

Listing only the server covers every tool on it. To cover a single tool, use `<mcp-server-name>:<tool-name>` as the value.

> [!WARNING]
>
> A guardrail policy is the only way to attach this guardrail. The `X-TFY-GUARDRAILS` header and guardrails pinned to a model don't cover MCP hooks.

## Config reference

The wrapper reads the guardrail's **Config** JSON.

| Key | Default | Notes |
| - | - | - |
| `bigeye_url` | `https://app.bigeye.com` | Your Bigeye host. It must be allowed by `BIGEYE_ALLOWED_HOSTS` |
| `workspace_id` | required | Bigeye workspace ID |
| `auth_scheme` | `apikey` | `apikey` or `bearer`. Bigeye rejects personal API keys sent as Bearer |
| `source_name` | none | Bigeye data source name. Required when the arguments contain SQL |
| `warehouse_type` | none | Bigeye warehouse type, sent as `sourceType`: a `DATABASE_TYPE_*` value such as `DATABASE_TYPE_SNOWFLAKE`, or a plain name such as `snowflake`. Omitted when unset |
| `block_on` | `["DENY", "REQUIRE_CONFIRMATION"]` | Decisions that block the call: any of `DENY`, `REQUIRE_CONFIRMATION`, `WARN` and `UNSPECIFIED`, as short names or with the `ACCESS_DECISION_` prefix. `UNSPECIFIED` also blocks when any asset is `UNSPECIFIED` or unresolved; see [Table and column names](#table-and-column-names) |
| `evaluate_policy` | `false` | Enforce Bigeye policies inline. With `false`, the verdict comes from catalog signals, and Bigeye evaluates policies after the call and shows the results in Agent Trust Hub. See [Policy mode](#policy-mode) |
| `bigeye_timeout_ms` | `3500` | 100 to 30000. Keep it below the gateway's guardrail timeout (about 5 seconds) |
| `agent_id` | `truefoundry-gateway` | Agent name Bigeye records decisions under for user callers. For virtual accounts and agents, their slug is used instead |
| `operation` | `mcp_tool_call` | Operation label shown in Bigeye |
| `sql_keys` | `["query", "sql", "statement"]` | Top-level argument names that hold SQL. The first non-empty one is used |
| `table_keys` | `["tables", "table"]` | Top-level argument names that hold table names |
| `column_keys` | `["columns", "column"]` | Top-level argument names that hold column names |
| `on_nothing_to_check` | `allow` | `allow` or `block` when no configured argument holds SQL, tables or columns. Use `block` only on a policy scoped to the SQL tool itself; on a whole server it blocks every other tool |

Setting `sql_keys`, `table_keys` or `column_keys` replaces that list's default; the other two keep theirs. Name values may be a list, a JSON-array string or a comma-separated string. For users, the caller's username is sent to Bigeye for audit.

## Table and column names

* **Use the names Bigeye's catalog shows for the data source.** Table and column arguments are sent to Bigeye as they are, so they must match the catalog. For some Snowflake sources that's `schema.table` and `schema.table.column`, with no database prefix. Check the catalog for your source.
* **Unresolved and `UNSPECIFIED` assets are allowed by default.** If Bigeye can't resolve an object, for example because `source_name` doesn't match a data source, it lists the object as unresolved. If it recognizes an asset that isn't in its catalog, it returns the asset with decision `UNSPECIFIED` and a source name such as `Unknown Snowflake`. Neither counts toward the overall decision, so the call goes through. The trace's `bigeye` output shows `unresolved_count` above 0, or the asset with `UNSPECIFIED`.
* **Add `UNSPECIFIED` to `block_on` to block them.** The call is then blocked when any asset is unresolved or `UNSPECIFIED`, so agents only touch data Bigeye has decided on. Test it on your workspace first: the wrapper counts an asset that Bigeye returns without its own decision as `UNSPECIFIED`, so check that cataloged tables show a decision other than `UNSPECIFIED` in the trace's `assets` list.
* **SQL is parsed by Bigeye.** For SQL arguments, Bigeye parses the statement itself and resolves the tables and columns it references against the data source in `source_name`.

## Policy mode

By default (`evaluate_policy: false`), the verdict comes from catalog signals such as open data-quality issues and sensitive-data findings. Bigeye still evaluates your workspace policies after the call and shows the results in Agent Trust Hub, but they don't affect the verdict.

Set `evaluate_policy: true` to enforce policies inline. The overall decision is then `DENY` if any policy matches and `ALLOW` otherwise, and catalog signals don't affect it. Inline evaluation adds latency that grows with the number of workspace policies, so benchmark it against `bigeye_timeout_ms`, which must stay below the gateway's guardrail timeout.

Bigeye's `access.policy.always_evaluate_synchronously` Advanced Setting forces inline evaluation on every request, so policy mode applies even when `evaluate_policy` is `false`. See Policy Evaluation in Bigeye's [Access Decision API docs](https://docs.bigeye.com/docs/access-decision-api).

## Verify the integration

**1. A query on a clean table runs**

From an MCP client connected to the server's gateway endpoint, call the SQL tool on a table with no open data-quality issues, for example `SELECT * FROM <schema>.<clean-table> LIMIT 10`. The tool runs and returns rows. In **AI Gateway → Monitor → Request Traces**, the guardrail span shows the check passed, with `overall_decision: ALLOW` in its `bigeye` output.

**2. A query on a table with open issues is blocked**

Call the same tool on a table with open data-quality issues in Bigeye, for example `SELECT <column> FROM <schema>.<flagged-table> LIMIT 10`. The gateway blocks the call and the tool doesn't run. The guardrail span shows the check failed, with `overall_decision: DENY`.

`DENY` is Bigeye's default for open issues and sensitive-data findings. If your workspace has lowered either setting in Advanced Settings, you'll see that decision instead, and `WARN` passes with the default `block_on`.

**3. Check Bigeye**

In Bigeye, open the [Agent Registry](https://docs.bigeye.com/docs/agent-registry) (Agent Trust > Registry) and click the agent (`agent_id`, `truefoundry-gateway` by default). Agent Trust must be enabled for your workspace. The agent's conversations list the decisions. Open a conversation to see each table with a status: a green check for no concerns, a yellow triangle for warnings, or a red triangle for a table that shouldn't be accessed. See the [AI Conversation Page](https://docs.bigeye.com/docs/ai-conversation-page).

Bigeye stores each decision with the `span_external_id` from the trace's `bigeye` output. To find the record for a span, filter the [access decision list endpoint](https://docs.bigeye.com/docs/access-decision-api) by `span_external_id`.

## Limitations

* **No masking or redaction.** The integration allows or blocks tool calls. It doesn't change arguments or results.
* **One guardrail config per Bigeye data source.** `source_name` and `warehouse_type` apply to every object in a call, so add a config and a policy for each data source.
* **Only top-level argument keys are read.** Nested arguments such as `{"params": {"query": ...}}` aren't read. Change the names with `sql_keys`, `table_keys` and `column_keys`.
* **MCP servers passed by URL in agent requests skip guardrails.** Register the MCP server in the AI Gateway so the policy can match it.
* **Fails open under Enforce But Ignore On Error.** If the wrapper or Bigeye errors or times out, the tool call goes through. Look for `ignored_error` on the guardrail span in traces. Use **Enforce** to block tool calls when the check can't run.

## Troubleshooting

> [accordion] 502 with the Bigeye key rejected
>
> The wrapper returns 502 with `"error": "bigeye_error"` when Bigeye rejects the key. If the wrapper logs say Bigeye returned 500 and couldn't decode the key (a base64 error), `auth_scheme` is usually `bearer` for a personal API key, or the key was truncated. Set `"auth_scheme": "apikey"` (the default) and re-paste the key into **Custom Bearer Auth**.

> [accordion] 500 for a host outside the allowlist
>
> The wrapper returns 500 with `"error": "configuration_error"` and `bigeye_url is not an allowed Bigeye host` when `bigeye_url` isn't covered by `BIGEYE_ALLOWED_HOSTS`. The default allows `*.bigeye.com`. For another host, set `BIGEYE_ALLOWED_HOSTS` on the wrapper and redeploy. The wrapper only calls https hosts and doesn't follow redirects.

> [accordion] Calls are allowed with unresolved or UNSPECIFIED assets
>
> The guardrail passes, but the trace's `bigeye` output shows `unresolved_count` above 0 or assets with `UNSPECIFIED`, and `overall_decision: UNSPECIFIED` when nothing has a decision.
>
> * **Unresolved:** Bigeye couldn't resolve the object. Check that `source_name` and `warehouse_type` match the data source, and use the names Bigeye's catalog shows for it (see [Table and column names](#table-and-column-names)).
> * **`UNSPECIFIED`:** Bigeye recognized the asset but it isn't in the catalog. Check that the data source is cataloged in Bigeye and covers the asset.

> [accordion] ignored\_error on the guardrail span
>
> The wrapper was unreachable, returned an error, or didn't answer within the gateway's guardrail timeout, so **Enforce But Ignore On Error** let the call through. Check `https://<wrapper-host>/health`, the wrapper logs and the error status (see [Response contract](#response-contract)), and keep `bigeye_timeout_ms` below the gateway's timeout.

## Reference

| Item | Value |
| - | - |
| Source repo | [`truefoundry/integrations-custom-guardrails/integrations/bigeye`](https://github.com/truefoundry/integrations-custom-guardrails/tree/main/integrations/bigeye) |
| Bigeye | [bigeye.com](https://www.bigeye.com) |
| Access Decision API | [docs.bigeye.com/docs/access-decision-api](https://docs.bigeye.com/docs/access-decision-api) |
| Bigeye API keys | [docs.bigeye.com/docs/using-api-keys](https://docs.bigeye.com/docs/using-api-keys) |
| Agent Trust Hub pages | [docs.bigeye.com/docs/agent-trust-pages](https://docs.bigeye.com/docs/agent-trust-pages) |
| Wrapper URL | `https://<wrapper-host>/mcp-pre-invoke` |
| Hook | MCP Tool Pre-Invoke (`mcp_tool_pre_invoke_guardrails`), attached through a guardrail policy |
| Selector | `bigeye/<config-name>` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.