# Connect a client

This page gives the exact set-up for each AI client: Claude Code, Codex, Cursor, GitHub Copilot in VS Code, Hermes Agent, and any other client that speaks MCP.

Every client reaches your workspace at one address, `https://api.duplex.matterspace.ai/mcp`. Most clients hold a key from the console, and the console's **Get started** screen shows every line below with your own key already in it. A client that supports MCP's own sign-in needs no key: the last section of this page says how it connects.

## Two ways to connect

| | **MCP only** | **The client's package** (MCP and hooks) |
| --- | --- | --- |
| What you install | Nothing: one line in the client's settings | The package for your client |
| How the agent gets its context | It calls `duplex_context` at the start of a turn and `duplex_observe` at its end, as the server tells it | The hooks give each prompt its context and record each turn, whatever the model does |
| Your rules on tool calls | The agent is told the rules and follows them | A hook checks a tool call before it runs and can stop it |
| Where it works | Any client that speaks MCP | Claude Code, Codex, Cursor, GitHub Copilot; Hermes Agent's package has skills and MCP, no hooks |

Start with MCP only: it takes a minute. Use the package where a rule must hold whatever the model decides: [The client packages](https://www.matterspace.ai/duplex/docs/packages) says where to download it and how to install it. Both ways use the same workspace, the same key and the same data, and you can move from one to the other at any time.

## A key

**API keys** in the [console](https://duplex.matterspace.ai/console) makes one, and **Get started** makes your first. A key is shown once. Keep it in an environment variable or in the client's own secret store, never in a file of a repository. Your sign-in to the console is not a key.

## Claude Code

In a terminal:

```bash
claude mcp add --transport http duplex https://api.duplex.matterspace.ai/mcp --header "X-API-Key: <your Duplex key>"
```

## Codex

The key stays in your environment; Codex reads it from there:

```bash
export DUPLEX_API_KEY="<your Duplex key>"
codex mcp add duplex --url https://api.duplex.matterspace.ai/mcp --bearer-token-env-var DUPLEX_API_KEY
```

## Cursor

In `~/.cursor/mcp.json` for yourself, or `.cursor/mcp.json` in a project:

```json
{
  "mcpServers": {
    "duplex": {
      "url": "https://api.duplex.matterspace.ai/mcp",
      "headers": {
        "Authorization": "Bearer <your Duplex key>"
      }
    }
  }
}
```

## GitHub Copilot in VS Code

In `.vscode/mcp.json`; VS Code asks for the key once and keeps it:

```json
{
  "servers": {
    "duplex": {
      "type": "http",
      "url": "https://api.duplex.matterspace.ai/mcp",
      "headers": {
        "Authorization": "Bearer ${input:duplex-api-key}"
      }
    }
  },
  "inputs": [
    {
      "id": "duplex-api-key",
      "type": "promptString",
      "password": true,
      "description": "Your Duplex key"
    }
  ]
}
```

## Hermes Agent

Merge into `~/.hermes/config.yaml`, and put `DUPLEX_API_KEY=<your Duplex key>` in `~/.hermes/.env`:

```yaml
mcp_servers:
  duplex:
    url: "https://api.duplex.matterspace.ai/mcp"
    headers:
      Authorization: "Bearer ${DUPLEX_API_KEY}"
```

## Any other client that reads an mcpServers file

```json
{
  "mcpServers": {
    "duplex": {
      "url": "https://api.duplex.matterspace.ai/mcp",
      "headers": {
        "X-API-Key": "<your Duplex key>"
      }
    }
  }
}
```

## Clients that sign in instead of holding a key

A client that supports MCP's own sign-in needs no key. Add a connector at `https://api.duplex.matterspace.ai/mcp`: the client opens the service's sign-in page, you sign in with your MS Duplex account and approve the client, and it receives a short-lived token for you alone. Signing out everywhere, leaving the organization or closing it ends the token.

## What the server is

- The server is `https://api.duplex.matterspace.ai/mcp`, Streamable HTTP: requests are POSTed as JSON-RPC.
- The key may go in `X-API-Key`, `x-duplex-key` or `Authorization: Bearer`.
- It offers eleven tools: `duplex_context`, `duplex_observe`, `duplex_learn`, `duplex_rules`, `duplex_task`, `duplex_plan`, `duplex_skill`, `duplex_share`, `duplex_forget`, `duplex_status` and `duplex_report_feedback`. Which of them a key is offered depends on what the key may do. [API](https://www.matterspace.ai/duplex/docs/api) says what each is for.
- A tool's result can be shortened (about 48,000 characters); the console and the [API](https://www.matterspace.ai/duplex/docs/api) give complete data.

## When a call is refused

Every refusal says what happened in a sentence and whether trying again helps (`retry`: `safe`, `after` with a wait, or `no`).

| The answer | What it means | What to do |
| --- | --- | --- |
| `401` | The key is not one the service knows, or it was revoked | Make a key on **API keys** |
| `402` | The month's queries of your plan are used | Wait for the next month, or change plan on **Billing**. Your agent keeps working without Duplex, and nothing it learned is lost; see [Plans and limits](https://www.matterspace.ai/duplex/docs/limits) |
| `403` with a rule's words | One of your organization's rules refused the call | The rule's text says why; your admins change rules on **Rules** |
| `429` naming a limit | Your plan's calls a minute, or calls at once, are used | Wait the seconds the answer names, or change plan on **Billing**; see [Plans and limits](https://www.matterspace.ai/duplex/docs/limits) |
| `503`, try again | The service could not take the call for a moment; with `over_capacity`, nothing was done | Send the call again after the seconds the answer names |

Source: https://www.matterspace.ai/duplex/docs/clients
