agentic_memory_mcp/tools/
memory_workspace_create.rs1use std::sync::Arc;
4use tokio::sync::Mutex;
5
6use serde::Deserialize;
7use serde_json::{json, Value};
8
9use crate::session::SessionManager;
10use crate::types::{McpError, McpResult, ToolCallResult, ToolDefinition};
11
12#[derive(Debug, Deserialize)]
13struct CreateParams {
14 name: String,
15}
16
17pub fn definition() -> ToolDefinition {
19 ToolDefinition {
20 name: "memory_workspace_create".to_string(),
21 description: Some(
22 "Create a multi-memory workspace for loading and querying multiple .amem files \
23 simultaneously. Use this to compare memories across projects or time periods."
24 .to_string(),
25 ),
26 input_schema: json!({
27 "type": "object",
28 "required": ["name"],
29 "properties": {
30 "name": {
31 "type": "string",
32 "description": "Name for the workspace"
33 }
34 }
35 }),
36 }
37}
38
39pub async fn execute(
41 args: Value,
42 session: &Arc<Mutex<SessionManager>>,
43) -> McpResult<ToolCallResult> {
44 let params: CreateParams =
45 serde_json::from_value(args).map_err(|e| McpError::InvalidParams(e.to_string()))?;
46
47 let mut session = session.lock().await;
48 let id = session.workspace_manager_mut().create(¶ms.name);
49
50 Ok(ToolCallResult::json(&json!({
51 "workspace_id": id,
52 "name": params.name,
53 "status": "created"
54 })))
55}