MCPcopy Create free account
hub / github.com/dexwritescode/rust-mcp / format_code_impl

Function format_code_impl

src/tools/formatting.rs:6–29  ·  view source on GitHub ↗
(
    args: Value,
    analyzer: &mut RustAnalyzerClient,
)

Source from the content-addressed store, hash-verified

4use serde_json::{Value, json};
5
6pub async fn format_code_impl(
7 args: Value,
8 analyzer: &mut RustAnalyzerClient,
9) -> Result<ToolResult> {
10 let file_path = args
11 .get("file_path")
12 .and_then(|v| v.as_str())
13 .ok_or_else(|| anyhow::anyhow!("Missing file_path parameter"))?;
14
15 // Implementation will use rust-analyzer LSP to format code
16 let result = analyzer.format_code(file_path).await?;
17
18 Ok(ToolResult {
19 content: vec![
20 json!({
21 "type": "text",
22 "text": result
23 })
24 .as_object()
25 .unwrap()
26 .clone(),
27 ],
28 })
29}

Callers 1

execute_toolFunction · 0.85

Calls 1

format_codeMethod · 0.45

Tested by

no test coverage detected