Make basic-memory folder parameter optional for write_note
Currently in basic-memory, the write_note
function requires a folder
parameter, which means notes are always created in subfolders. There’s no option to create notes directly at the root level without specifying a subfolder.
Current Implementation
Looking at the implementation in src/basic_memory/mcp/tools/write_note.py
:
@mcp.tool(
description="Create or update a markdown note. Returns a markdown formatted summary of the semantic content.",
)
async def write_note(
title: str,
content: str,
folder: str, # Required parameter with no default
tags=None,
) -> str:
The folder
parameter is required with no default value, meaning:
- Users must always specify a folder
- Notes are always organized in subfolders
- There’s no built-in way to specify a “root” location
Proposed Solution
Modify the write_note
function to make the folder
parameter optional with a sensible default:
@mcp.tool(
description="Create or update a markdown note. Returns a markdown formatted summary of the semantic content.",
)
async def write_note(
title: str,
content: str,
folder: str = "", # Optional with empty string default for root level
tags=None,
) -> str:
This change would:
- Allow notes to be created at the root level when no folder is specified
- Maintain backward compatibility for existing code that specifies folders
- Provide users with more flexibility in organizing their knowledge base
Implementation Steps
- Update the function signature in
src/basic_memory/mcp/tools/write_note.py
- Update documentation to reflect the optional nature of the folder parameter
- Add tests to verify that notes can be created at the root level
- Ensure any client code (CLI, API, etc.) properly handles the optional parameter
Related Issues
This is related to another issue where basic-memory generates permalinks without trailing slashes, causing Jekyll to create flat files instead of directory structures.