1/// The implementation of this tool draws heavily from Zed's
2/// See
3use std::path::PathBuf;
4
5use async_lsp::LanguageServer;
6use async_lsp::lsp_types::{
7 DocumentDiagnosticParams, DocumentDiagnosticReportResult, PartialResultParams,
8 TextDocumentIdentifier, Url, WorkDoneProgressParams,
9};
10use rmcp::ErrorData as MCPError;
11use rmcp::{handler::server::wrapper::Parameters, model::CallToolResult, schemars, serde_json};
12
13use crate::mcp::*;
14
15#[derive(Debug, serde::Deserialize, schemars::JsonSchema)]
16pub struct ReadToolArgs {
17 pub path: PathBuf,
18 pub range_start: usize,
19 pub range_end: usize,
20}
21
22#[derive(Debug, serde::Serialize)]
23pub struct ReadToolOutput {
24 pub content: Option<String>,
25 pub diagnostics: DocumentDiagnosticReportResult,
26}
27
28pub async fn call(
29 server: &MCPServer,
30 Parameters(args): Parameters<ReadToolArgs>,
31) -> Result<CallToolResult, MCPError> {
32 Err(MCPError::internal_error("Not yet implemented", None))
33 // let content = tokio::fs::read_to_string(&file_path)
34 // .await
35 // .map_err(|e| MCPError::invalid_request(format!("Failed to read file: {e}"), None))?;
36
37 // let mut lsp_server = server.lsp_server.clone();
38
39 // let diagnostic_report = lsp_server
40 // .document_diagnostic(DocumentDiagnosticParams {
41 // text_document: TextDocumentIdentifier::new(Url::from_file_path(file_path).unwrap()),
42 // identifier: None,
43 // previous_result_id: None,
44 // work_done_progress_params: WorkDoneProgressParams {
45 // work_done_token: None,
46 // },
47 // partial_result_params: PartialResultParams {
48 // partial_result_token: None,
49 // },
50 // })
51 // .await
52 // .unwrap();
53
54 // Ok(CallToolResult {
55 // content: vec![],
56 // structured_content: Some(serde_json::json!(ReadToolOutput {
57 // content: Some(content),
58 // diagnostics: diagnostic_report
59 // })),
60 // is_error: None,
61 // meta: None,
62 // })
63}