mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Update rmcp to 1.7.0 (#24763)
WIll make it easier to uprev when the new draft spec is supported. Also updates reqwest where needed for compatibility but doesn't update it everywhere since this is already a large diff. The new version of rmcp handles certain kinds of authentication failures differently, this patch includes support for identifying the failing scope in a WWW-Authenticate header.
This commit is contained in:
@@ -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)?)
|
||||
|
||||
@@ -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 {
|
||||
@@ -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(
|
||||
@@ -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(),
|
||||
|
||||
@@ -56,13 +56,13 @@ fn annotations(
|
||||
destructive: Option<bool>,
|
||||
open_world: Option<bool>,
|
||||
) -> ToolAnnotations {
|
||||
ToolAnnotations {
|
||||
destructive_hint: destructive,
|
||||
idempotent_hint: None,
|
||||
open_world_hint: open_world,
|
||||
read_only_hint: read_only,
|
||||
title: None,
|
||||
}
|
||||
ToolAnnotations::from_raw(
|
||||
/*title*/ None,
|
||||
read_only,
|
||||
destructive,
|
||||
/*idempotent_hint*/ None,
|
||||
open_world,
|
||||
)
|
||||
}
|
||||
|
||||
fn approval_metadata(
|
||||
|
||||
@@ -46,17 +46,11 @@ fn make_mcp_tool(
|
||||
callable_name: callable_name.to_string(),
|
||||
callable_namespace: callable_namespace.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: connector_id.map(str::to_string),
|
||||
connector_name: connector_name.map(str::to_string),
|
||||
plugin_display_names: Vec::new(),
|
||||
|
||||
@@ -522,19 +522,13 @@ mod tests {
|
||||
callable_name: tool_name.to_string(),
|
||||
callable_namespace: callable_namespace.to_string(),
|
||||
namespace_description: None,
|
||||
tool: rmcp::model::Tool {
|
||||
name: tool_name.to_string().into(),
|
||||
title: None,
|
||||
description: None,
|
||||
input_schema: Arc::new(rmcp::model::object(serde_json::json!({
|
||||
tool: rmcp::model::Tool::new_with_raw(
|
||||
tool_name.to_string(),
|
||||
None,
|
||||
Arc::new(rmcp::model::object(serde_json::json!({
|
||||
"type": "object",
|
||||
}))),
|
||||
output_schema: None,
|
||||
annotations: None,
|
||||
execution: None,
|
||||
icons: None,
|
||||
meta: None,
|
||||
},
|
||||
),
|
||||
connector_id: None,
|
||||
connector_name: None,
|
||||
plugin_display_names: Vec::new(),
|
||||
|
||||
@@ -82,10 +82,9 @@ impl ToolExecutor<ToolInvocation> for ListMcpResourceTemplatesHandler {
|
||||
|
||||
let payload_result: Result<ListResourceTemplatesPayload, FunctionCallError> = async {
|
||||
if let Some(server_name) = server.clone() {
|
||||
let params = cursor.clone().map(|value| PaginatedRequestParams {
|
||||
meta: None,
|
||||
cursor: Some(value),
|
||||
});
|
||||
let params = cursor
|
||||
.clone()
|
||||
.map(|value| PaginatedRequestParams::default().with_cursor(Some(value)));
|
||||
let result = session
|
||||
.list_resource_templates(&server_name, params)
|
||||
.await
|
||||
|
||||
@@ -82,10 +82,9 @@ impl ToolExecutor<ToolInvocation> for ListMcpResourcesHandler {
|
||||
|
||||
let payload_result: Result<ListResourcesPayload, FunctionCallError> = async {
|
||||
if let Some(server_name) = server.clone() {
|
||||
let params = cursor.clone().map(|value| PaginatedRequestParams {
|
||||
meta: None,
|
||||
cursor: Some(value),
|
||||
});
|
||||
let params = cursor
|
||||
.clone()
|
||||
.map(|value| PaginatedRequestParams::default().with_cursor(Some(value)));
|
||||
let result = session
|
||||
.list_resources(&server_name, params)
|
||||
.await
|
||||
|
||||
@@ -78,13 +78,7 @@ impl ToolExecutor<ToolInvocation> for ReadMcpResourceHandler {
|
||||
|
||||
let payload_result: Result<ReadResourcePayload, FunctionCallError> = async {
|
||||
let result = session
|
||||
.read_resource(
|
||||
&server,
|
||||
ReadResourceRequestParams {
|
||||
meta: None,
|
||||
uri: uri.clone(),
|
||||
},
|
||||
)
|
||||
.read_resource(&server, ReadResourceRequestParams::new(uri.clone()))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
FunctionCallError::RespondToModel(format!("resources/read failed: {err:#}"))
|
||||
|
||||
@@ -50,11 +50,10 @@ fn tool_info() -> ToolInfo {
|
||||
callable_name: "_create_event".to_string(),
|
||||
callable_namespace: "mcp__calendar__".to_string(),
|
||||
namespace_description: Some("Plan events.".to_string()),
|
||||
tool: rmcp::model::Tool {
|
||||
name: "createEvent".to_string().into(),
|
||||
title: Some("Create event".to_string()),
|
||||
description: Some("Create a calendar event.".to_string().into()),
|
||||
input_schema: Arc::new(rmcp::model::object(json!({
|
||||
tool: rmcp::model::Tool::new(
|
||||
"createEvent",
|
||||
"Create a calendar event.",
|
||||
Arc::new(rmcp::model::object(json!({
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"start_time": { "type": "string" },
|
||||
@@ -62,12 +61,8 @@ fn tool_info() -> ToolInfo {
|
||||
},
|
||||
"additionalProperties": false
|
||||
}))),
|
||||
output_schema: None,
|
||||
annotations: None,
|
||||
execution: None,
|
||||
icons: None,
|
||||
meta: None,
|
||||
},
|
||||
)
|
||||
.with_title("Create event"),
|
||||
connector_id: None,
|
||||
connector_name: Some("Calendar".to_string()),
|
||||
plugin_display_names: vec![" Calendar plugin ".to_string(), " ".to_string()],
|
||||
|
||||
@@ -258,21 +258,15 @@ mod tests {
|
||||
callable_name: tool_name.to_string(),
|
||||
callable_namespace: format!("mcp__{server_name}"),
|
||||
namespace_description: None,
|
||||
tool: Tool {
|
||||
name: tool_name.to_string().into(),
|
||||
title: None,
|
||||
description: Some(format!("{description_prefix} desktop tool").into()),
|
||||
input_schema: Arc::new(rmcp::model::object(serde_json::json!({
|
||||
tool: Tool::new(
|
||||
tool_name.to_string(),
|
||||
format!("{description_prefix} desktop tool"),
|
||||
Arc::new(rmcp::model::object(serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"additionalProperties": false,
|
||||
}))),
|
||||
output_schema: None,
|
||||
annotations: None,
|
||||
execution: None,
|
||||
icons: None,
|
||||
meta: None,
|
||||
},
|
||||
),
|
||||
connector_id: None,
|
||||
connector_name: None,
|
||||
plugin_display_names: Vec::new(),
|
||||
|
||||
@@ -306,19 +306,13 @@ fn mcp_tool_info(
|
||||
callable_name: tool_name.to_string(),
|
||||
callable_namespace: callable_namespace.to_string(),
|
||||
namespace_description: None,
|
||||
tool: rmcp::model::Tool {
|
||||
name: tool_name.to_string().into(),
|
||||
title: None,
|
||||
description: Some("Test MCP tool".to_string().into()),
|
||||
input_schema: Arc::new(rmcp::model::object(json!({
|
||||
tool: rmcp::model::Tool::new(
|
||||
tool_name.to_string(),
|
||||
"Test MCP tool",
|
||||
Arc::new(rmcp::model::object(json!({
|
||||
"type": "object",
|
||||
}))),
|
||||
output_schema: None,
|
||||
annotations: None,
|
||||
execution: None,
|
||||
icons: None,
|
||||
meta: None,
|
||||
},
|
||||
),
|
||||
connector_id: None,
|
||||
connector_name: None,
|
||||
plugin_display_names: Vec::new(),
|
||||
|
||||
@@ -302,21 +302,15 @@ fn mcp_tool(server: &str, namespace: &str, name: &str) -> ToolInfo {
|
||||
callable_name: name.to_string(),
|
||||
callable_namespace: namespace.to_string(),
|
||||
namespace_description: Some(format!("Tools from {server}.")),
|
||||
tool: rmcp::model::Tool {
|
||||
name: name.to_string().into(),
|
||||
title: None,
|
||||
description: Some(format!("{name} test tool").into()),
|
||||
input_schema: Arc::new(rmcp::model::object(json!({
|
||||
tool: rmcp::model::Tool::new(
|
||||
name.to_string(),
|
||||
format!("{name} test tool"),
|
||||
Arc::new(rmcp::model::object(json!({
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"additionalProperties": false,
|
||||
}))),
|
||||
output_schema: None,
|
||||
annotations: None,
|
||||
execution: None,
|
||||
icons: None,
|
||||
meta: None,
|
||||
},
|
||||
),
|
||||
connector_id: None,
|
||||
connector_name: None,
|
||||
plugin_display_names: Vec::new(),
|
||||
|
||||
Reference in New Issue
Block a user