Run Claude Desktop on Amazon Bedrock through AgentCore Gateway
Part 2 of 5: Claude Desktop can send its model calls and its MCP tool calls through your own AgentCore gateway, signed in with your identity provider. Here's how we set it up on macOS with a managed profile, and how to switch back.

Claude Desktop can run in third-party mode on Amazon Bedrock, with its model calls and MCP tool calls going through your own AgentCore gateway. People sign in with your identity provider, and Desktop sends their token with every call. This guide sets that up on a Mac and shows how to switch back.
The short version
- A managed macOS profile is the reliable way to configure it. The in-app screen and the Admin Console may be hidden from you.
- Desktop signs people in itself and sends their ID token on every model call.
- MCP needs a small headers helper script, because Cognito can’t do the OAuth that MCP clients expect.
- Set the scopes explicitly, and list only models that are active in your account.
- A second profile with
deploymentModeset to1pputs Desktop back to claude.ai.
This follows our AgentCore Gateway guide. You need its gateway, Cognito pool and app client, and the sign-in from its Step 7. Metomic Boundary, our invented 900-person payments company, is rolling this out to its platform team.
The AgentCore Gateway series, in order:
- Put Claude Code on Bedrock behind your own sign-in
- Run Claude Desktop through the same gateway (this guide)
- Add GitHub’s MCP server with a read-only token
- Give each person their own HubSpot sign-in
- Count what the MCP tool definitions cost per model call
What changes when Desktop runs in third-party mode?
Claude Desktop (third-party mode)
├─ model calls ──► <gateway>/inference ──► Claude on Bedrock Authorization: Bearer <ID token from Desktop's own sign-in>
└─ tool calls ──► <gateway>/mcp ──► your MCP targets Authorization: Bearer <ID token from the headers helper>
Desktop stops talking to claude.ai. It signs the person in through your identity provider in their browser, then sends the ID token as a bearer token. The gateway checks it exactly as it checks Claude Code’s.
There are two sign-ins today: Desktop’s own covers model calls, and the helper’s covers MCP. More on that under “What’s still hard?”.
Which way of configuring Desktop should you use?
| Way | Where | When it works |
|---|---|---|
| In the app | Help → Troubleshooting → Enable Developer Mode, then Developer → Configure Third-Party Inference… | Only if your signed-in organisation hasn’t turned developer mode off. Desktop hides the item and doesn’t say why |
| Admin Console | Organization settings → Desktop 3P | Only in an organisation Anthropic has provisioned for a third-party deployment |
| A managed profile | The com.anthropic.claudefordesktop preference domain |
Always, installed by hand or by your device management tool |
We used the profile. It’s also what you’d ship to everyone with your device management tool, so it’s worth getting right on one Mac first.
Step 1: How do you give Desktop the MCP token?
Desktop runs a headers helper before connecting to an MCP server and sends the JSON it prints. This one reads the ID token from Step 7 of the first guide and renews it from the refresh token when it’s nearly out. It needs no AWS credentials or libraries. It’s a standalone rewrite of the helper Desktop ran for us, and we’ve tested it from a terminal, including the renewal.
#!/usr/bin/python3
"""Prints {"Authorization": "Bearer <ID token>"} for an MCP client's headersHelper, renewing the token when it's nearly out."""
import base64, json, os, time, urllib.request
TOKEN = os.path.expanduser(os.environ.get("AGENTCORE_TOKEN_FILE", "~/.agentcore-id-token"))
REFRESH = os.path.expanduser(os.environ.get("AGENTCORE_REFRESH_FILE", "~/.agentcore-refresh"))
token = open(TOKEN).read().strip()
claims = json.loads(base64.urlsafe_b64decode(token.split(".")[1] + "=="))
if claims["exp"] - time.time() < 120: # the issuer names the region, the audience is the app client
region = claims["iss"].split(".")[1]
request = urllib.request.Request(f"https://cognito-idp.{region}.amazonaws.com/", method="POST",
headers={"Content-Type": "application/x-amz-json-1.1", "X-Amz-Target": "AWSCognitoIdentityProviderService.InitiateAuth"},
data=json.dumps({"AuthFlow": "REFRESH_TOKEN_AUTH", "ClientId": claims["aud"],
"AuthParameters": {"REFRESH_TOKEN": open(REFRESH).read().strip()}}).encode())
token = json.load(urllib.request.urlopen(request, timeout=20))["AuthenticationResult"]["IdToken"]
with open(os.open(TOKEN, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), "w") as f:
f.write(token + "\n")
os.chmod(TOKEN, 0o600)
print(json.dumps({"Authorization": "Bearer " + token}))
Save it as /Users/<you>/bin/agentcore-headers.py and make it executable with chmod 700. Desktop starts it with a bare environment, so name it by its full path and don’t rely on your shell’s PATH.
Check: run it. It prints one line, {"Authorization": "Bearer eyJ…"}, and nothing else. Anything extra on standard output breaks the header.
Step 2: What goes in the profile?
Write the settings as JSON first. This is ours with Metomic Boundary’s placeholders:
{
"deploymentMode": "3p",
"inferenceProvider": "bedrock",
"inferenceBedrockRegion": "eu-west-2",
"inferenceBedrockBaseUrl": "https://<gateway-id>.gateway.bedrock-agentcore.eu-west-2.amazonaws.com/inference",
"inferenceCredentialKind": "external-idp",
"inferenceIdpOidc": {
"issuer": "https://cognito-idp.eu-west-2.amazonaws.com/<pool-id>",
"clientId": "<app-client-id>",
"redirectPort": 53180,
"scopes": "openid email profile"
},
"inferenceModels": ["eu.anthropic.claude-sonnet-5-5", "eu.anthropic.claude-haiku-5-5"],
"managedMcpServers": [{
"name": "agentcore",
"transport": "http",
"url": "https://<gateway-id>.gateway.bedrock-agentcore.eu-west-2.amazonaws.com/mcp",
"headersHelper": "/Users/<you>/bin/agentcore-headers.py"
}]
}
Every key earns its place:
| Key | Why |
|---|---|
deploymentMode: "3p" |
Forces third-party mode, even if the person chose otherwise before |
inferenceProvider: "bedrock" |
Bedrock’s request format |
inferenceBedrockBaseUrl |
The gateway’s /inference in place of Bedrock’s own endpoint |
inferenceCredentialKind: "external-idp" |
Desktop signs the person in and sends their ID token as the bearer |
inferenceIdpOidc.redirectPort |
Desktop listens on http://127.0.0.1:53180/callback, which must be the app client’s callback URL exactly |
inferenceIdpOidc.scopes |
Left unset, Desktop adds offline_access, which Cognito refuses with invalid_scope |
inferenceModels |
Only models active in your account. A Legacy model fails on the first message |
managedMcpServers |
The gateway’s /mcp, with the helper from Step 1. It’s a JSON array |
Step 3: How do you turn the JSON into a profile?
A profile is a property list with one payload in Desktop’s domain. Strings, numbers and booleans stay as they are; objects and arrays become JSON strings. That’s the shape Desktop’s own export produces. This script builds two: one to switch to Bedrock and one to switch back.
# build_profiles.py: python3 build_profiles.py desktop-config.json
import json, plistlib, sys, uuid
DOMAIN = "com.anthropic.claudefordesktop"
config = json.load(open(sys.argv[1]))
def profile(title, settings):
payload = {"PayloadType": DOMAIN, "PayloadIdentifier": f"{DOMAIN}.settings", "PayloadVersion": 1,
"PayloadDisplayName": "Claude Desktop", "PayloadUUID": str(uuid.uuid4()).upper()}
for key, value in settings.items():
payload[key] = value if isinstance(value, (bool, str, int)) else json.dumps(value, separators=(",", ":"))
return {"PayloadContent": [payload], "PayloadDisplayName": title, "PayloadIdentifier": f"{DOMAIN}.profile",
"PayloadType": "Configuration", "PayloadUUID": str(uuid.uuid4()).upper(), "PayloadVersion": 1,
"PayloadScope": "System"}
open("claude-desktop-bedrock.mobileconfig", "wb").write(plistlib.dumps(profile("Claude Desktop: Bedrock", config)))
open("claude-desktop-claude-ai.mobileconfig", "wb").write(plistlib.dumps(profile("Claude Desktop: claude.ai", {"deploymentMode": "1p"})))
Both profiles share one identifier, com.anthropic.claudefordesktop.profile, so installing either replaces the other.
Check: plutil -lint claude-desktop-bedrock.mobileconfig says OK.
Step 4: How do you install it and sign in?
- Double-click
claude-desktop-bedrock.mobileconfig. - Open System Settings → General → Device Management, select the profile and choose Install.
- Quit Desktop with Cmd-Q and open it again. It reads these settings only at launch.
- Sign in when Desktop asks. Your browser opens your Cognito sign-in page, then hands back to Desktop on port 53180.
Check: send “Hey!” in a new chat. The reply comes from Claude on Bedrock, through your gateway.
Step 5: How do you confirm MCP is connected?
Desktop’s third-party mode has its own log. MCP lines start with [custom3p-mcp].
grep 'custom3p-mcp' ~/Library/Logs/Claude-3p/main.log | tail -5
Check: you see a line like this, with your gateway’s tool count:
[custom3p-mcp] server connected { name: 'agentcore', toolCount: 3, host: 'plain', hostPid: … }
Then ask “Ask DeepWiki what octocat/Hello-World is for.” Desktop calls one of DeepWiki’s tools through the gateway and answers.
How do you switch back to claude.ai?
Install claude-desktop-claude-ai.mobileconfig the same way, then quit and reopen Desktop. It replaces the Bedrock profile, and deploymentMode: "1p" puts Desktop back on claude.ai with your usual sign-in and connectors.
Removing the profile in Device Management also works. Third-party mode keeps its data in ~/Library/Application Support/Claude-3p, so nothing of your claude.ai setup was touched.
What goes wrong, and what does it mean?
| You see | Cause | Fix |
|---|---|---|
The browser comes back with error=invalid_scope |
scopes unset, so Desktop asked for offline_access |
Set "scopes": "openid email profile" |
| “is Legacy and you have not been actively using the model” on the first message | A model in inferenceModels isn’t active in your account |
List active models only |
| “Couldn’t reconnect the agentcore connector” | Desktop rejected the whole tools/list |
See the GitHub guide: the gateway invents output schemas Desktop won’t accept |
No [custom3p-mcp] line for your server |
The helper failed or printed something extra | Run the helper by hand and read what it prints |
| One prompt costs hundreds of thousands of tokens | Every tool’s definition goes with every model call | See what tool definitions cost behind a gateway |
| Configure Third-Party Inference… is missing | Your organisation turned developer mode off | Use the profile |
What’s still hard?
- Two sign-ins. Desktop’s own sign-in covers model calls. The helper’s token comes from a separate terminal sign-in. We haven’t found a way for the MCP server to reuse Desktop’s token.
- macOS only, so far. We’ve only built and tested this on a Mac.
- Background calls. Besides streamed chat, Desktop makes short non-streamed InvokeModel calls for background work. Your gateway role, and anything watching it, must expect both.
- Each person’s SaaS sign-in. Desktop connects to the gateway on MCP protocol 2025-03-26. Per-person OAuth links need 2025-11-25, so Desktop didn’t show them. The HubSpot guide has our workaround.
What do you have now?
- Claude Desktop on Bedrock through your gateway, signed in with your identity provider.
- Its MCP tools coming through the same gateway, with a token that renews itself.
- Two profiles to move between Bedrock and claude.ai in a minute.
Desktop sends whatever you point it at. Whose data rides along, and where it goes after the gateway, is what our governed MCP gateway is there to decide. We’re working with a small number of security teams on what happens to the data these tools touch. If you’ve solved the two sign-ins, we’d like to hear how.
Frequently asked questions
- How do you configure Claude Desktop for Amazon Bedrock without the Admin Console?
- Install a managed configuration profile in the com.anthropic.claudefordesktop preference domain. It's the same file Desktop's own Configure Third-Party Inference screen exports, and it's what a device management tool would deliver. Installed by hand on a Mac, it needs neither developer mode nor an organisation provisioned for third-party deployment. Quit Desktop and open it again after installing it.
- Why does Claude Desktop's sign-in fail with invalid_scope?
- If you don't set scopes, Desktop asks your identity provider for offline_access along with openid, email and profile. Amazon Cognito doesn't support offline_access, so it sends the browser back with invalid_scope. Set the scopes field in inferenceIdpOidc to "openid email profile". Desktop then asks for exactly those three and the sign-in completes.
- Does switching Claude Desktop to Bedrock remove my claude.ai sign-in?
- No. Third-party mode keeps its own data in a separate folder, ~/Library/Application Support/Claude-3p, with its own log at ~/Library/Logs/Claude-3p/main.log. Your claude.ai sign-in, chats and connectors stay where they were. Install a profile that sets deploymentMode to 1p, or remove the profile, and Desktop opens as it did before.
- Why does Claude Desktop say it couldn't reconnect the AgentCore connector?
- In our case Desktop rejected the gateway's whole tools/list because some tools had output schemas whose type wasn't object. The gateway added those schemas for GitHub's MCP server. Desktop's log line starts with [custom3p-mcp] connect failed and mentions an invalid result for tools/list. The fix is to drop those schemas in a response interceptor.
- Can Claude Desktop use OAuth for the AgentCore gateway's MCP endpoint?
- Not with Cognito, in our experience. The gateway advertises its authorizer for OAuth discovery, but Cognito has no dynamic client registration, and Cognito access tokens lack the audience the gateway checks. A headers helper script that prints the person's ID token works instead. Desktop runs it before connecting and sends the header it prints.