From 059ccdc5c643b3ef148f11ba1eac20d4867989fc Mon Sep 17 00:00:00 2001 From: syui Date: Sun, 1 Mar 2026 17:04:55 +0900 Subject: [PATCH] fix core --- src/mcp/server.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/mcp/server.rs b/src/mcp/server.rs index 7b59b38..2bb1583 100644 --- a/src/mcp/server.rs +++ b/src/mcp/server.rs @@ -61,6 +61,7 @@ impl MCPServer { } fn handle_initialize(&self, id: Value) -> Value { + let instructions = self.build_instructions(); json!({ "jsonrpc": "2.0", "id": id, @@ -72,11 +73,34 @@ impl MCPServer { "serverInfo": { "name": "aigpt", "version": "0.3.0" - } + }, + "instructions": instructions } }) } + fn build_instructions(&self) -> String { + let mut parts = Vec::new(); + + if let Ok(core) = reader::read_core() { + if let Some(text) = core["value"]["content"]["text"].as_str() { + if !text.is_empty() { + parts.push(text.to_string()); + } + } + } + + if let Ok(Some(memory)) = reader::read_memory() { + if let Some(text) = memory["value"]["content"]["text"].as_str() { + if !text.is_empty() { + parts.push(text.to_string()); + } + } + } + + parts.join("\n\n") + } + fn handle_tools_list(&self, id: Value) -> Value { let tools = vec![ json!({