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

> ## Agent Instructions
> These docs cover three products: TrustGate (AI agent gateway), TrustGuard (runtime security), and TrustTest (AI red teaming). Start from each product overview for the definition and How it works. Prefer the .md URL next to a page in /llms.txt when you need the full article. Use /llms-full.txt for a single-file dump of the site.

# Kiro

> Configure TrustGuard agent hooks for Kiro and connect the Kiro agent to TrustGate over MCP

Kiro is an agentic IDE from AWS. Its agent can read repositories, write files,
run shell commands, and call external tools on the developer's machine.

TrustGuard agent hooks evaluate local prompts and actions.

## NeuralTrust controls

| Product | Scope | Controls |
| - | - | - |
| **[TrustGuard](https://docs.neuraltrust.ai/trustguard/overview.md)** | Evaluates prompts, tool calls, and tool results against an organization [policy](https://docs.neuraltrust.ai/trustguard/concepts/policies.md) through agent hooks on the developer's machine. | Monitor · Block · Ask on tool calls · Mask tool calls |
| **[TrustGate](https://docs.neuraltrust.ai/trustgate/overview.md)** | Exposes the MCP registries and tools assigned to an application. MCP (Model Context Protocol) connects Kiro to systems such as trackers, databases, and internal APIs. | Tool availability · application authentication · per-tool rate limits |

Install TrustGuard from the
[trustguard-kiro-plugin](https://github.com/NeuralTrust/trustguard-kiro-plugin)
repository, from a checkout or through MDM. Kiro hooks are defined per
workspace, so the hook files go into each project you want protected. Configure
TrustGate separately in Kiro's `mcp.json`.

## Deployment options

| Goal | Configuration | Location |
| - | - | - |
| Evaluate prompts, commands, file writes, MCP calls, and tool results against organization policy | **TrustGuard agent hooks** using the plugin's hook runtime and a managed `kiro.json` | Each developer machine, with hook files in each workspace; IT deploys the runtime and config by MDM |
| Centrally manage the MCP tools available to Kiro | **TrustGate MCP** using an `mcpServers` entry in `.kiro/settings/mcp.json` | Kiro connects to the remote TrustGate endpoint |

> [!WARNING]
>
> **Use separate credentials for TrustGuard and TrustGate.** The hooks use a
> `tgk_…` [collector](https://docs.neuraltrust.ai/trustguard/concepts/collectors.md) key in `kiro.json`. MCP
> authenticates as an application with OAuth or an `ag_…` API key. A `tgk_…` key does
> not authenticate MCP, and `kiro.json` does not accept MCP settings.

## Before you start

| Requirement | Notes |
| - | - |
| Egress from developer machines to `{TRUSTGUARD_BASE_URL}` | The console shows the [base URL](https://docs.neuraltrust.ai/trustguard/api/evaluate.md#base-url) for your workspace. |
| The **Kiro** collector type *(hooks path)* | **Agent Security → Collectors → Catalog → Coding agents → Kiro**. Create the `tgk_…` key on its **Auth** tab, where it is shown once, and assign the policy on the **Policies** tab. |
| Kiro IDE with agent hooks | Hooks run only in a **trusted** workspace. Verified on Kiro IDE 1.5.49. |
| `bash`, `curl`, and `python3` *(hooks path)* | The hook runtime is a bash script with a Python 3 helper (standard library only). All three ship with a stock macOS. |
| MDM *(optional)* | Use it to deploy the hook runtime, the managed `kiro.json`, and the workspace hook files. |
| An [MCP application](https://docs.neuraltrust.ai/trustgate/mcp/overview.md) *(MCP path)* | Bind the required registries, then copy the endpoint from its **Connect** tab. |
| Application credentials *(MCP path)* | Use OAuth, which requires no pasted credential, or an `ag_…` API key. |

Create the policy in **Observe** mode. Observe records decisions in **Activity**
without enforcing them. Review the results, then switch the policy to
**Enforce**. See [Policies](https://docs.neuraltrust.ai/trustguard/concepts/policies.md).

Developers do **not** need NeuralTrust accounts for the hooks path.

## Set up prompt and tool screening (TrustGuard)

### Install from a checkout (pilot)

```bash theme={null}
git clone https://github.com/NeuralTrust/trustguard-kiro-plugin.git
cd trustguard-kiro-plugin
make setup-key
make install-local WORKSPACE=/path/to/project
```

`make setup-key` writes `~/.trustguard/kiro.json` (`chmod 600`) and sends one
harmless test prompt to `/v1/evaluate`. It asks for four values:

| Prompt | Default |
| - | - |
| TrustGuard data-plane URL | `https://trustguard.neuraltrust.ai` |
| Collector API key | None. Paste the `tgk_…` key; input is hidden. On a re-run, Enter keeps the saved key |
| `fail_mode` | `closed` |
| `transform_action` | `mask` |

`make install-local WORKSPACE=…`:

* Copies the hook runtime (`trustguard-hook.sh`, `trustguard_hook.py`) to
  `~/.trustguard/kiro/`
* Writes `trustguard-prompt-submit.json`, `trustguard-pre-tool.json`, and
  `trustguard-post-tool.json` into `<workspace>/.kiro/hooks/`, with an
  **absolute** path to the runtime. Kiro runs hook commands with the workspace as
  cwd, so relative paths are unreliable

Then open the project in Kiro, trust the workspace when prompted, and run
**Developer: Reload Window**. The three hooks appear in the **Agent Hooks** panel.

Repeat `make install-local WORKSPACE=…` for every project you want protected;
the runtime is shared. Without `make`, run `scripts/setup-key.sh` and
`scripts/install.sh /path/to/project`.

### Deploy under MDM (enterprise)

An MDM deployment consists of three components:

| Piece | What to deploy |
| - | - |
| **Hook runtime** | `trustguard/trustguard-hook.sh` and `trustguard/trustguard_hook.py` from the repo, under a fixed directory (e.g. `~/.trustguard/kiro/`) |
| **API key config** | MDM-managed `kiro.json` (paths below) |
| **Workspace hooks** | The three `trustguard-*.json` hook files in each managed workspace, written with `scripts/install-hooks.py install <templates> <hook-script> <workspace>` |

**Managed key config.**

```json theme={null}
{
  "data_url": "https://<your-trustguard-host>",
  "api_key": "tgk_…",
  "fail_mode": "closed",
  "transform_action": "deny"
}
```

| OS | Managed config path |
| - | - |
| macOS | `/Library/Application Support/TrustGuard/kiro.json` |
| Linux | `/etc/trustguard/kiro.json` |
| Windows | `%ProgramData%\TrustGuard\kiro.json` |

When the managed file includes `api_key`, its `data_url`, `api_key`, and
`fail_mode` cannot be overridden by the user file or environment variables. See
[Configuration](#configuration).

## Set up governed tool access (TrustGate)

Kiro treats TrustGate as a **remote MCP server**: one `url` per MCP application,
and the agent sees the merged toolkit that application is routed to. Copy the
endpoint from the application's **Connect** tab:

```text theme={null}
https://<mcp-host>/<application-slug>/mcp
```

Add it to `.kiro/settings/mcp.json` (workspace) or `~/.kiro/settings/mcp.json`
(user). From the command palette, **Kiro: Open workspace MCP config (JSON)** and
**Kiro: Open user MCP config (JSON)** open the two files. When both exist, Kiro
merges them and the workspace file takes precedence.

**OAuth applications (recommended).** Only `url` is required:

```json theme={null}
{
  "mcpServers": {
    "TrustGate": {
      "url": "https://<mcp-host>/<application-slug>/mcp"
    }
  }
}
```

Kiro runs the browser-based OAuth flow on first connect, registering a client
against the discovery documents TrustGate publishes. Nothing has to be
registered per developer.

**API-key applications.** Send the application key as a header, and keep it out
of the file with a `${…}` environment reference:

```json theme={null}
{
  "mcpServers": {
    "TrustGate": {
      "url": "https://<mcp-host>/<application-slug>/mcp",
      "headers": {
        "X-AG-API-Key": "${TRUSTGATE_MCP_API_KEY}"
      }
    }
  }
}
```

**Private (Hybrid) data plane.** Add `"X-AG-Gateway-Slug": "<gateway-slug>"` to
`headers` unless the MCP host already scopes the
[gateway](https://docs.neuraltrust.ai/trustgate/concepts/gateways.md).

TrustGate tool calls pass through the TrustGuard hooks like any other MCP call.

## Verify

**Hooks.**

1. In Kiro, open the **Agent Hooks** panel and confirm `trustguard-prompt-submit`,
   `trustguard-pre-tool`, and `trustguard-post-tool` are listed.
2. Ask the agent to run a shell command.
3. Confirm the event in TrustGuard **Activity**.

Smoke-test the runtime (optional):

```bash theme={null}
echo '{"hook_event_name":"PreToolUse","tool_name":"execute_bash","tool_input":{"command":"echo hi"},"session_id":"s1","cwd":"/tmp"}' \
  | bash ~/.trustguard/kiro/trustguard-hook.sh pre-tool; echo "exit=$?"
```

Exit `0` means allowed; exit `2` means denied, with the reason on stderr.

**MCP.**

1. Open the MCP servers view in the Kiro panel and confirm **TrustGate** is
   connected.
2. Ask the agent to use a tool from a toolkit bound to that application.
3. Confirm the call in TrustGate **Activity**.

## Reference

### Coverage

| Surface | Monitor | Block | Redact |
| - | :-: | :-: | :-: |
| LLM input | ✅ | ⚠️ | ❌ |
| LLM output | ➖ | ➖ | ➖ |
| Tool call | ✅ | ✅ | ✅ |
| Tool result | ✅ | ✅ | ❌ |

TrustGuard can evaluate Kiro prompts, commands, file writes, and tool calls from
a local checkout during a pilot or from an MDM deployment.

**Session taint.** A blocked prompt or a blocked tool result taints the Kiro
chat. Every later tool call in that chat is denied locally, without calling the
API, until the developer starts a new chat. Taint markers live in
`~/.trustguard/logs/kiro/taint/`.

**Prompts.** Kiro ignores the exit code of `UserPromptSubmit` hooks today
([kirodotdev/Kiro#11050](https://github.com/kirodotdev/Kiro/issues/11050)), so a
blocked prompt still reaches the model. The plugin enforces the block through
session taint: no tool can run in that chat afterwards.

**Ask.** The result of an `ask` verdict depends on the event:

| Event | What an `ask` verdict does |
| - | - |
| `UserPromptSubmit` | Logged only; the prompt proceeds |
| `PreToolUse` | Kiro shows its approval prompt, with the reason `A TrustGuard policy needs your approval to continue.` |
| `PostToolUse` | Logged only |

**Masking.** On a DLP `transform` verdict for a tool call, `transform_action`
decides the outcome: `mask` (default) runs the tool with the masked input,
`ask` shows the masked input for approval, and `deny` blocks. If TrustGuard
returns no masked payload, the call is denied. A prompt cannot be rewritten; the
agent is told not to repeat the sensitive value. On a tool result, a `transform`
is logged, or taints the session when `transform_action` is `deny`.

**Limits.** Hooks run only in a trusted workspace and only for workspaces with
the hook files installed. Commands the developer types in Kiro's terminal do not
go through hooks; only agent actions are covered.

A `PostToolUse` block cannot erase output the tool already produced. The plugin
tells the agent to treat the result as untrusted, not to follow instructions in
it or repeat sensitive values, and taints the session.

The hooks do not evaluate model responses or tool declarations. Use TrustGate to
control which tools are available.

### What is evaluated

| Kiro event | TrustGuard | What you can stop | Enforcement |
| - | - | - | - |
| `UserPromptSubmit` | `protocol: llm`, `direction: input` | Jailbreaks ([Prompt Guard](https://docs.neuraltrust.ai/trustguard/detectors/content-security.md#prompt-guard)); secrets and PII pasted into the agent ([DLP](https://docs.neuraltrust.ai/trustguard/detectors/data-loss-prevention.md)) | **Observe + taint**: a block taints the session |
| `PreToolUse` (`execute_bash`, `execute_pwsh`) | `protocol: all`, `direction: input` | Dangerous or out-of-policy commands | **Block** (Kiro denies the call); `transform` rewrites the command with the masked value |
| `PreToolUse` (`fs_write`, MCP, and other tools) | `protocol: mcp`, `tools/call` | Secrets written to files; risky MCP tool calls | **Block**, **Ask**, or masked arguments |
| `PostToolUse` | `protocol: mcp`, tool result, `direction: output` | [Indirect prompt injection](https://docs.neuraltrust.ai/trustguard/detectors/agent-mcp-security.md) in MCP or tool output | **Block** with a reason, and the session is tainted |

Every hook calls [`POST /v1/evaluate`](https://docs.neuraltrust.ai/trustguard/api/evaluate) with the
collector `tgk_…` key, and the policy's
[detectors](https://docs.neuraltrust.ai/trustguard/concepts/detectors.md) decide the verdict.

Kiro names MCP tools `mcp_<server>_<tool>`. When the server is listed in the
workspace or user `mcp.json`, the plugin strips the server prefix, so
`params.name` is the `<tool>` segment; otherwise the full name is sent. Gate on
the short tool name.

### Configuration

**`kiro.json` (TrustGuard hooks only).** `~/.trustguard/kiro.json` (`chmod 600`;
path overridable with `TRUSTGUARD_KIRO_CONFIG`). It never holds MCP values.

| Key | Default | Env override | Meaning |
| - | - | - | - |
| `data_url` | — | `TRUSTGUARD_DATA_URL` | TrustGuard data plane that serves `/v1/evaluate` |
| `api_key` | — | `TRUSTGUARD_API_KEY` | Collector key (`tgk_…`) |
| `fail_mode` | `open` | `TRUSTGUARD_FAIL_MODE` | `closed` denies every tool call when TrustGuard is unreachable, returns an error, or the config is broken. `make setup-key` writes `closed` |
| `transform_action` | `mask` | `TRUSTGUARD_TRANSFORM_ACTION` | `mask`, `ask`, or `deny`. See [Coverage](#coverage) |
| `timeout_ms` | `5000` | `TRUSTGUARD_TIMEOUT_MS` | Per-call timeout |
| `max_content_bytes` | `262144` | | Tool output sent to TrustGuard is clipped to this size |
| `consumer_id` | — | `TRUSTGUARD_CONSUMER_ID` | Sent as `consumer_id` only when set |
| `user_email` | — | | Sent as `attributes.user.email` only when set |
| `events` | all on | | Turn events off, e.g. `{"PostToolUse": false}` |
| `skip_tools` | `[]` | | Tool names never sent to TrustGuard |
| `shell_tools` | `["execute_bash","execute_pwsh"]` | | Tools evaluated as shell commands |
| `debug` | `false` | `TRUSTGUARD_DEBUG=1` | Log every call, including the request payload |

Precedence: environment > user file > managed file > default. When the managed
file includes `api_key`, `data_url`, `api_key`, and `fail_mode` are **locked**.

**`mcp.json` (TrustGate only).** Two scopes:

| Scope | Path | Use it for |
| - | - | - |
| **User** | `~/.kiro/settings/mcp.json` | An application every workspace should reach |
| **Workspace** | `.kiro/settings/mcp.json` | An application tied to one codebase; takes precedence over the user file |

**Deployment ownership.**

| Component | Owner | Configuration |
| - | - | - |
| **Hook runtime** | IT / MDM, or `make install-local` for a pilot | `trustguard-hook.sh` and `trustguard_hook.py` under `~/.trustguard/kiro/` |
| **Hooks config** | IT / MDM | `kiro.json` with the org `tgk_…` key |
| **Workspace hooks** | IT / MDM, or the developer | `.kiro/hooks/trustguard-*.json` in each workspace |
| **MCP config** | IT or developer | A `TrustGate` entry in `mcp.json` |

### Attributes

* `attributes.collector.type = "ide"`
* `attributes.source.application = "kiro-plugin"`
* `attributes.kiro`: the non-content hook fields, such as the event name and cwd
* `attributes.tool.name` for shell commands and tool results; for MCP tool calls
  the name is on the payload (`params.name`)
* `consumer_id` and `attributes.user.email` only when set in `kiro.json`. Kiro
  does not expose the account email to hooks

Set `consumer_id` (for example through MDM or `TRUSTGUARD_CONSUMER_ID`) to get
per-developer attribution in **Activity**.

Gate on `source.application` and/or `tool.name` / `tool.command`.

### Troubleshooting

| Symptom | Cause |
| - | - |
| Hooks never fire | The workspace is not trusted, or the window was not reloaded after install. Check that `.kiro/hooks/trustguard-*.json` exist and point at an existing `~/.trustguard/kiro/trustguard-hook.sh` |
| Every tool call is denied with "session is tainted" | Expected after a block in that chat. Start a new chat |
| Every tool call is denied with "fail\_mode is closed" | TrustGuard is unreachable or the config is incomplete. Run `make setup-key` again to re-run the self-test |
| A blocked prompt still reached the model | Expected. Kiro cannot block prompts yet; the session is tainted instead. See [Coverage](#coverage) |
| A project is not protected | Hooks are per workspace. Run `make install-local WORKSPACE=…` for that project |
| No events in **Activity** | No policy assigned to the collector, or `kiro.json` is missing or has the wrong `data_url` |
| Server connects, no tools | Application has no bound registries, tool restrictions exclude everything, or the upstream connect link was never authorized |
| `401` / repeated login | Wrong plane URL, revoked `ag_…` key, or `X-AG-Gateway-Slug` missing on Hybrid |

**Logs.** The plugin log is `~/.trustguard/logs/kiro/calls.jsonl`. By default it
records only blocks, denials, taints, and errors, without content. Set
`"debug": true` to log every call with its request; this can include the
sensitive data TrustGuard is masking, so turn it off afterwards. The API key is
never logged. Kiro's own log shows whether hooks fired and what they returned:
`~/Library/Application Support/Kiro/logs/<timestamp>/window*/exthost/kiro.kiroAgent/Kiro Logs.log`.

## Related

* [Policies: Gates](https://docs.neuraltrust.ai/trustguard/concepts/policies.md#gates): Ask and Block configuration
* [Evaluate API](https://docs.neuraltrust.ai/trustguard/api/evaluate.md): requests sent by the hooks
* [MCP overview](https://docs.neuraltrust.ai/trustgate/mcp/overview.md): applications, catalog merging, and upstream authentication
* [TrustGate authentication](https://docs.neuraltrust.ai/trustgate/concepts/auth.md): API key and OAuth2 authentication for MCP applications
* [How it works](https://docs.neuraltrust.ai/trustguard/how-it-works.md): what each collector can enforce
* [Plugin repository](https://github.com/NeuralTrust/trustguard-kiro-plugin): source, install scripts, and tests
* [Kiro hooks docs](https://kiro.dev/docs/hooks/) · [Kiro MCP docs](https://kiro.dev/docs/mcp/configuration/)


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