refactor: Enforce agentic API design across mcp-memory handlers

- Replaced unconstrained JSON serialization (serde_json) with dense YAML (serde_yaml) to prevent context window bloat (ADR-0122).
- Replaced 404/empty array dead ends with token-efficient LLM fallback hints in router and meta/graph handlers.
- Ensured graceful error fallbacks instead of hard crashes.
This commit is contained in:
Riz Ashraf committed 2026-10-10 19:39:08 +01:00
1 parent f56750f596
commit 2024d9521b
3 files changed
+18 -18

No files matched your search

+2 -2
View File
@@ -791,7 +791,7 @@ impl McpTool for SearchNodesHandler {
}
}
}
Ok::<String, crate::error::AppError>(serde_yaml::to_string(&matched_entities)?)
if matched_entities.is_empty() { Ok::<String, crate::error::AppError>(format!("No entities found matching query. Try using a different keyword or relaxing the search query.")) } else { Ok::<String, crate::error::AppError>(serde_yaml::to_string(&matched_entities)?) }
})?;
Ok(data)
}
@@ -832,7 +832,7 @@ impl McpTool for OpenNodesHandler {
result.entities.insert(name, e);
}
}
Ok::<String, crate::error::AppError>(serde_yaml::to_string(&result)?)
if result.entities.is_empty() { Ok::<String, crate::error::AppError>(format!("No matching nodes found.")) } else { Ok::<String, crate::error::AppError>(serde_yaml::to_string(&result)?) }
})?;
Ok(data)
}