Update rmcp to 3.1.3 (#39798)

## What changed

- Upgrade `rmcp` and `rmcp-macros` from 3.1.2 to 3.1.3.
- Preserve authentication-required and retryable transport classifications when modern MCP discovery falls back to legacy initialization.
- Prevent unrelated discovery errors from triggering legacy fallback while retaining their diagnostics.

## Testing

- Cover authentication challenges and transient initialization failures during legacy fallback.
- Verify that a failed OAuth issuer check does not consume the pending authorization state.

GitOrigin-RevId: 957c0873fec1148883dd163fbaeb77d7593d8c53
This commit is contained in:
stevenlee-oai authored and copyberry committed 2026-08-20 20:53:17 +00:00
1 parent cc801d7048
commit a3bce23f3b
9 files changed
+138 -10

No files matched your search

@@ -802,7 +802,7 @@ fn legacy_discovery_fallback_response(
{
return ServerJsonRpcMessage::error(
ErrorData::new(
ErrorCode::INVALID_REQUEST,
ErrorCode::HEADER_MISMATCH,
"server/discover method-not-found response did not match its request ID",
None,
),
@@ -855,6 +855,20 @@ fn legacy_discovery_fallback_response(
Some(request.id.clone()),
)
} else {
let mut response = response;
if let JsonRpcMessage::Error(error) = &mut response
&& !matches!(
error.error.code,
ErrorCode::METHOD_NOT_FOUND
| ErrorCode::UNSUPPORTED_PROTOCOL_VERSION
| ErrorCode::HEADER_MISMATCH
| ErrorCode::MISSING_REQUIRED_CLIENT_CAPABILITY
)
{
// rmcp 3.1.3 falls back on other discovery errors, so mark unproven
// rejections as modern failures while preserving their diagnostics.
error.error.code = ErrorCode::HEADER_MISMATCH;
}
response
}
}
@@ -1111,6 +1111,18 @@ mod tests {
expected_token_requests
);
assert_eq!(result.is_ok(), expected_token_requests == 1);
if expected_token_requests == 0 {
state
.handle_callback_with_issuer(
"legitimate-code",
&csrf_state,
Some(authorization_issuer.as_str()),
)
.await
.expect("issuer validation failures must preserve OAuth authorization state");
assert_eq!(token_requests.load(Ordering::SeqCst), 1);
}
server.abort();
}
}
+4 -1
View File
@@ -20,7 +20,10 @@ pub fn is_authentication_required_error(error: &Error) -> bool {
.is_some_and(auth_error_requires_authentication)
|| source
.downcast_ref::<ClientInitializeError>()
.is_some_and(|error| {
.is_some_and(|mut error| {
while let ClientInitializeError::LegacyFallbackFailed { fallback, .. } = error {
error = fallback;
}
matches!(
error,
ClientInitializeError::TransportError { error, .. }
@@ -121,6 +121,9 @@ impl RmcpClient {
fn is_retryable_client_initialize_error(error: &rmcp::service::ClientInitializeError) -> bool {
match error {
rmcp::service::ClientInitializeError::LegacyFallbackFailed { fallback, .. } => {
Self::is_retryable_client_initialize_error(fallback)
}
rmcp::service::ClientInitializeError::TransportError { error, context }
if matches!(
context.as_ref(),