# Connect Claude Code for Yourself

Add your Dtwo gateway to Claude Code just for yourself.

## Overview

This guide adds your Dtwo gateway to Claude Code just for you. To set it up for everyone in your organization instead, see [Roll Out Dtwo in Claude Code](/docs/connect-client-claude-code).

## Set up Claude Code

Select how your gateway signs people in.

<div class="doc-tabs" data-tabs>

<div class="doc-tablist doc-tablist-cards" role="tablist" aria-label="Sign-in type">
<button type="button" role="tab" class="doc-tab" data-tab="dtwo" aria-selected="true"><img src="/favicon.svg" alt="" width="36" height="36" data-no-lightbox>Dtwo authentication</button>
<button type="button" role="tab" class="doc-tab" data-tab="entra"><img src="/logos/azure.svg" alt="" width="36" height="36" data-no-lightbox>Microsoft Entra ID</button>
<button type="button" role="tab" class="doc-tab" data-tab="okta"><img src="/logos/okta.png" alt="" width="36" height="36" data-no-lightbox>Okta</button>
</div>

<div class="doc-tabpanel" data-panel="dtwo" role="tabpanel">

<p class="doc-step">Step 1: Add the gateway to Claude Code</p>

In a terminal, add the gateway as an MCP server:

```bash
claude mcp add --transport http --scope user <GatewayName> <GatewayURL>
```

Replace the placeholders:

- `<GatewayName>`: your gateway's name. This is the name you'll see for the server in Claude Code.
- `<GatewayURL>`: your gateway's MCP URL. Copy it from your gateway's **Overview** tab in the Dtwo UI. It must start with `https://`.

`--scope` sets where the gateway is available:

- `--scope user` (used above): every project you open in Claude Code.
- `--scope local`: only the project you ran the command in, and only for you. This is the default if you leave `--scope` out.
- `--scope project`: the project you ran the command in, for everyone who works on it. Claude Code saves the gateway to a `.mcp.json` file in the project, which you commit to your repository.

Then start Claude Code, run `/mcp`, select your gateway, and sign in with your Dtwo account when your browser opens.

To share the setup through your repository without running the command, add the gateway to `.mcp.json` at the project root yourself, using the same values:

```json
{
  "mcpServers": {
    "<GatewayName>": {
      "type": "http",
      "url": "<GatewayURL>"
    }
  }
}
```

<p class="doc-step">Step 2: Verify the connection</p>

1. Run `/mcp` in Claude Code. Your gateway shows as connected, with its tools listed.
2. Ask Claude which tools it has through your gateway. It should list the tools from the MCP servers behind your gateway.

</div>

<div class="doc-tabpanel" data-panel="entra" role="tabpanel">

<p class="doc-step">Step 1: Get Claude Code's client ID from Microsoft Entra ID</p>

If you've already registered Claude Code as an app in Microsoft Entra ID, go to **App registrations**, open the Claude Code app, and copy the **Application (client) ID** from its **Overview** page. This is your `<ClientId>`.

If you haven't registered Claude Code in Microsoft Entra ID yet, follow [Register Claude Code in Microsoft Entra ID](/docs/register-claude-code-entra), then come back here.

<p class="doc-step">Step 2: Add the gateway to Claude Code</p>

In a terminal, add the gateway as an MCP server:

```bash
claude mcp add --transport http --scope user <GatewayName> <GatewayURL> --client-id <ClientId> --callback-port 33418
```

Replace the placeholders:

- `<GatewayName>`: your gateway's name. This is the name you'll see for the server in Claude Code.
- `<GatewayURL>`: your gateway's MCP URL. Copy it from your gateway's **Overview** tab in the Dtwo UI. It must start with `https://`.
- `<ClientId>`: the client ID you copied when you registered the client in your identity provider.

The `--callback-port` must match the port in the redirect URI registered for Claude Code in your identity provider.

`--scope` sets where the gateway is available:

- `--scope user` (used above): every project you open in Claude Code.
- `--scope local`: only the project you ran the command in, and only for you. This is the default if you leave `--scope` out.
- `--scope project`: the project you ran the command in, for everyone who works on it. Claude Code saves the gateway to a `.mcp.json` file in the project, which you commit to your repository.

Then start Claude Code, run `/mcp`, select your gateway, and sign in when your browser opens.

To share the setup through your repository without running the command, add the gateway to `.mcp.json` at the project root yourself, using the same values:

```json
{
  "mcpServers": {
    "<GatewayName>": {
      "type": "http",
      "url": "<GatewayURL>",
      "oauth": {
        "clientId": "<ClientId>",
        "callbackPort": 33418
      }
    }
  }
}
```

<p class="doc-step">Step 3: Verify the connection</p>

1. Run `/mcp` in Claude Code. Your gateway shows as connected, with its tools listed.
2. Ask Claude which tools it has through your gateway. It should list the tools from the MCP servers behind your gateway.

</div>

<div class="doc-tabpanel" data-panel="okta" role="tabpanel">

<p class="doc-step">Step 1: Get Claude Code's client ID from Okta</p>

If you've already registered Claude Code as an app in Okta, go to **Applications and Resources → Applications**, open the Claude Code app integration, and copy the **Client ID** from its **General** tab. This is your `<ClientId>`.

If you haven't registered Claude Code in Okta yet, follow [Register Claude Code in Okta](/docs/register-claude-code-okta), then come back here.

<p class="doc-step">Step 2: Add the gateway to Claude Code</p>

In a terminal, add the gateway as an MCP server:

```bash
claude mcp add --transport http --scope user <GatewayName> <GatewayURL> --client-id <ClientId> --callback-port 33418
```

Replace the placeholders:

- `<GatewayName>`: your gateway's name. This is the name you'll see for the server in Claude Code.
- `<GatewayURL>`: your gateway's MCP URL. Copy it from your gateway's **Overview** tab in the Dtwo UI. It must start with `https://`.
- `<ClientId>`: the client ID you copied when you registered the client in your identity provider.

The `--callback-port` must match the port in the redirect URI registered for Claude Code in your identity provider.

`--scope` sets where the gateway is available:

- `--scope user` (used above): every project you open in Claude Code.
- `--scope local`: only the project you ran the command in, and only for you. This is the default if you leave `--scope` out.
- `--scope project`: the project you ran the command in, for everyone who works on it. Claude Code saves the gateway to a `.mcp.json` file in the project, which you commit to your repository.

Then start Claude Code, run `/mcp`, select your gateway, and sign in when your browser opens.

To share the setup through your repository without running the command, add the gateway to `.mcp.json` at the project root yourself, using the same values:

```json
{
  "mcpServers": {
    "<GatewayName>": {
      "type": "http",
      "url": "<GatewayURL>",
      "oauth": {
        "clientId": "<ClientId>",
        "callbackPort": 33418
      }
    }
  }
}
```

<p class="doc-step">Step 3: Verify the connection</p>

1. Run `/mcp` in Claude Code. Your gateway shows as connected, with its tools listed.
2. Ask Claude which tools it has through your gateway. It should list the tools from the MCP servers behind your gateway.

</div>

</div>

---

Having trouble? Email [support@dtwo.ai](mailto:support@dtwo.ai).