From 2bd6278db54276dc8f507c3fe315df2159f8bd19 Mon Sep 17 00:00:00 2001 From: Christina Chu Date: Tue, 27 Oct 2026 12:12:44 -0700 Subject: [PATCH 1/4] fix: shorten the MCP server name so every tool fits in 64 characters AWS caps an MCP server name, "_" and a tool name at 64 characters. The name from #968 holds the full space UUID (49 characters), so registration failed for 18 of the 31 allowlisted tools. Keep the first 13 characters of the space ID, and test that every allowlisted tool fits. Co-Authored-By: Claude Opus 5.5 --- internal/awsdevops/export_test.go | 5 +++++ internal/awsdevops/lookup.go | 11 ++++++++++- internal/awsdevops/runplan_test.go | 9 +++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/internal/awsdevops/export_test.go b/internal/awsdevops/export_test.go index 38904942a..1bf7e3171 100644 --- a/internal/awsdevops/export_test.go +++ b/internal/awsdevops/export_test.go @@ -21,3 +21,8 @@ func ConnectExisting(ctx context.Context, clients Clients, opts SetupOptions) (S return ConnectPlan(ctx, clients, opts, plan) } + +// MCPTools lists every tool in the allowlist, for tests. +func MCPTools() []string { + return append(append([]string{}, mcpReadOnlyTools...), mcpMutativeTools...) +} diff --git a/internal/awsdevops/lookup.go b/internal/awsdevops/lookup.go index 444d41e46..5697f3ca4 100644 --- a/internal/awsdevops/lookup.go +++ b/internal/awsdevops/lookup.go @@ -197,10 +197,19 @@ func agentSpaceARN(region, accountID, spaceID string) string { return fmt.Sprintf("arn:aws:aidevops:%s:%s:agentspace/%s", region, accountID, spaceID) } +// mcpServerIDLength is how much of the space ID the server name keeps. AWS +// caps the name, "_" and a tool name at 64 characters, so a full UUID leaves +// too little room for the tools. +const mcpServerIDLength = 13 + // MCPServerNameFor is the name of the MCP server that setup registers for an // agent space. AWS needs a unique name of letters, digits, "_" and "-", and -// the ID ties the server to the space. +// the start of the ID ties the server to the space. func MCPServerNameFor(agentSpaceID string) string { + if len(agentSpaceID) > mcpServerIDLength { + agentSpaceID = agentSpaceID[:mcpServerIDLength] + } + return MCPServerName + "-" + agentSpaceID } diff --git a/internal/awsdevops/runplan_test.go b/internal/awsdevops/runplan_test.go index f69ffbd6d..b88a444e6 100644 --- a/internal/awsdevops/runplan_test.go +++ b/internal/awsdevops/runplan_test.go @@ -1361,3 +1361,12 @@ func TestMCPServerNameForHasOnlyAllowedCharacters(t *testing.T) { assert.Regexp(t, `^[a-zA-Z0-9_-]{1,128}$`, name) } + +// AWS caps the server name, "_" and a tool name at 64 characters. +func TestMCPServerNameForLeavesRoomForEveryTool(t *testing.T) { + name := awsdevops.MCPServerNameFor("0b9f6c3e-5d7a-4c1e-9a2b-3f4e5d6c7b8a") + + for _, tool := range awsdevops.MCPTools() { + assert.LessOrEqual(t, len(name+"_"+tool), 64, tool) + } +} From 586c9bf4775f29379a9d5c353d62fa0ec0c6ea4d Mon Sep 17 00:00:00 2001 From: Christina Chu Date: Tue, 27 Oct 2026 12:27:11 -0700 Subject: [PATCH 2/4] fix: keep the last 12 characters of the space ID in the MCP server name The last group of a UUID space ID has no dash, so the name reads as LaunchDarkly-97503e355157. Co-Authored-By: Claude Opus 5.5 --- internal/awsdevops/lookup.go | 6 +++--- internal/awsdevops/runplan_test.go | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/awsdevops/lookup.go b/internal/awsdevops/lookup.go index 5697f3ca4..ba8d0ffb5 100644 --- a/internal/awsdevops/lookup.go +++ b/internal/awsdevops/lookup.go @@ -200,14 +200,14 @@ func agentSpaceARN(region, accountID, spaceID string) string { // mcpServerIDLength is how much of the space ID the server name keeps. AWS // caps the name, "_" and a tool name at 64 characters, so a full UUID leaves // too little room for the tools. -const mcpServerIDLength = 13 +const mcpServerIDLength = 12 // MCPServerNameFor is the name of the MCP server that setup registers for an // agent space. AWS needs a unique name of letters, digits, "_" and "-", and -// the start of the ID ties the server to the space. +// the end of the ID ties the server to the space. func MCPServerNameFor(agentSpaceID string) string { if len(agentSpaceID) > mcpServerIDLength { - agentSpaceID = agentSpaceID[:mcpServerIDLength] + agentSpaceID = agentSpaceID[len(agentSpaceID)-mcpServerIDLength:] } return MCPServerName + "-" + agentSpaceID diff --git a/internal/awsdevops/runplan_test.go b/internal/awsdevops/runplan_test.go index b88a444e6..1a7edc8f1 100644 --- a/internal/awsdevops/runplan_test.go +++ b/internal/awsdevops/runplan_test.go @@ -1362,6 +1362,11 @@ func TestMCPServerNameForHasOnlyAllowedCharacters(t *testing.T) { assert.Regexp(t, `^[a-zA-Z0-9_-]{1,128}$`, name) } +// The name keeps the last group of a UUID space ID. +func TestMCPServerNameForKeepsTheEndOfTheSpaceID(t *testing.T) { + assert.Equal(t, "LaunchDarkly-3f4e5d6c7b8a", awsdevops.MCPServerNameFor("0b9f6c3e-5d7a-4c1e-9a2b-3f4e5d6c7b8a")) +} + // AWS caps the server name, "_" and a tool name at 64 characters. func TestMCPServerNameForLeavesRoomForEveryTool(t *testing.T) { name := awsdevops.MCPServerNameFor("0b9f6c3e-5d7a-4c1e-9a2b-3f4e5d6c7b8a") From 6e4622fcfb31bad2d15f100aeaaf49fbfc7d39e7 Mon Sep 17 00:00:00 2001 From: Christina Chu Date: Tue, 27 Oct 2026 12:42:20 -0700 Subject: [PATCH 3/4] docs: explain the length of the space ID in the MCP server name Co-Authored-By: Claude Opus 5.5 --- internal/awsdevops/lookup.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/awsdevops/lookup.go b/internal/awsdevops/lookup.go index ba8d0ffb5..7ac4446a0 100644 --- a/internal/awsdevops/lookup.go +++ b/internal/awsdevops/lookup.go @@ -197,9 +197,13 @@ func agentSpaceARN(region, accountID, spaceID string) string { return fmt.Sprintf("arn:aws:aidevops:%s:%s:agentspace/%s", region, accountID, spaceID) } -// mcpServerIDLength is how much of the space ID the server name keeps. AWS -// caps the name, "_" and a tool name at 64 characters, so a full UUID leaves -// too little room for the tools. +// mcpServerIDLength is how many characters of the space ID the server name +// keeps. The agent sees each tool as "_", and AWS +// caps that at 64 characters. "LaunchDarkly-" takes 13 and "_" takes 1, so +// with the longest tool (get-experiment-metric-results, 29) the ID gets at +// most 21. A full UUID is 36. 12 is the last group of a UUID, which leaves 9 +// characters for longer tools. TestMCPServerNameForLeavesRoomForEveryTool +// checks every tool in the allowlist. const mcpServerIDLength = 12 // MCPServerNameFor is the name of the MCP server that setup registers for an From 987f848195bd36a4570b4c646305c7c38ae21385 Mon Sep 17 00:00:00 2001 From: Christina Chu Date: Tue, 27 Oct 2026 12:43:42 -0700 Subject: [PATCH 4/4] docs: shorten the comment on the length of the space ID Co-Authored-By: Claude Opus 5.5 --- internal/awsdevops/lookup.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/internal/awsdevops/lookup.go b/internal/awsdevops/lookup.go index 7ac4446a0..a8efbdaed 100644 --- a/internal/awsdevops/lookup.go +++ b/internal/awsdevops/lookup.go @@ -197,13 +197,8 @@ func agentSpaceARN(region, accountID, spaceID string) string { return fmt.Sprintf("arn:aws:aidevops:%s:%s:agentspace/%s", region, accountID, spaceID) } -// mcpServerIDLength is how many characters of the space ID the server name -// keeps. The agent sees each tool as "_", and AWS -// caps that at 64 characters. "LaunchDarkly-" takes 13 and "_" takes 1, so -// with the longest tool (get-experiment-metric-results, 29) the ID gets at -// most 21. A full UUID is 36. 12 is the last group of a UUID, which leaves 9 -// characters for longer tools. TestMCPServerNameForLeavesRoomForEveryTool -// checks every tool in the allowlist. +// mcpServerIDLength is the length to truncate the agent space ID to in the +// server name. const mcpServerIDLength = 12 // MCPServerNameFor is the name of the MCP server that setup registers for an