Repository navigation
fix: register one OAuth MCP server for each AWS account - #983
Conversation
aws-devops-agent setup registered one LaunchDarkly MCP server for each agent space, with a LaunchDarkly access token. AWS keeps the credentials on the registration, so a different token needed a different server. Now setup registers one server for the AWS account, with OAuth. Setup opens the approval URL that AWS sends, waits until AWS registers the server, and associates the server with the agent space. Another agent space reuses the server and needs no browser step. This change removes the token path: the token prompt, the token check, --replace-mcp-token, and the server name for each space. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # cmd/aws_devops_agent/confirm_test.go # cmd/aws_devops_agent/plan_print_test.go # cmd/aws_devops_agent/setup.go # internal/awsdevops/awsdevops.go # internal/awsdevops/awsdevops_test.go # internal/awsdevops/setup.go
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0d27684. Configure here.
Andrewjeska
left a comment
There was a problem hiding this comment.
Agent review incoming
| func SetOAuthPollInterval(d time.Duration) func() { | ||
| old := oauthPollInterval | ||
| oauthPollInterval = d | ||
|
|
||
| return func() { oauthPollInterval = old } | ||
| } |
There was a problem hiding this comment.
I dont see this called anywhere?
There was a problem hiding this comment.
Thanks! It was a leftover test helper I think. Updated test cases to actually use it.
Scope: 20 files, +311/−1697 — removes the per-agent-space, token-based MCP registration path in favor of one OAuth-based Nits worth addressing
Already-raised (Cursor Bugbot)The reply at #discussion_r4405123593 looks correct — AWS doesn't persist a pending registration when approval is cancelled, so a retry gets a fresh approval URL and does not hit a name conflict. Safe to resolve. No concerns
OverallShip it after addressing #1 and #2; #3–#5 are nice-to-haves. via LD Research 🤖 |
The new test adds the server on the third poll, so setup must wait and poll again. The approval test no longer sets the poll interval, because that test finds the server on the first poll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Setup took the first OAuth server that ListServices sent. Each server acts as the member who approved it, so two agent spaces could act as different members. Now the plan stops, names each server, and asks for --mcp-service-id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If RegisterService reports that LaunchDarkly-OAuth already exists, setup now says to rename or delete that server in the AWS console, or to pass --mcp-service-id. Before, setup showed only the error from AWS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The help said that AWS can ask for a console sign-in before the approval. AWS registers the server before it opens the console, so the sign-in comes after the approval, and setup does not wait for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review!
|

For Humans
Updates ldcli aws-devops-agent setup script to more closely align with what's in the manual setup docs: https://github.com/launchdarkly/ld-docs-private/pull/8632
Mainly:
Old:
One MCP server registration <=> one agent space.viaaccess tokenNew:
MCP server registration <=> one account (multiple agent space)viaOauth (browser).This removes the numerous confusing MCP registrations that could show up for users:

Instead of asking for access token, we direct users to LD Oauth page and poll results to continue with the rest of setup.
Previously concerns were raised about re-using the access token - the issues are still present, but there's nothing to enforce it on AWS side either (you can use other teammates' registered MCP server through the UI). Leaving the issue standing, and recommending that users use a service account if appropriate.
Summary
ldcli aws-devops-agent setupregistered one LaunchDarkly MCP server for each agent space, with a LaunchDarkly access token. AWS keeps the credentials on the registration (RegisterService). The association (AssociateService) holds only the tool allowlist. So a different token for each space needed a different server.With this change, setup registers one MCP server for the AWS account, with OAuth:
RegisterServicewithAuthorizationDiscovery. The return URL is the DevOps Agent console URL of the region.ListServicesevery 5 seconds, for 10 minutes at most. It looks for a server at the LaunchDarkly endpoint with theoauth-3lomethod.If another agent space runs setup, setup finds the server of the account and associates it. That space needs no browser step.
The new server has the name
LaunchDarkly-OAuth. Setup never reuses a server that uses a token, even one with the nameLaunchDarklyfrom the AWS console guide. If an agent space is already connected to a LaunchDarkly server, setup keeps that server.--mcp-service-idstill works.Removed
--replace-mcp-tokenand the token replacement logic: disconnect, deregister, and the handling of shared serversMCPServerNameFor)DeregisterServiceandDisassociateServicefrom theAgentAPIinterfaceTradeoffs
Testing
go test ./...andgolangci-lintpass.LaunchDarkly-OAuthafter the approval, and associated it.🤖 Generated with Claude Code
Note
Overview
ldcli aws-devops-agent setupno longer registers a separate LaunchDarkly MCP server per agent space using--access-token. It uses one account-level MCP registration shared by all agent spaces, authenticated with OAuth in the browser instead of pasted service tokens.When no OAuth server exists at the configured endpoint, setup calls
RegisterServicewith authorization discovery, opens the approval URL (viaOpenURL/browser.OpenURL), and pollsListServicesuntil AWS exposes anoauth-3loserver namedLaunchDarkly-OAuth, then associates it with the agent space. Later runs reuse that account server or an MCP server already linked to the space;--mcp-service-idstill selects among multiple OAuth servers.Removed: interactive token prompts, LaunchDarkly token validation (
token.go),--replace-mcp-token, per-space server naming, and MCP deregister/disassociate paths used for token replacement. Help text and tests are updated to match; OAuth behavior is covered by new polling/approval tests.Reviewed by Cursor Bugbot for commit 56eca35. Bugbot is set up for automated code reviews on this repo. Configure here.