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:

  1. Users must always specify a folder
  2. Notes are always organized in subfolders
  3. 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:

  1. Allow notes to be created at the root level when no folder is specified
  2. Maintain backward compatibility for existing code that specifies folders
  3. Provide users with more flexibility in organizing their knowledge base

Implementation Steps

  1. Update the function signature in src/basic_memory/mcp/tools/write_note.py
  2. Update documentation to reflect the optional nature of the folder parameter
  3. Add tests to verify that notes can be created at the root level
  4. Ensure any client code (CLI, API, etc.) properly handles the optional parameter

This is related to another issue where basic-memory generates permalinks without trailing slashes, causing Jekyll to create flat files instead of directory structures.

#AI #AITools #BasicMemory