parent
7f70325a93
commit
5d985fa1d8
2 changed files with 11 additions and 25 deletions
|
@ -19,7 +19,7 @@ use util::debug_panic;
|
||||||
|
|
||||||
use crate::claude::{
|
use crate::claude::{
|
||||||
McpServerConfig,
|
McpServerConfig,
|
||||||
tools::{ClaudeTool, EditToolParams, EditToolResponse, ReadToolParams, ReadToolResponse},
|
tools::{ClaudeTool, EditToolParams, ReadToolParams},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ClaudeMcpServer {
|
pub struct ClaudeMcpServer {
|
||||||
|
@ -179,11 +179,9 @@ impl ClaudeMcpServer {
|
||||||
let input =
|
let input =
|
||||||
serde_json::from_value(request.arguments.context("Arguments required")?)?;
|
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 {
|
Ok(CallToolResponse {
|
||||||
content: vec![ToolResponseContent::Text {
|
content,
|
||||||
text: serde_json::to_string(&result)?,
|
|
||||||
}],
|
|
||||||
is_error: None,
|
is_error: None,
|
||||||
meta: None,
|
meta: None,
|
||||||
})
|
})
|
||||||
|
@ -191,11 +189,9 @@ impl ClaudeMcpServer {
|
||||||
let input =
|
let input =
|
||||||
serde_json::from_value(request.arguments.context("Arguments required")?)?;
|
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 {
|
Ok(CallToolResponse {
|
||||||
content: vec![ToolResponseContent::Text {
|
content: vec![],
|
||||||
text: serde_json::to_string(&result)?,
|
|
||||||
}],
|
|
||||||
is_error: None,
|
is_error: None,
|
||||||
meta: None,
|
meta: None,
|
||||||
})
|
})
|
||||||
|
@ -209,7 +205,7 @@ impl ClaudeMcpServer {
|
||||||
params: ReadToolParams,
|
params: ReadToolParams,
|
||||||
delegate: AcpClientDelegate,
|
delegate: AcpClientDelegate,
|
||||||
cx: &AsyncApp,
|
cx: &AsyncApp,
|
||||||
) -> Task<Result<ReadToolResponse>> {
|
) -> Task<Result<Vec<ToolResponseContent>>> {
|
||||||
cx.foreground_executor().spawn(async move {
|
cx.foreground_executor().spawn(async move {
|
||||||
let response = delegate
|
let response = delegate
|
||||||
.read_text_file(ReadTextFileParams {
|
.read_text_file(ReadTextFileParams {
|
||||||
|
@ -219,9 +215,9 @@ impl ClaudeMcpServer {
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(ReadToolResponse {
|
Ok(vec![ToolResponseContent::Text {
|
||||||
content: response.content,
|
text: response.content,
|
||||||
})
|
}])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +225,7 @@ impl ClaudeMcpServer {
|
||||||
params: EditToolParams,
|
params: EditToolParams,
|
||||||
delegate: AcpClientDelegate,
|
delegate: AcpClientDelegate,
|
||||||
cx: &AsyncApp,
|
cx: &AsyncApp,
|
||||||
) -> Task<Result<EditToolResponse>> {
|
) -> Task<Result<()>> {
|
||||||
cx.foreground_executor().spawn(async move {
|
cx.foreground_executor().spawn(async move {
|
||||||
let response = delegate
|
let response = delegate
|
||||||
.read_text_file_reusing_snapshot(ReadTextFileParams {
|
.read_text_file_reusing_snapshot(ReadTextFileParams {
|
||||||
|
@ -251,7 +247,7 @@ impl ClaudeMcpServer {
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(EditToolResponse)
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -434,10 +434,6 @@ pub struct EditToolParams {
|
||||||
pub new_text: String,
|
pub new_text: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct EditToolResponse;
|
|
||||||
|
|
||||||
#[derive(Deserialize, JsonSchema, Debug)]
|
#[derive(Deserialize, JsonSchema, Debug)]
|
||||||
pub struct ReadToolParams {
|
pub struct ReadToolParams {
|
||||||
/// The absolute path to the file to read.
|
/// The absolute path to the file to read.
|
||||||
|
@ -450,12 +446,6 @@ pub struct ReadToolParams {
|
||||||
pub limit: Option<u32>,
|
pub limit: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct ReadToolResponse {
|
|
||||||
pub content: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, JsonSchema, Debug)]
|
#[derive(Deserialize, JsonSchema, Debug)]
|
||||||
pub struct WriteToolParams {
|
pub struct WriteToolParams {
|
||||||
/// Absolute path for new file
|
/// Absolute path for new file
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue