From 08c03db4cff87eb7dbdb9a3c7d271dd36adb6e28 Mon Sep 17 00:00:00 2001 From: Alex Hancock Date: Tue, 21 Oct 2025 10:24:53 -0400 Subject: [PATCH 1/3] improvement: propagate McpErrors directly into ToolCallResult --- crates/goose/src/agents/extension_manager.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/goose/src/agents/extension_manager.rs b/crates/goose/src/agents/extension_manager.rs index 29294fc84c01..150c61bf4b81 100644 --- a/crates/goose/src/agents/extension_manager.rs +++ b/crates/goose/src/agents/extension_manager.rs @@ -3,7 +3,7 @@ use axum::http::{HeaderMap, HeaderName}; use chrono::{DateTime, Utc}; use futures::stream::{FuturesUnordered, StreamExt}; use futures::{future, FutureExt}; -use rmcp::service::ClientInitializeError; +use rmcp::service::{ClientInitializeError, ServiceError}; use rmcp::transport::streamable_http_client::{ AuthRequiredError, StreamableHttpClientTransportConfig, StreamableHttpError, }; @@ -937,7 +937,10 @@ impl ExtensionManager { .call_tool(&tool_name, arguments, cancellation_token) .await .map(|call| call.content) - .map_err(|e| ErrorData::new(ErrorCode::INTERNAL_ERROR, e.to_string(), None)) + .map_err(|e| match e { + ServiceError::McpError(error_data) => error_data, + _ => ErrorData::new(ErrorCode::INTERNAL_ERROR, e.to_string(), None), + }) }; Ok(ToolCallResult { From 3b963d03b75f754f74a3fad7113b8e23fc695d84 Mon Sep 17 00:00:00 2001 From: Alex Hancock Date: Tue, 21 Oct 2025 10:57:39 -0400 Subject: [PATCH 2/3] improvement: propagate original error as the data param when constructing ErrorData --- crates/goose/src/agents/extension_manager.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/goose/src/agents/extension_manager.rs b/crates/goose/src/agents/extension_manager.rs index 150c61bf4b81..50fd2ff1dfc4 100644 --- a/crates/goose/src/agents/extension_manager.rs +++ b/crates/goose/src/agents/extension_manager.rs @@ -40,6 +40,7 @@ use rmcp::model::{ ServerInfo, Tool, }; use rmcp::transport::auth::AuthClient; +use schemars::_private::NoSerialize; use serde_json::Value; type McpClientBox = Arc>>; @@ -939,7 +940,7 @@ impl ExtensionManager { .map(|call| call.content) .map_err(|e| match e { ServiceError::McpError(error_data) => error_data, - _ => ErrorData::new(ErrorCode::INTERNAL_ERROR, e.to_string(), None), + _ => ErrorData::new(ErrorCode::INTERNAL_ERROR, e.to_string(), e.maybe_to_value()), }) }; From eca4c6063213974303845e64804911401b7a7983 Mon Sep 17 00:00:00 2001 From: Alex Hancock Date: Tue, 21 Oct 2025 11:01:31 -0400 Subject: [PATCH 3/3] fix: cargo fmt --- crates/goose/src/agents/extension_manager.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/goose/src/agents/extension_manager.rs b/crates/goose/src/agents/extension_manager.rs index 50fd2ff1dfc4..40b668a7e88c 100644 --- a/crates/goose/src/agents/extension_manager.rs +++ b/crates/goose/src/agents/extension_manager.rs @@ -940,7 +940,9 @@ impl ExtensionManager { .map(|call| call.content) .map_err(|e| match e { ServiceError::McpError(error_data) => error_data, - _ => ErrorData::new(ErrorCode::INTERNAL_ERROR, e.to_string(), e.maybe_to_value()), + _ => { + ErrorData::new(ErrorCode::INTERNAL_ERROR, e.to_string(), e.maybe_to_value()) + } }) };