From f5d0dc9de6c5075fbe95ea4b169b45f5ad22e972 Mon Sep 17 00:00:00 2001
From: Kiro Agent <244629292+kiro-agent@users.noreply.github.com>
Date: Sun, 30 Aug 2026 14:46:23 +0000
Subject: [PATCH 1/3] fix(mcp-auth): negotiate protocol version instead of
rejecting
Add 2025-06-18 to the default supported protocol versions and negotiate
downwards on initialize instead of returning JSON-RPC -32602 for an
unsupported version.
Per the MCP lifecycle spec the server echoes the requested version when
supported, otherwise responds with a version it does support. We pick the
highest supported version that is not newer than the requested one, because
@modelcontextprotocol/sdk <= 1.16.0 rejects any negotiated version outside
its own accepted set. Only when no supported version is old enough do we
fall back to -32602.
---
src/constructs/mcp-auth.ts | 4 +--
src/constructs/mcp-cognito-auth.ts | 2 +-
src/constructs/rest-api.ts | 2 +-
src/mcp-auth/mcp/server.ts | 39 ++++++++++++++++++++--
test/mcp-auth/mcp-server.test.ts | 52 ++++++++++++++++++++++++++++--
5 files changed, 91 insertions(+), 8 deletions(-)
diff --git a/src/constructs/mcp-auth.ts b/src/constructs/mcp-auth.ts
index a030607e..d1e43e0f 100644
--- a/src/constructs/mcp-auth.ts
+++ b/src/constructs/mcp-auth.ts
@@ -47,7 +47,7 @@ export interface McpAuthProps {
/**
* Supported MCP protocol versions (newest first).
- * @default ['2025-11-25', '2025-03-26', '2024-11-05']
+ * @default ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05']
*/
readonly protocolVersions?: string[];
@@ -139,7 +139,7 @@ export class McpAuth extends Construct {
MCP_CLIENT_ID: props.clientId,
MCP_SERVER_NAME: props.serverInfo.name,
MCP_SERVER_VERSION: props.serverInfo.version,
- MCP_PROTOCOL_VERSIONS: (props.protocolVersions ?? ['2025-11-25', '2025-03-26', '2024-11-05']).join(','),
+ MCP_PROTOCOL_VERSIONS: (props.protocolVersions ?? ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05']).join(','),
MCP_SCOPES: (props.scopes ?? ['openid', 'email', 'profile']).join(','),
MCP_ALLOWED_REDIRECT_URIS: props.allowedRedirectUris.join(','),
MCP_STRIP_PARAMETERS: (props.stripParameters ?? ['resource']).join(','),
diff --git a/src/constructs/mcp-cognito-auth.ts b/src/constructs/mcp-cognito-auth.ts
index a17ef3a8..c011c952 100644
--- a/src/constructs/mcp-cognito-auth.ts
+++ b/src/constructs/mcp-cognito-auth.ts
@@ -42,7 +42,7 @@ export interface McpCognitoAuthProps {
/**
* Supported MCP protocol versions (newest first).
- * @default ['2025-11-25', '2025-03-26', '2024-11-05']
+ * @default ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05']
*/
readonly protocolVersions?: string[];
diff --git a/src/constructs/rest-api.ts b/src/constructs/rest-api.ts
index 633dda1f..3863e52b 100644
--- a/src/constructs/rest-api.ts
+++ b/src/constructs/rest-api.ts
@@ -100,7 +100,7 @@ export interface McpAuthOptions {
/**
* Supported MCP protocol versions (newest first).
- * @default ['2025-11-25', '2025-03-26', '2024-11-05']
+ * @default ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05']
*/
readonly protocolVersions?: string[];
diff --git a/src/mcp-auth/mcp/server.ts b/src/mcp-auth/mcp/server.ts
index 605d5253..7ee718ea 100644
--- a/src/mcp-auth/mcp/server.ts
+++ b/src/mcp-auth/mcp/server.ts
@@ -62,12 +62,24 @@ export function createMcpServer
Optional ReadonlylambdaOptional ReadonlyprotocolSupported MCP protocol versions (newest first).
-Optional ReadonlyscopesOAuth scopes to advertise in discovery metadata.
diff --git a/docs/constructs/interfaces/McpAuthProps.html b/docs/constructs/interfaces/McpAuthProps.html index d808c7ae..07f92798 100644 --- a/docs/constructs/interfaces/McpAuthProps.html +++ b/docs/constructs/interfaces/McpAuthProps.html @@ -24,7 +24,7 @@ReadonlyclientThe pre-provisioned OAuth client ID returned by the register endpoint.
Optional ReadonlylambdaLambda function options for MCP auth handlers.
Optional ReadonlyprotocolSupported MCP protocol versions (newest first).
-Optional ReadonlyscopesOAuth scopes to advertise in discovery metadata.
diff --git a/docs/constructs/interfaces/McpCognitoAuthProps.html b/docs/constructs/interfaces/McpCognitoAuthProps.html index 16502e69..8046ad30 100644 --- a/docs/constructs/interfaces/McpCognitoAuthProps.html +++ b/docs/constructs/interfaces/McpCognitoAuthProps.html @@ -34,7 +34,7 @@Optional ReadonlylambdaLambda function options for MCP auth handlers.
Optional ReadonlyprotocolSupported MCP protocol versions (newest first).
-
Lambda function options for MCP auth handlers.