Skip to content

Self-hosted AI workspace.

Python

fix: rag remove_directory expands ~ so it matches the indexed path (#1305)

Afonso Coutinho094f8198e5f4
diff --git a/mcp_servers/rag_server.py b/mcp_servers/rag_server.py
index 2d50b4b4f..1afd7fce9 100644
--- a/mcp_servers/rag_server.py
+++ b/mcp_servers/rag_server.py
@@ -120,6 +120,9 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
directory = arguments.get("directory", "").strip()
if not directory:
return [TextContent(type="text", text="Error: remove_directory needs a directory path")]
+ # Expand ~ to match add_directory, which indexes the expanded path.
+ # Without this, removing "~/docs" never matches the stored absolute path.
+ directory = os.path.expanduser(directory)
if not _personal_docs_manager:
return [TextContent(type="text", text="Error: Personal docs manager not available")]
try: