Skip to content

Commit 73202d1

Browse files
phernandezclaude
andauthored
fix: add tool use doc to write note for using empty string for root folder (#339)
Signed-off-by: phernandez <paul@basicmachines.co> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 795e339 commit 73202d1

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/basic_memory/mcp/tools/write_note.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ async def write_note(
6363
title: The title of the note
6464
content: Markdown content for the note, can include observations and relations
6565
folder: Folder path relative to project root where the file should be saved.
66-
Use forward slashes (/) as separators. Examples: "notes", "projects/2025", "research/ml"
66+
Use forward slashes (/) as separators. Use "/" or "" to write to project root.
67+
Examples: "notes", "projects/2025", "research/ml", "/" (root)
6768
project: Project name to write to. Optional - server will resolve using the
6869
hierarchy above. If unknown, use list_memory_projects() to discover
6970
available projects.
@@ -124,6 +125,10 @@ async def write_note(
124125
# Get and validate the project (supports optional project parameter)
125126
active_project = await get_active_project(client, project, context)
126127

128+
# Normalize "/" to empty string for root folder (must happen before validation)
129+
if folder == "/":
130+
folder = ""
131+
127132
# Validate folder path to prevent path traversal attacks
128133
project_path = active_project.home
129134
if folder and not validate_project_path(folder, project_path):

test-int/mcp/test_write_note_integration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ async def test_write_note_file_path_os_path_join(mcp_server, test_project):
397397
"nested/folder/another-note",
398398
),
399399
("", "Root Note", "root-note.md", "root-note"),
400+
("/", "Root Slash Note", "root-slash-note.md", "root-slash-note"),
400401
(
401402
"folder with spaces",
402403
"Note Title",

0 commit comments

Comments
 (0)