Skip to content

Commit 56d1223

Browse files
phernandezclaude
andcommitted
fix: allow "/" as folder path for project root in write_note
Users reported that folder="/" doesn't work for writing to project root. The validate_project_path() function was blocking "/" before sanitization. Changes: - Normalize "/" to "" before path validation in write_note tool - Update documentation to show both "/" and "" work for root - Add test case verifying "/" works as root folder path 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent eb6dc89 commit 56d1223

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/basic_memory/mcp/tools/write_note.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +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. Use empty string ("") to write to project root.
67-
Examples: "notes", "projects/2025", "research/ml", "" (root)
66+
Use forward slashes (/) as separators. Use "/" or "" to write to project root.
67+
Examples: "notes", "projects/2025", "research/ml", "/" (root)
6868
project: Project name to write to. Optional - server will resolve using the
6969
hierarchy above. If unknown, use list_memory_projects() to discover
7070
available projects.
@@ -125,6 +125,10 @@ async def write_note(
125125
# Get and validate the project (supports optional project parameter)
126126
active_project = await get_active_project(client, project, context)
127127

128+
# Normalize "/" to empty string for root folder (must happen before validation)
129+
if folder == "/":
130+
folder = ""
131+
128132
# Validate folder path to prevent path traversal attacks
129133
project_path = active_project.home
130134
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)