Connect Claude Code for Yourself
Add your Dtwo gateway to Claude Code just for yourself.
On this page
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.
Set up Claude Code
Select how your gateway signs people in.
Step 1: Add the gateway to Claude Code
In a terminal, add the gateway as an MCP server:
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 withhttps://.
--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--scopeout.--scope project: the project you ran the command in, for everyone who works on it. Claude Code saves the gateway to a.mcp.jsonfile 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:
{
"mcpServers": {
"<GatewayName>": {
"type": "http",
"url": "<GatewayURL>"
}
}
}
Step 2: Verify the connection
- Run
/mcpin Claude Code. Your gateway shows as connected, with its tools listed. - Ask Claude which tools it has through your gateway. It should list the tools from the MCP servers behind your gateway.
Step 1: Get Claude Code's client ID from Microsoft Entra ID
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, then come back here.
Step 2: Add the gateway to Claude Code
In a terminal, add the gateway as an MCP server:
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 withhttps://.<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--scopeout.--scope project: the project you ran the command in, for everyone who works on it. Claude Code saves the gateway to a.mcp.jsonfile 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:
{
"mcpServers": {
"<GatewayName>": {
"type": "http",
"url": "<GatewayURL>",
"oauth": {
"clientId": "<ClientId>",
"callbackPort": 33418
}
}
}
}
Step 3: Verify the connection
- Run
/mcpin Claude Code. Your gateway shows as connected, with its tools listed. - Ask Claude which tools it has through your gateway. It should list the tools from the MCP servers behind your gateway.
Step 1: Get Claude Code's client ID from Okta
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, then come back here.
Step 2: Add the gateway to Claude Code
In a terminal, add the gateway as an MCP server:
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 withhttps://.<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--scopeout.--scope project: the project you ran the command in, for everyone who works on it. Claude Code saves the gateway to a.mcp.jsonfile 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:
{
"mcpServers": {
"<GatewayName>": {
"type": "http",
"url": "<GatewayURL>",
"oauth": {
"clientId": "<ClientId>",
"callbackPort": 33418
}
}
}
}
Step 3: Verify the connection
- Run
/mcpin Claude Code. Your gateway shows as connected, with its tools listed. - Ask Claude which tools it has through your gateway. It should list the tools from the MCP servers behind your gateway.