# Connect your agent (https://docs.ctxpipe.ai/docs/mcp/mcp-docs)

ctxpipe has one remote MCP server for every organization:

```text
https://app.ctxpipe.ai/mcp
```

A self-hosted deployment uses the same `/mcp` path on its own origin. The
server uses Streamable HTTP. It gives your agent
[seven read-only tools](/docs/mcp/use-from-your-agent).

## Install with the CLI

Run this in a repository:

```bash
npx ctxpipe init
```

The wizard signs you in, asks which organization and agent clients to
configure, and shows the planned file changes before it writes them. Write the
configuration to the repository, to your user profile, or to both. To share the
setup with your team, commit the repository configuration that the CLI writes.
It holds no secret.

The wizard can also set up [local memory](/docs/mcp/local-memory). To configure
the MCP only, run `npx ctxpipe mcp add`.

| Client                | Repository configuration                                                                                                                              | User configuration                                                                                                                                               |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Claude Code**       | `.mcp.json`                                                                                                                                           | Runs `claude mcp add` when the Claude CLI is installed. Without the Claude CLI, the CLI writes the repository `.mcp.json`, or prints the command for an API key. |
| **Cursor**            | `.cursor/mcp.json`                                                                                                                                    | `~/.cursor/mcp.json`                                                                                                                                             |
| **Codex**             | No repository file. Prints a `codex mcp add` command, which writes your user configuration. For an API key, it prints the `.codex/config.toml` lines. | Runs `codex mcp add` when the Codex CLI is installed. Without the Codex CLI, the CLI prints the command. For an API key, it prints the `config.toml` lines.      |
| **OpenCode**          | `opencode.json`                                                                                                                                       | `~/.config/opencode/opencode.json`                                                                                                                               |
| **VS Code / Copilot** | `.vscode/mcp.json`                                                                                                                                    | Prints a VS Code install link                                                                                                                                    |

The CLI sign-in is only for setup. The CLI keeps it in the OS keychain, or in
`~/.config/ctxpipe/` when no keychain is available. Your agent client asks you
to authorize ctxpipe separately the first time it connects.

### Scripts and CI

Use flags to run the CLI without prompts:

```bash
npx ctxpipe init --org acme --agents cursor,claude --scope repo --non-interactive
npx ctxpipe mcp add --client opencode --scope user --non-interactive
npx ctxpipe doctor --json
```

Run `npx ctxpipe init --help` for all flags. Examples are `--base-url`,
`--dry-run`, `--json`, `--no-mcp`, and `--auth api-key`. For an agent that
cannot sign in through a browser, see [API keys](/docs/mcp/api-keys).

## Authorize the client

The first time your client connects, it opens ctxpipe in the browser:

1. Sign in to ctxpipe.
2. Select the organizations that the client can read. The organization of your
   current session is selected. Select at least one.
3. Leave **Also allow changes** clear. It shows only when a client asks for
   write access, and the MCP tools never need it.
4. Approve. The client returns to your agent, ready to use.

Each tool call names one of the organizations that you selected. To change the
set later, or to revoke the client, open
[Connected apps](/docs/mcp/connected-apps).

## Configure a client by hand

Use manual configuration when the CLI does not support your client, or when
another tool manages the configuration. The client opens the browser to
authorize, so the configuration holds no token.

### Claude Code

`.mcp.json` in the repository:

```json
{
  "mcpServers": {
    "ctxpipe": {
      "type": "http",
      "url": "https://app.ctxpipe.ai/mcp"
    }
  }
}
```

For your user profile, run
`claude mcp add --transport http ctxpipe --scope user https://app.ctxpipe.ai/mcp`.

### Cursor

`.cursor/mcp.json` in the repository, or `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "ctxpipe": {
      "type": "http",
      "url": "https://app.ctxpipe.ai/mcp"
    }
  }
}
```

### Codex

```bash
codex mcp add ctxpipe --url "https://app.ctxpipe.ai/mcp"
```

### OpenCode

`opencode.json` in the repository, or `~/.config/opencode/opencode.json`:

```json
{
  "mcp": {
    "ctxpipe": {
      "type": "remote",
      "url": "https://app.ctxpipe.ai/mcp",
      "enabled": true
    }
  }
}
```

### VS Code / Copilot

`.vscode/mcp.json` in the repository:

```json
{
  "servers": {
    "ctxpipe": {
      "type": "http",
      "url": "https://app.ctxpipe.ai/mcp"
    }
  }
}
```

For your user profile, use the install link that
`npx ctxpipe mcp add --client vscode --scope user` prints.

### Other clients

Use the endpoint URL with the Streamable HTTP transport. The name of the
transport key changes between clients. Read the documentation of your client.

## Check the connection

Ask your agent:

```text
Call the ctxpipe list_workspaces tool, then search_knowledge for our
standards on authentication.
```

A finished browser sign-in does not prove tool access. The tools must return
your Workspaces.

## Troubleshooting

* **The client asks for authorization after the CLI signed you in.** This is
  correct. The CLI sign-in and the client authorization are separate.
* **The connection fails with only a URL.** Add the `type` field for your
  client. Most clients do not detect the transport.
* **Cursor or Claude Code refuses the server type.** Use `"type": "http"`.
* **OpenCode shows the server, but it does not connect.** Use the top-level
  `mcp.ctxpipe` shape with `type: "remote"` and `enabled: true`.
* **The client cannot finish the browser sign-in.** Use an
  [API key](/docs/mcp/api-keys).
* **A tool returns `org_not_found`.** See
  [Connected apps](/docs/mcp/connected-apps#when-a-tool-says-org_not_found).

Old configurations can have `?orgSlug=` in the URL. The server ignores it, so
you can keep it or remove it. The current CLI writes the URL without it.

## Related

* [Use ctxpipe from your agent](/docs/mcp/use-from-your-agent): the tools and how to use them
* [API keys](/docs/mcp/api-keys): CI, review bots, and headless agents
* [Connected apps](/docs/mcp/connected-apps): change organizations or revoke a client
* [Local memory](/docs/mcp/local-memory): Markdown memory that agents keep in the repository
