use rust_mcp_macros::JsonSchema;
use rust_mcp_schema::RpcError;
use std::str::FromStr;
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, JsonSchema)]
pub struct EditOperation {
#[serde(rename = "oldText")]
pub old_text: String,
#[serde(rename = "newText")]
pub new_text: String,
}
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, JsonSchema)]
pub struct EditFileTool {
pub path: String,
pub edits: Vec<EditOperation>,
#[serde(
rename = "dryRun",
default,
skip_serializing_if = "std::option::Option::is_none"
)]
pub dry_run: Option<bool>,
}
#[derive(JsonSchema, Debug)]
pub enum Colors {
#[json_schema(title = "Green Color")]
Green,
#[json_schema(title = "Red Color")]
Red,
}
impl FromStr for Colors {
type Err = RpcError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"green" => Ok(Colors::Green),
"red" => Ok(Colors::Red),
_ => Err(RpcError::parse_error().with_message("Invalid color".to_string())),
}
}
}