use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolDescription {
pub name: String,
pub description: String,
pub input_schema: serde_json::Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResourceDescription {
pub uri: String,
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub mime_type: Option<String>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn tool_description_serializes() {
let tool = ToolDescription {
name: "search".into(),
description: "Search documents".into(),
input_schema: serde_json::json!({"type": "object"}),
};
let json = serde_json::to_string(&tool).unwrap();
assert!(json.contains("\"search\""));
}
#[test]
fn resource_description_roundtrip() {
let res = ResourceDescription {
uri: "docs://readme".into(),
name: "README".into(),
description: Some("Project readme".into()),
mime_type: Some("text/markdown".into()),
};
let json = serde_json::to_string(&res).unwrap();
let back: ResourceDescription = serde_json::from_str(&json).unwrap();
assert_eq!(back.uri, "docs://readme");
}
}