# Grok

Sign in from Grok chat. Grok's CLI and API send the agent credential as a bearer token.

The same server serves Grok chat, the Grok CLI, and the Grok API: `https://api.gnesi.io/api/mcp`.

## Grok chat

Add a custom connector with that URL. The click path for Grok on the web and in the Grok app is on [MCP](/integrations/mcp). Connect opens the Gnesi page. Slide to connect, and that same window returns to Grok. Do not paste the agent credential into the chat.

## Grok CLI

```bash
grok mcp add --transport http gnesi https://api.gnesi.io/api/mcp --header "Authorization: Bearer $GNESI_CREDENTIAL"
```

Use `Authorization: Bearer`. A header named `x-api-key` makes that CLI start a sign-in it cannot finish with a credential.

Or in `~/.grok/config.toml`:

```toml
[mcp_servers.gnesi]
url = "https://api.gnesi.io/api/mcp"
enabled = true

[mcp_servers.gnesi_headers]
Authorization = "Bearer YOUR_CREDENTIAL"
```

Start a new session after saving. `grok mcp list` should show `gnesi`.

## Grok API

Register Gnesi as a remote MCP tool. The `authorization` value is `Bearer` plus the agent credential.

```json
{
  "type": "remote_mcp",
  "server_label": "gnesi",
  "server_url": "https://api.gnesi.io/api/mcp",
  "authorization": "Bearer YOUR_CREDENTIAL"
}
```

Put that object in the `tools` array. Tool names on the CLI are prefixed with the server name. The API follows xAI's remote MCP prefix. The underlying tools are the ones on [MCP](/api/mcp).
