Improve MCP server responses (#34927)

Release Notes:

- N/A
This commit is contained in:
Agus Zubiaga 2025-07-22 19:14:34 -03:00 committed by GitHub
parent 7f70325a93
commit 5d985fa1d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 25 deletions

View file

@ -19,7 +19,7 @@ use util::debug_panic;
use crate::claude::{
McpServerConfig,
tools::{ClaudeTool, EditToolParams, EditToolResponse, ReadToolParams, ReadToolResponse},
tools::{ClaudeTool, EditToolParams, ReadToolParams},
};
pub struct ClaudeMcpServer {
@ -179,11 +179,9 @@ impl ClaudeMcpServer {
let input =
serde_json::from_value(request.arguments.context("Arguments required")?)?;
let result = Self::handle_read_tool_call(input, delegate, cx).await?;
let content = Self::handle_read_tool_call(input, delegate, cx).await?;
Ok(CallToolResponse {
content: vec![ToolResponseContent::Text {
text: serde_json::to_string(&result)?,
}],
content,
is_error: None,
meta: None,
})
@ -191,11 +189,9 @@ impl ClaudeMcpServer {
let input =
serde_json::from_value(request.arguments.context("Arguments required")?)?;
let result = Self::handle_edit_tool_call(input, delegate, cx).await?;
Self::handle_edit_tool_call(input, delegate, cx).await?;
Ok(CallToolResponse {
content: vec![ToolResponseContent::Text {
text: serde_json::to_string(&result)?,
}],
content: vec![],
is_error: None,
meta: None,
})
@ -209,7 +205,7 @@ impl ClaudeMcpServer {
params: ReadToolParams,
delegate: AcpClientDelegate,
cx: &AsyncApp,
) -> Task<Result<ReadToolResponse>> {
) -> Task<Result<Vec<ToolResponseContent>>> {
cx.foreground_executor().spawn(async move {
let response = delegate
.read_text_file(ReadTextFileParams {
@ -219,9 +215,9 @@ impl ClaudeMcpServer {
})
.await?;
Ok(ReadToolResponse {
content: response.content,
})
Ok(vec![ToolResponseContent::Text {
text: response.content,
}])
})
}
@ -229,7 +225,7 @@ impl ClaudeMcpServer {
params: EditToolParams,
delegate: AcpClientDelegate,
cx: &AsyncApp,
) -> Task<Result<EditToolResponse>> {
) -> Task<Result<()>> {
cx.foreground_executor().spawn(async move {
let response = delegate
.read_text_file_reusing_snapshot(ReadTextFileParams {
@ -251,7 +247,7 @@ impl ClaudeMcpServer {
})
.await?;
Ok(EditToolResponse)
Ok(())
})
}

View file

@ -434,10 +434,6 @@ pub struct EditToolParams {
pub new_text: String,
}
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct EditToolResponse;
#[derive(Deserialize, JsonSchema, Debug)]
pub struct ReadToolParams {
/// The absolute path to the file to read.
@ -450,12 +446,6 @@ pub struct ReadToolParams {
pub limit: Option<u32>,
}
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ReadToolResponse {
pub content: String,
}
#[derive(Deserialize, JsonSchema, Debug)]
pub struct WriteToolParams {
/// Absolute path for new file