Upgrade rmcp to 3.0.0-beta.3 (#35720)

## What changed

- Update the `rmcp` model and transport integrations for `3.0.0-beta.3`.
- Preserve legacy `elicitation/create` form requests, schema defaults, metadata, and wire-format compatibility while adopting the new elicitation types.
- Harden OAuth discovery by using GET-first discovery without starting an MCP session, preventing cross-origin header redirects, validating authorization-server and callback issuers, and retaining compatibility with metadata that omits an issuer.
- Keep stored OAuth credentials readable and avoid requiring reauthorization after transient refresh failures.

## Testing

- Add coverage for legacy elicitation round trips, OAuth discovery variants, callback issuer validation, credential migration, and refresh failures.

GitOrigin-RevId: 756197d26f3fd347c28c400228f6b3d06ed493b7
This commit is contained in:
thomas authored and copyberry committed 2026-07-28 05:17:25 +00:00
1 parent 899539c03a
commit 61de0d8fe8
48 files changed
+1391 -639

No files matched your search

+11 -9
View File
@@ -86,7 +86,7 @@ impl McpToolCallCell {
}
fn render_content_block(block: &serde_json::Value, width: usize) -> String {
let content = match serde_json::from_value::<rmcp::model::Content>(block.clone()) {
let content = match serde_json::from_value::<rmcp::model::ContentBlock>(block.clone()) {
Ok(content) => content,
Err(_) => {
return format_and_truncate_tool_result(
@@ -97,20 +97,22 @@ impl McpToolCallCell {
}
};
match content.raw {
rmcp::model::RawContent::Text(text) => {
match content {
rmcp::model::ContentBlock::Text(text) => {
format_and_truncate_tool_result(&text.text, TOOL_CALL_MAX_LINES, width)
}
rmcp::model::RawContent::Image(_) => "<image content>".to_string(),
rmcp::model::RawContent::Audio(_) => "<audio content>".to_string(),
rmcp::model::RawContent::Resource(resource) => {
rmcp::model::ContentBlock::Image(_) => "<image content>".to_string(),
rmcp::model::ContentBlock::Audio(_) => "<audio content>".to_string(),
rmcp::model::ContentBlock::Resource(resource) => {
let uri = match resource.resource {
rmcp::model::ResourceContents::TextResourceContents { uri, .. } => uri,
rmcp::model::ResourceContents::BlobResourceContents { uri, .. } => uri,
_ => return "<unknown embedded resource>".to_string(),
};
format!("embedded resource: {uri}")
}
rmcp::model::RawContent::ResourceLink(link) => format!("link: {}", link.uri),
rmcp::model::ContentBlock::ResourceLink(link) => format!("link: {}", link.uri),
_ => format_and_truncate_tool_result(&block.to_string(), TOOL_CALL_MAX_LINES, width),
}
}
}
@@ -282,8 +284,8 @@ fn try_new_completed_mcp_tool_call_with_image_output(
/// Returns `None` when the block is not an image, when base64 decoding fails, when the format
/// cannot be inferred, or when the image decoder rejects the bytes.
fn decode_mcp_image(block: &serde_json::Value) -> Option<DynamicImage> {
let content = serde_json::from_value::<rmcp::model::Content>(block.clone()).ok()?;
let rmcp::model::RawContent::Image(image) = content.raw else {
let content = serde_json::from_value::<rmcp::model::ContentBlock>(block.clone()).ok()?;
let rmcp::model::ContentBlock::Image(image) = content else {
return None;
};
let base64_data = if let Some(data_url) = image.data.strip_prefix("data:") {
+8 -14
View File
@@ -31,7 +31,7 @@ use std::path::PathBuf;
use codex_app_server_protocol::CommandExecutionSource as ExecCommandSource;
use codex_protocol::mcp::CallToolResult;
use codex_protocol::mcp::Tool;
use rmcp::model::Content;
use rmcp::model::ContentBlock;
const SMALL_PNG_BASE64: &str = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg==";
async fn test_config() -> Config {
@@ -175,12 +175,12 @@ fn assert_unstyled_lines(lines: &[Line<'static>]) {
}
fn image_block(data: &str) -> serde_json::Value {
serde_json::to_value(Content::image(data.to_string(), "image/png"))
serde_json::to_value(ContentBlock::image(data.to_string(), "image/png"))
.expect("image content should serialize")
}
fn text_block(text: &str) -> serde_json::Value {
serde_json::to_value(Content::text(text)).expect("text content should serialize")
serde_json::to_value(ContentBlock::text(text)).expect("text content should serialize")
}
fn resource_link_block(
@@ -189,17 +189,11 @@ fn resource_link_block(
title: Option<&str>,
description: Option<&str>,
) -> serde_json::Value {
serde_json::to_value(Content::resource_link(rmcp::model::RawResource {
uri: uri.to_string(),
name: name.to_string(),
title: title.map(str::to_string),
description: description.map(str::to_string),
mime_type: None,
size: None,
icons: None,
meta: None,
}))
.expect("resource link content should serialize")
let mut resource = rmcp::model::Resource::new(uri, name);
resource.title = title.map(str::to_string);
resource.description = description.map(str::to_string);
serde_json::to_value(ContentBlock::resource_link(resource))
.expect("resource link content should serialize")
}
#[test]