Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

221 changes: 178 additions & 43 deletions codex-rs/Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion codex-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ rcgen = { version = "0.14.7", default-features = false, features = [
regex = "1.12.3"
regex-lite = "0.1.8"
reqwest = { version = "0.12", features = ["cookies"] }
rmcp = { version = "0.15.0", default-features = false }
rmcp = { version = "1.7.0", default-features = false }
runfiles = { git = "https://github.com/dzbarsky/rules_rust", rev = "b56cbaa8465e74127f1ea216f813cd377295ad81" }
rustls = { version = "0.23", default-features = false, features = [
"ring",
Expand Down
1 change: 1 addition & 0 deletions codex-rs/app-server-protocol/src/protocol/v2/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ impl From<McpServerElicitationRequestResponse> for rmcp::model::CreateElicitatio
Self {
action: value.action.into(),
content: value.content,
meta: None,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions codex-rs/app-server-protocol/src/protocol/v2/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,7 @@ fn mcp_server_elicitation_response_round_trips_rmcp_result() {
content: Some(json!({
"confirmed": true,
})),
meta: None,
};

let v2_response = McpServerElicitationRequestResponse::from(rmcp_result.clone());
Expand Down
5 changes: 1 addition & 4 deletions codex-rs/app-server/tests/suite/v2/app_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1432,10 +1432,7 @@ impl AppsServerControl {

impl ServerHandler for AppListMcpServer {
fn get_info(&self) -> ServerInfo {
ServerInfo {
capabilities: ServerCapabilities::builder().enable_tools().build(),
..ServerInfo::default()
}
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
}

fn list_tools(
Expand Down
37 changes: 16 additions & 21 deletions codex-rs/app-server/tests/suite/v2/mcp_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,8 @@ struct ResourceAppsMcpServer;

impl ServerHandler for ResourceAppsMcpServer {
fn get_info(&self) -> ServerInfo {
ServerInfo {
protocol_version: ProtocolVersion::V_2025_06_18,
capabilities: ServerCapabilities::builder().enable_resources().build(),
..ServerInfo::default()
}
ServerInfo::new(ServerCapabilities::builder().enable_resources().build())
.with_protocol_version(ProtocolVersion::V_2025_06_18)
}

async fn read_resource(
Expand All @@ -308,21 +305,19 @@ impl ServerHandler for ResourceAppsMcpServer {
));
}

Ok(ReadResourceResult {
contents: vec![
ResourceContents::TextResourceContents {
uri: TEST_RESOURCE_URI.to_string(),
mime_type: Some("text/markdown".to_string()),
text: TEST_RESOURCE_TEXT.to_string(),
meta: None,
},
ResourceContents::BlobResourceContents {
uri: TEST_BLOB_RESOURCE_URI.to_string(),
mime_type: Some("application/octet-stream".to_string()),
blob: TEST_RESOURCE_BLOB.to_string(),
meta: None,
},
],
})
Ok(ReadResourceResult::new(vec![
ResourceContents::TextResourceContents {
uri: TEST_RESOURCE_URI.to_string(),
mime_type: Some("text/markdown".to_string()),
text: TEST_RESOURCE_TEXT.to_string(),
meta: None,
},
ResourceContents::BlobResourceContents {
uri: TEST_BLOB_RESOURCE_URI.to_string(),
mime_type: Some("application/octet-stream".to_string()),
blob: TEST_RESOURCE_BLOB.to_string(),
meta: None,
},
]))
}
}
7 changes: 2 additions & 5 deletions codex-rs/app-server/tests/suite/v2/mcp_server_elicitation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,8 @@ struct ElicitationAppsMcpServer;

impl ServerHandler for ElicitationAppsMcpServer {
fn get_info(&self) -> ServerInfo {
ServerInfo {
protocol_version: rmcp::model::ProtocolVersion::V_2025_06_18,
capabilities: ServerCapabilities::builder().enable_tools().build(),
..ServerInfo::default()
}
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
.with_protocol_version(rmcp::model::ProtocolVersion::V_2025_06_18)
}

async fn list_tools(
Expand Down
12 changes: 4 additions & 8 deletions codex-rs/app-server/tests/suite/v2/mcp_server_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,7 @@ struct McpStatusServer {

impl ServerHandler for McpStatusServer {
fn get_info(&self) -> ServerInfo {
ServerInfo {
capabilities: ServerCapabilities::builder().enable_tools().build(),
..ServerInfo::default()
}
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
}

async fn list_tools(
Expand Down Expand Up @@ -244,13 +241,12 @@ struct SlowInventoryServer {

impl ServerHandler for SlowInventoryServer {
fn get_info(&self) -> ServerInfo {
ServerInfo {
capabilities: ServerCapabilities::builder()
ServerInfo::new(
ServerCapabilities::builder()
.enable_tools()
.enable_resources()
.build(),
..ServerInfo::default()
}
)
}

async fn list_tools(
Expand Down
5 changes: 1 addition & 4 deletions codex-rs/app-server/tests/suite/v2/mcp_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,7 @@ struct ToolAppsMcpServer;

impl ServerHandler for ToolAppsMcpServer {
fn get_info(&self) -> ServerInfo {
ServerInfo {
capabilities: ServerCapabilities::builder().enable_tools().build(),
..ServerInfo::default()
}
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
}

async fn list_tools(
Expand Down
5 changes: 1 addition & 4 deletions codex-rs/app-server/tests/suite/v2/plugin_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,10 +1122,7 @@ struct PluginInstallMcpServer {

impl ServerHandler for PluginInstallMcpServer {
fn get_info(&self) -> ServerInfo {
ServerInfo {
capabilities: ServerCapabilities::builder().enable_tools().build(),
..ServerInfo::default()
}
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
}

fn list_tools(
Expand Down
5 changes: 1 addition & 4 deletions codex-rs/app-server/tests/suite/v2/plugin_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1768,10 +1768,7 @@ struct PluginReadMcpServer {

impl ServerHandler for PluginReadMcpServer {
fn get_info(&self) -> ServerInfo {
ServerInfo {
capabilities: ServerCapabilities::builder().enable_tools().build(),
..ServerInfo::default()
}
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
}

fn list_tools(
Expand Down
10 changes: 4 additions & 6 deletions codex-rs/codex-mcp/src/connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,8 @@ impl McpConnectionManager {
let mut cursor: Option<String> = None;

loop {
let params = cursor.as_ref().map(|next| PaginatedRequestParams {
meta: None,
cursor: Some(next.clone()),
let params = cursor.as_ref().map(|next| {
PaginatedRequestParams::default().with_cursor(Some(next.clone()))
});
let response = match client.list_resources(params, timeout).await {
Ok(result) => result,
Expand Down Expand Up @@ -576,9 +575,8 @@ impl McpConnectionManager {
let mut cursor: Option<String> = None;

loop {
let params = cursor.as_ref().map(|next| PaginatedRequestParams {
meta: None,
cursor: Some(next.clone()),
let params = cursor.as_ref().map(|next| {
PaginatedRequestParams::default().with_cursor(Some(next.clone()))
});
let response = match client.list_resource_templates(params, timeout).await {
Ok(result) => result,
Expand Down
16 changes: 5 additions & 11 deletions codex-rs/codex-mcp/src/connection_manager_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,11 @@ fn create_test_tool(server_name: &str, tool_name: &str) -> ToolInfo {
callable_name: tool_name.to_string(),
callable_namespace: server_name.to_string(),
namespace_description: None,
tool: Tool {
name: tool_name.to_string().into(),
title: None,
description: Some(format!("Test tool: {tool_name}").into()),
input_schema: Arc::new(JsonObject::default()),
output_schema: None,
annotations: None,
execution: None,
icons: None,
meta: None,
},
tool: Tool::new(
tool_name.to_string(),
format!("Test tool: {tool_name}"),
Arc::new(JsonObject::default()),
),
connector_id: None,
connector_name: None,
plugin_display_names: Vec::new(),
Expand Down
8 changes: 1 addition & 7 deletions codex-rs/codex-mcp/src/mcp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,7 @@ pub async fn read_mcp_resource(
.await;

let result = manager
.read_resource(
server,
ReadResourceRequestParams {
meta: None,
uri: uri.to_string(),
},
)
.read_resource(server, ReadResourceRequestParams::new(uri))
.await;
cancel_token.cancel();
result
Expand Down
74 changes: 28 additions & 46 deletions codex-rs/codex-mcp/src/rmcp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,26 +470,13 @@ async fn start_server_task(
codex_apps_tools_cache_context,
client_elicitation_capability,
} = params;
let params = InitializeRequestParams {
meta: None,
capabilities: ClientCapabilities {
experimental: None,
extensions: None,
roots: None,
sampling: None,
elicitation: Some(client_elicitation_capability),
tasks: None,
},
client_info: Implementation {
name: "codex-mcp-client".to_owned(),
version: env!("CARGO_PKG_VERSION").to_owned(),
title: Some("Codex".into()),
description: None,
icons: None,
website_url: None,
},
protocol_version: ProtocolVersion::V_2025_06_18,
};
let mut capabilities = ClientCapabilities::default();
capabilities.elicitation = Some(client_elicitation_capability);
let params = InitializeRequestParams::new(
capabilities,
Implementation::new("codex-mcp-client", env!("CARGO_PKG_VERSION")).with_title("Codex"),
)
.with_protocol_version(ProtocolVersion::V_2025_06_18);

let send_elicitation = elicitation_requests.make_sender(server_name.clone(), tx_event);

Expand Down Expand Up @@ -647,32 +634,27 @@ mod tests {
use rmcp::model::Meta;

fn tool_with_connector_meta() -> RmcpTool {
RmcpTool {
name: "capture_file_upload".to_string().into(),
title: None,
description: Some("test tool".to_string().into()),
input_schema: Arc::new(JsonObject::default()),
output_schema: None,
annotations: None,
execution: None,
icons: None,
meta: Some(Meta(
serde_json::json!({
"connector_id": "connector_gmail",
"connector_name": "Gmail",
"connector_display_name": "Gmail",
"connector_description": "Mail connector",
"connectorDescription": "Mail connector",
"connectorFutureField": "future connector metadata",
"CONNECTOR_UPPERCASE": "uppercase connector metadata",
"openai/fileParams": ["file"],
"custom": "kept"
})
.as_object()
.expect("object")
.clone(),
)),
}
RmcpTool::new(
"capture_file_upload",
"test tool",
Arc::new(JsonObject::default()),
)
.with_meta(Meta(
serde_json::json!({
"connector_id": "connector_gmail",
"connector_name": "Gmail",
"connector_display_name": "Gmail",
"connector_description": "Mail connector",
"connectorDescription": "Mail connector",
"connectorFutureField": "future connector metadata",
"CONNECTOR_UPPERCASE": "uppercase connector metadata",
"openai/fileParams": ["file"],
"custom": "kept"
})
.as_object()
.expect("object")
.clone(),
))
}

#[test]
Expand Down
8 changes: 1 addition & 7 deletions codex-rs/core/src/codex_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,7 @@ impl CodexThread {
let result = self
.codex
.session
.read_resource(
server,
ReadResourceRequestParams {
meta: None,
uri: uri.to_string(),
},
)
.read_resource(server, ReadResourceRequestParams::new(uri))
.await?;

Ok(serde_json::to_value(result)?)
Expand Down
38 changes: 11 additions & 27 deletions codex-rs/core/src/connectors_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ use std::sync::Arc;
use tempfile::tempdir;

fn annotations(destructive_hint: Option<bool>, open_world_hint: Option<bool>) -> ToolAnnotations {
ToolAnnotations {
ToolAnnotations::from_raw(
/*title*/ None,
/*read_only_hint*/ None,
destructive_hint,
idempotent_hint: None,
/*idempotent_hint*/ None,
open_world_hint,
read_only_hint: None,
title: None,
}
)
}

fn app(id: &str) -> AppInfo {
Expand All @@ -63,17 +63,7 @@ fn plugin_names(names: &[&str]) -> Vec<String> {
}

fn test_tool_definition(tool_name: &str) -> Tool {
Tool {
name: tool_name.to_string().into(),
title: None,
description: None,
input_schema: Arc::new(JsonObject::default()),
output_schema: None,
annotations: None,
execution: None,
icons: None,
meta: None,
}
Tool::new_with_raw(tool_name.to_string(), None, Arc::new(JsonObject::default()))
}

fn codex_app_tool(
Expand Down Expand Up @@ -243,17 +233,11 @@ fn accessible_connectors_from_mcp_tools_preserves_description() {
callable_name: "calendar_create_event".to_string(),
callable_namespace: "mcp__codex_apps__calendar".to_string(),
namespace_description: Some("Plan events".to_string()),
tool: Tool {
name: "calendar_create_event".to_string().into(),
title: None,
description: Some("Create a calendar event".into()),
input_schema: Arc::new(JsonObject::default()),
output_schema: None,
annotations: None,
execution: None,
icons: None,
meta: None,
},
tool: Tool::new(
"calendar_create_event",
"Create a calendar event",
Arc::new(JsonObject::default()),
),
connector_id: Some("calendar".to_string()),
connector_name: Some("Calendar".to_string()),
plugin_display_names: Vec::new(),
Expand Down
Loading
Loading