From 02bafa5db126d38313fec7fccfcef93692e0b441 Mon Sep 17 00:00:00 2001 From: Riz Ashraf Date: Sat, 12 Sep 2026 09:10:13 +0100 Subject: [PATCH] feat(server): inject explicit descriptions into MCP tools/list payload --- server/src/fix_descriptions.py | 78 ++++++++++++++++++++++++ server/src/handlers.rs | 108 ++++++++++++++++----------------- 2 files changed, 132 insertions(+), 54 deletions(-) create mode 100644 server/src/fix_descriptions.py diff --git a/server/src/fix_descriptions.py b/server/src/fix_descriptions.py new file mode 100644 index 0000000..a14a7a0 --- /dev/null +++ b/server/src/fix_descriptions.py @@ -0,0 +1,78 @@ +import re + +descriptions = { + "create_entities": "Create new entities in the knowledge graph.", + "create_relations": "Create new relations between entities in the knowledge graph.", + "add_observations": "Add new observations to existing entities in the knowledge graph.", + "delete_entities": "Delete entities from the knowledge graph.", + "delete_observations": "Delete observations from existing entities.", + "delete_relations": "Delete relations between entities.", + "read_graph": "Read the entire knowledge graph.", + "search_nodes": "Search for entities in the knowledge graph by name or type.", + "open_nodes": "Open and retrieve full details of specific nodes in the knowledge graph.", + "log_code_change": "Log a significant code change or refactor in the memory system.", + "query_recent_changes": "Query recently logged code changes.", + "visualize_graph": "Generate a visual representation of the knowledge graph.", + "add_sticky_note": "Add a sticky note for unstructured thoughts or reminders.", + "read_sticky_notes": "Read all active sticky notes.", + "condense_entity": "Condense or summarize an entity's observations to reduce size.", + "add_task": "Add a new task to the task tracker.", + "update_task_status": "Update the status of an existing task.", + "list_active_tasks": "List all currently active tasks.", + "store_snippet": "Store a reusable code snippet.", + "search_snippets": "Search through stored code snippets.", + "delete_snippet": "Delete a stored code snippet.", + "log_decision": "Log an architectural decision record (ADR).", + "query_decisions": "Query architectural decision records.", + "merge_entities": "Merge two entities in the knowledge graph into one.", + "find_orphans": "Find orphaned entities (entities without any relations) in the graph.", + "learn_preference": "Record a user preference or behavior to adapt future interactions.", + "read_preferences": "Read all learned user preferences.", + "log_error_fix": "Log a complex error and its fix for future reference.", + "search_error_fixes": "Search through previously logged error fixes.", + "pin_file": "Pin a file to keep it explicitly in the context workspace.", + "unpin_file": "Unpin a file from the context workspace.", + "list_pinned_files": "List all currently pinned files.", + "add_session_summary": "Add a summary of the current session.", + "get_project_timeline": "Get a timeline of major project events.", + "leave_handoff_memo": "Leave a memo for the next session or agent.", + "read_handoff_memos": "Read pending handoff memos.", + "clear_handoff_memos": "Clear handoff memos after reading.", + "update_env_fingerprint": "Update the environment fingerprint (e.g., OS, tool versions).", + "read_env_fingerprint": "Read the current environment fingerprint.", + "log_env_requirement": "Log a required tool or package for the environment.", + "add_milestone": "Add a new project milestone.", + "update_milestone": "Update the status of a project milestone.", + "list_milestones": "List all project milestones.", + "generate_standup_report": "Generate a standup report based on recent activity.", + "register_environment": "Register details about a specific deployment environment.", + "get_environment_details": "Get details about a registered environment.", + "add_pr_checklist_item": "Add an item to the PR checklist.", + "get_pr_checklist": "Get the current PR checklist.", + "clear_pr_checklist": "Clear the PR checklist.", + "log_tech_debt": "Log identified technical debt.", + "resolve_tech_debt": "Mark a logged technical debt as resolved.", + "list_tech_debt": "List all unresolved technical debt.", + "save_context_workspace": "Save the current set of pinned files and context.", + "load_context_workspace": "Load a previously saved context workspace.", + "list_context_workspaces": "List all saved context workspaces.", + "omni_search": "Search across all memory sources (graph, tasks, snippets, ADRs, etc.) at once.", + "get_project_health": "Get a synthesized health report of the project based on memory data." +} + +def fix_handlers(filepath): + with open(filepath, "r") as f: + content = f.read() + + for tool_name, description in descriptions.items(): + # Match crate::mcp::tool_def::<...>("tool_name", "") + # Note: sometimes it's on multiple lines for GenerateStandupReportTool etc. + # But most are single line. + pattern = r'(crate::mcp::tool_def::<[^>]+>\(\s*"' + tool_name + r'"\s*,\s*)""(\s*\))' + replacement = r'\1"' + description + r'"\2' + content = re.sub(pattern, replacement, content) + + with open(filepath, "w") as f: + f.write(content) + +fix_handlers("C:\\Users\\reazul.ashraf\\workspace\\rust\\mcp-memory\\server\\src\\handlers.rs") diff --git a/server/src/handlers.rs b/server/src/handlers.rs index bb26789..ad34cb1 100644 --- a/server/src/handlers.rs +++ b/server/src/handlers.rs @@ -39,72 +39,72 @@ impl MemoryHandler { } "tools/list" => { let tools = vec![ - crate::mcp::tool_def::("create_entities", ""), - crate::mcp::tool_def::("create_relations", ""), - crate::mcp::tool_def::("add_observations", ""), - crate::mcp::tool_def::("delete_entities", ""), - crate::mcp::tool_def::("delete_observations", ""), - crate::mcp::tool_def::("delete_relations", ""), - crate::mcp::tool_def::("read_graph", ""), - crate::mcp::tool_def::("search_nodes", ""), - crate::mcp::tool_def::("open_nodes", ""), - crate::mcp::tool_def::("log_code_change", ""), - crate::mcp::tool_def::("query_recent_changes", ""), - crate::mcp::tool_def::("visualize_graph", ""), - crate::mcp::tool_def::("add_sticky_note", ""), - crate::mcp::tool_def::("read_sticky_notes", ""), - crate::mcp::tool_def::("condense_entity", ""), - crate::mcp::tool_def::("add_task", ""), - crate::mcp::tool_def::("update_task_status", ""), - crate::mcp::tool_def::("list_active_tasks", ""), - crate::mcp::tool_def::("store_snippet", ""), - crate::mcp::tool_def::("search_snippets", ""), - crate::mcp::tool_def::("delete_snippet", ""), - crate::mcp::tool_def::("log_decision", ""), - crate::mcp::tool_def::("query_decisions", ""), - crate::mcp::tool_def::("merge_entities", ""), - crate::mcp::tool_def::("find_orphans", ""), - crate::mcp::tool_def::("learn_preference", ""), - crate::mcp::tool_def::("read_preferences", ""), - crate::mcp::tool_def::("log_error_fix", ""), - crate::mcp::tool_def::("search_error_fixes", ""), - crate::mcp::tool_def::("pin_file", ""), - crate::mcp::tool_def::("unpin_file", ""), - crate::mcp::tool_def::("list_pinned_files", ""), - crate::mcp::tool_def::("add_session_summary", ""), - crate::mcp::tool_def::("get_project_timeline", ""), - crate::mcp::tool_def::("leave_handoff_memo", ""), - crate::mcp::tool_def::("read_handoff_memos", ""), - crate::mcp::tool_def::("clear_handoff_memos", ""), - crate::mcp::tool_def::("update_env_fingerprint", ""), - crate::mcp::tool_def::("read_env_fingerprint", ""), - crate::mcp::tool_def::("log_env_requirement", ""), - crate::mcp::tool_def::("add_milestone", ""), - crate::mcp::tool_def::("update_milestone", ""), - crate::mcp::tool_def::("list_milestones", ""), + crate::mcp::tool_def::("create_entities", "Create new entities in the knowledge graph."), + crate::mcp::tool_def::("create_relations", "Create new relations between entities in the knowledge graph."), + crate::mcp::tool_def::("add_observations", "Add new observations to existing entities in the knowledge graph."), + crate::mcp::tool_def::("delete_entities", "Delete entities from the knowledge graph."), + crate::mcp::tool_def::("delete_observations", "Delete observations from existing entities."), + crate::mcp::tool_def::("delete_relations", "Delete relations between entities."), + crate::mcp::tool_def::("read_graph", "Read the entire knowledge graph."), + crate::mcp::tool_def::("search_nodes", "Search for entities in the knowledge graph by name or type."), + crate::mcp::tool_def::("open_nodes", "Open and retrieve full details of specific nodes in the knowledge graph."), + crate::mcp::tool_def::("log_code_change", "Log a significant code change or refactor in the memory system."), + crate::mcp::tool_def::("query_recent_changes", "Query recently logged code changes."), + crate::mcp::tool_def::("visualize_graph", "Generate a visual representation of the knowledge graph."), + crate::mcp::tool_def::("add_sticky_note", "Add a sticky note for unstructured thoughts or reminders."), + crate::mcp::tool_def::("read_sticky_notes", "Read all active sticky notes."), + crate::mcp::tool_def::("condense_entity", "Condense or summarize an entity's observations to reduce size."), + crate::mcp::tool_def::("add_task", "Add a new task to the task tracker."), + crate::mcp::tool_def::("update_task_status", "Update the status of an existing task."), + crate::mcp::tool_def::("list_active_tasks", "List all currently active tasks."), + crate::mcp::tool_def::("store_snippet", "Store a reusable code snippet."), + crate::mcp::tool_def::("search_snippets", "Search through stored code snippets."), + crate::mcp::tool_def::("delete_snippet", "Delete a stored code snippet."), + crate::mcp::tool_def::("log_decision", "Log an architectural decision record (ADR)."), + crate::mcp::tool_def::("query_decisions", "Query architectural decision records."), + crate::mcp::tool_def::("merge_entities", "Merge two entities in the knowledge graph into one."), + crate::mcp::tool_def::("find_orphans", "Find orphaned entities (entities without any relations) in the graph."), + crate::mcp::tool_def::("learn_preference", "Record a user preference or behavior to adapt future interactions."), + crate::mcp::tool_def::("read_preferences", "Read all learned user preferences."), + crate::mcp::tool_def::("log_error_fix", "Log a complex error and its fix for future reference."), + crate::mcp::tool_def::("search_error_fixes", "Search through previously logged error fixes."), + crate::mcp::tool_def::("pin_file", "Pin a file to keep it explicitly in the context workspace."), + crate::mcp::tool_def::("unpin_file", "Unpin a file from the context workspace."), + crate::mcp::tool_def::("list_pinned_files", "List all currently pinned files."), + crate::mcp::tool_def::("add_session_summary", "Add a summary of the current session."), + crate::mcp::tool_def::("get_project_timeline", "Get a timeline of major project events."), + crate::mcp::tool_def::("leave_handoff_memo", "Leave a memo for the next session or agent."), + crate::mcp::tool_def::("read_handoff_memos", "Read pending handoff memos."), + crate::mcp::tool_def::("clear_handoff_memos", "Clear handoff memos after reading."), + crate::mcp::tool_def::("update_env_fingerprint", "Update the environment fingerprint (e.g., OS, tool versions)."), + crate::mcp::tool_def::("read_env_fingerprint", "Read the current environment fingerprint."), + crate::mcp::tool_def::("log_env_requirement", "Log a required tool or package for the environment."), + crate::mcp::tool_def::("add_milestone", "Add a new project milestone."), + crate::mcp::tool_def::("update_milestone", "Update the status of a project milestone."), + crate::mcp::tool_def::("list_milestones", "List all project milestones."), crate::mcp::tool_def::( "generate_standup_report", "", ), - crate::mcp::tool_def::("register_environment", ""), + crate::mcp::tool_def::("register_environment", "Register details about a specific deployment environment."), crate::mcp::tool_def::( "get_environment_details", "", ), - crate::mcp::tool_def::("add_pr_checklist_item", ""), - crate::mcp::tool_def::("get_pr_checklist", ""), - crate::mcp::tool_def::("clear_pr_checklist", ""), - crate::mcp::tool_def::("log_tech_debt", ""), - crate::mcp::tool_def::("resolve_tech_debt", ""), - crate::mcp::tool_def::("list_tech_debt", ""), - crate::mcp::tool_def::("save_context_workspace", ""), - crate::mcp::tool_def::("load_context_workspace", ""), + crate::mcp::tool_def::("add_pr_checklist_item", "Add an item to the PR checklist."), + crate::mcp::tool_def::("get_pr_checklist", "Get the current PR checklist."), + crate::mcp::tool_def::("clear_pr_checklist", "Clear the PR checklist."), + crate::mcp::tool_def::("log_tech_debt", "Log identified technical debt."), + crate::mcp::tool_def::("resolve_tech_debt", "Mark a logged technical debt as resolved."), + crate::mcp::tool_def::("list_tech_debt", "List all unresolved technical debt."), + crate::mcp::tool_def::("save_context_workspace", "Save the current set of pinned files and context."), + crate::mcp::tool_def::("load_context_workspace", "Load a previously saved context workspace."), crate::mcp::tool_def::( "list_context_workspaces", "", ), - crate::mcp::tool_def::("omni_search", ""), - crate::mcp::tool_def::("get_project_health", ""), + crate::mcp::tool_def::("omni_search", "Search across all memory sources (graph, tasks, snippets, ADRs, etc.) at once."), + crate::mcp::tool_def::("get_project_health", "Get a synthesized health report of the project based on memory data."), ]; Some(crate::mcp::success( id,