Skip to main content

winx_code_agent/tools/
mod.rs

1//! Tools module for the Winx application.
2//!
3//! This module hosts the individual MCP tool implementations (shell, file IO,
4//! image, context save). The live service that wires them to the MCP protocol
5//! is [`crate::server::WinxService`].
6
7pub mod background_shell;
8pub mod bash_command;
9pub mod code_map;
10pub mod context_save;
11pub mod file_write_or_edit;
12pub mod initialize;
13pub mod multi_file_edit;
14pub mod outline;
15pub mod read_files;
16pub mod read_image;
17pub mod references;
18pub mod undo_edit;
19
20/// Serialize a tool's structured output to JSON for the MCP result's
21/// `structuredContent`, mapping the (practically impossible) failure to a domain
22/// error instead of panicking. Used by the read-only `CodeMap` handlers.
23pub(crate) fn structured_json<T: serde::Serialize>(
24    value: &T,
25) -> crate::errors::Result<serde_json::Value> {
26    serde_json::to_value(value).map_err(|e| {
27        crate::errors::WinxError::SerializationError(format!("structured output: {e}"))
28    })
29}