# Connect

Connecting an agent makes your rules available to it. See [how gnt works](/docs/concepts) for how
that pairs with `check_action` to actually stop an unapproved action.

## claude.ai connectors

In claude.ai, go to Settings → Connectors → Add custom connector. Paste your MCP endpoint (from
`gnt keys create`) as the server URL, then add an `Authorization: Bearer gnt_live_xxxx` header with
your key. All 5 tools become available in any chat once it's connected.

## Claude Code

Create a named key in the dashboard and copy its one-command setup, or print the same artifact from
the CLI:

```bash
gnt keys create "Claude Code — production" --client claude-code
```

That command connects the MCP server. Claude Code is also the one supported client where gnt can
install a host hook that mechanically checks tool calls before they run:

```bash
gnt hooks install
```

## Codex

Choose **Codex** when creating an agent key. gnt prints the supported `~/.codex/config.toml` remote
server entry with its authorization header. The Codex app, CLI, and IDE extension share that MCP
configuration. Codex does not currently expose a CLI flag that durably
stores this static authorization header, so gnt labels this honestly as **Copy config**, not as a
one-command connection.

```bash
gnt keys create "Codex — production" --client codex
```

This makes `check_action` and the other gnt tools available. gnt does not install a Codex host
interceptor today, so your runtime or tool adapter must call `check_action` before side effects.

## Gemini CLI

Gemini CLI supports a remote streamable HTTP MCP server with an authorization header. The dashboard
and CLI both generate its supported one-command setup:

```bash
gnt keys create "Gemini CLI — recruiting" --client gemini
```

This connects the tools only. gnt does not install a Gemini host interceptor today; enforce
`check_action` in the runtime or tool adapter.

## Generic MCP client

Choose **Generic MCP** for a portable server URL and authorization-header template:

```bash
gnt keys create "Support runtime" --client generic
```

MCP access alone does not intercept the client&apos;s other tools. The host must place gnt at its action
boundary.

## Raw MCP client (Python)

Talk to the endpoint directly over streamable HTTP with the official MCP SDK.

```python
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

URL = "https://api.gntai.dev/mcp/"
TOKEN = "gnt_live_xxxx"

async with streamablehttp_client(
    URL, headers={"Authorization": f"Bearer {TOKEN}"}
) as (read, write, _):
    async with ClientSession(read, write) as session:
        await session.initialize()
        result = await session.call_tool(
            "search_rules", {"query": "refund window"}
        )
```

## OpenAI-compatible agent

The Responses API supports remote MCP servers as a tool type. Point it at the same endpoint and
header.

```python
from openai import OpenAI

client = OpenAI()
resp = client.responses.create(
    model="gpt-4.1",
    input="What is our refund policy?",
    tools=[{
        "type": "mcp",
        "server_label": "gnt-brain",
        "server_url": "https://api.gntai.dev/mcp/",
        "headers": {"Authorization": "Bearer gnt_live_xxxx"},
    }],
)
```

## OpenClaw

Run `gnt connect openclaw` to detect a local install and write this for you, or add it to
`~/.openclaw/openclaw.json` by hand and export `GNT_MCP_KEY` before starting the gateway. Connecting
only makes the tools available, so pair it with the [check_action skill](/docs/enforce) below:
that's what gets OpenClaw to actually call it before acting, not just have it on hand.

```json
{
  "mcp": {
    "servers": {
      "gnt-brain": {
        "url": "https://api.gntai.dev/mcp/",
        "transport": "streamable-http",
        "headers": { "Authorization": "Bearer ${GNT_MCP_KEY}" }
      }
    }
  }
}
```

## Hermes Agent

Nous Research's Hermes Agent reads MCP servers straight out of its own config file. Run
`gnt connect hermes` to wire it up, or see the [Hermes Agent](/docs/hermes-agent) page for the full
walkthrough, including the skill that gets Hermes to call `check_action` before it acts.
