# Connect Lexi to an MCP client

This is an agent-readable setup guide, not an installable Codex or Claude skill package. Do not download or install it. Use it once to configure Lexi's remote MCP server; after that, the MCP connection advertises its tools and runtime instructions directly.

## Safety rules

- Never ask the user to paste an Agent key into chat.
- Never echo, log, or commit an Agent key.
- The user must create the key in Lexi Settings and store it locally as `LEXI_AGENT_KEY`.
- Lexi shows the full key only once. If it is lost, revoke it and create another.

Open Agent key settings:

`https://app.meetlexi.app/?nav=settings.agents`

Lexi MCP endpoint:

`https://api.meetlexi.app/mcp`

## Codex

Add this to `~/.codex/config.toml`:

```toml
[mcp_servers.lexi]
url = "https://api.meetlexi.app/mcp"
bearer_token_env_var = "LEXI_AGENT_KEY"
default_tools_approval_mode = "writes"
```

Ask the user to set `LEXI_AGENT_KEY` in the environment that launches Codex, restart Codex, and use `/mcp` to verify the connection.

## Claude Code

Add this to the project's `.mcp.json`, or configure the equivalent user-scoped server:

```json
{
  "mcpServers": {
    "lexi": {
      "type": "http",
      "url": "https://api.meetlexi.app/mcp",
      "headers": {
        "Authorization": "Bearer ${LEXI_AGENT_KEY}"
      }
    }
  }
}
```

Ask the user to set `LEXI_AGENT_KEY` in the environment that launches Claude Code, restart Claude Code, and run `claude mcp get lexi` to verify the connection.

## Using Lexi

The MCP server exposes these tools:

- `search_hub`: semantic search across the user's saved knowledge. Prefer this for topic or meaning-based questions.
- `list_items`: list recent items with optional filters.
- `get_item`: read one saved item by UUID.
- `save_link`: save an HTTP or HTTPS URL.
- `save_note`: save a plain-text or Markdown note.
- `get_quota`: inspect the user's current plan, credits, and limits.

For `save_link` and `save_note`, generate one UUID before the first attempt and reuse that UUID for every retry. Generating a new UUID creates a new item.
