diff --git a/server/src/router.rs b/server/src/router.rs
index 1341512..877ab94 100644
--- a/server/src/router.rs
+++ b/server/src/router.rs
@@ -573,6 +573,21 @@ impl MemoryHandler {
Some(crate::mcp::success(id, payload))
}
"initialize" => {
+ if let Some(params) = req.get("params") {
+ if let Some(client_info) = params.get("clientInfo") {
+ if let Some(name) = client_info.get("name").and_then(|n| n.as_str()) {
+ let dialect = if name.to_lowercase().contains("claude") {
+ "xml".to_string()
+ } else {
+ "markdown".to_string()
+ };
+ if let Ok(mut write_guard) = self.state.dialect.write() {
+ *write_guard = dialect;
+ }
+ }
+ }
+ }
+
let init = rmcp::model::InitializeResult::new(
rmcp::model::ServerCapabilities::builder()
.enable_tools()
@@ -765,10 +780,15 @@ impl MemoryHandler {
match result {
Ok(text) => {
- let mut content_obj = serde_json::json!({"type": "text", "text": &text});
+ let formatted_text = match self.state.dialect.read().map(|d| d.clone()) {
+ Ok(d) if d == "xml" => format!("\n{}\n", text),
+ _ => text.clone(),
+ };
+
+ let mut content_obj = serde_json::json!({"type": "text", "text": &formatted_text});
// Heuristic: If response is large (e.g. > 4000 chars), inject cache_control for Prompt Caching
- if text.len() > 4000 {
+ if formatted_text.len() > 4000 {
content_obj["cacheControl"] = serde_json::json!({"type": "ephemeral"});
}
diff --git a/server/src/state.rs b/server/src/state.rs
index 687a134..38f11ca 100644
--- a/server/src/state.rs
+++ b/server/src/state.rs
@@ -133,6 +133,7 @@ pub struct MemoryState {
pub event_bus_tx: tokio::sync::broadcast::Sender,
pub ollama: Arc,
pub clipboard_cache: Arc>,
+ pub dialect: std::sync::RwLock,
}
impl MemoryState {
@@ -206,6 +207,7 @@ impl MemoryState {
activity_tx: tokio::sync::broadcast::channel(100).0,
event_bus_tx: tokio::sync::broadcast::channel(1000).0,
clipboard_cache: Arc::new(tokio::sync::RwLock::new(ClipboardCacheState::default())),
+ dialect: std::sync::RwLock::new("markdown".to_string()),
};
// Normalize pre-existing graph entity and relation types