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