Skip to content

Commit e5e733d

Browse files
github-actions[bot]claudephernandez
committed
fix: Rename write_note entity_type parameter to note_type for clarity
Resolves inconsistency between write_note's entity_type parameter and search_notes's entity_types parameter. The write_note parameter sets the frontmatter type field (note, guide, person, etc.), while search_notes's entity_types filters by Entity/Observation/Relation types. Renaming to note_type makes it clear this parameter sets the note's type in frontmatter, not the database entity type. Changes: - Renamed entity_type → note_type in write_note MCP tool - Updated parameter documentation with clearer description - Updated all examples in AI assistant guide - Updated all test cases - Internal Entity schema field remains entity_type (no breaking change) Fixes #403 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
1 parent a7d7cc5 commit e5e733d

3 files changed

Lines changed: 23 additions & 22 deletions

File tree

docs/ai-assistant-guide-extended.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ Adopt GraphQL instead of REST for our API layer.
576576
""",
577577
folder="decisions",
578578
tags=["decision", "api", "graphql"],
579-
entity_type="decision",
579+
note_type="decision",
580580
project="main"
581581
)
582582
```
@@ -613,7 +613,7 @@ await write_note(
613613
""",
614614
folder="meetings",
615615
tags=["meeting", "api", "team"],
616-
entity_type="meeting",
616+
note_type="meeting",
617617
project="main"
618618
)
619619
```
@@ -665,7 +665,7 @@ Specification for user authentication system using JWT tokens.
665665
""",
666666
folder="specs",
667667
tags=["spec", "auth", "security"],
668-
entity_type="spec",
668+
note_type="spec",
669669
project="main"
670670
)
671671
```
@@ -1631,7 +1631,7 @@ await write_note(
16311631
{related_entities}
16321632
""",
16331633
folder="decisions",
1634-
entity_type="decision",
1634+
note_type="decision",
16351635
project="main"
16361636
)
16371637
```
@@ -2706,14 +2706,14 @@ await write_note(
27062706

27072707
### Content Management
27082708

2709-
**write_note(title, content, folder, tags, entity_type, project)**
2709+
**write_note(title, content, folder, tags, note_type, project)**
27102710
- Create or update markdown notes
27112711
- Parameters:
27122712
- `title` (required): Note title
27132713
- `content` (required): Markdown content
27142714
- `folder` (required): Destination folder
27152715
- `tags` (optional): List of tags
2716-
- `entity_type` (optional): Entity type (note, person, meeting, etc.)
2716+
- `note_type` (optional): Type of note (stored in frontmatter). Can be "note", "person", "meeting", "guide", etc.
27172717
- `project` (required unless default_project_mode): Target project
27182718
- Returns: Created/updated entity with permalink
27192719
- Example:
@@ -2723,7 +2723,7 @@ await write_note(
27232723
content="# API Design\n...",
27242724
folder="specs",
27252725
tags=["api", "design"],
2726-
entity_type="spec",
2726+
note_type="spec",
27272727
project="main"
27282728
)
27292729
```

src/basic_memory/mcp/tools/write_note.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def write_note(
2929
folder: str,
3030
project: Optional[str] = None,
3131
tags=None,
32-
entity_type: str = "note",
32+
note_type: str = "note",
3333
context: Context | None = None,
3434
) -> str:
3535
"""Write a markdown note to the knowledge base.
@@ -70,7 +70,8 @@ async def write_note(
7070
available projects.
7171
tags: Tags to categorize the note. Can be a list of strings, a comma-separated string, or None.
7272
Note: If passing from external MCP clients, use a string format (e.g. "tag1,tag2,tag3")
73-
entity_type: Type of entity to create. Defaults to "note". Can be "guide", "report", "config", etc.
73+
note_type: Type of note to create (stored in frontmatter). Defaults to "note".
74+
Can be "guide", "report", "config", "person", etc.
7475
context: Optional FastMCP context for performance caching.
7576
7677
Returns:
@@ -96,14 +97,14 @@ async def write_note(
9697
content="# Weekly Standup\\n\\n- [decision] Use SQLite for storage #tech"
9798
)
9899
99-
# Create a note with tags and entity type
100+
# Create a note with tags and note type
100101
write_note(
101102
project="work-project",
102103
title="API Design",
103104
folder="specs",
104105
content="# REST API Specification\\n\\n- implements [[Authentication]]",
105106
tags=["api", "design"],
106-
entity_type="guide"
107+
note_type="guide"
107108
)
108109
109110
# Update existing note (same title/folder)
@@ -147,7 +148,7 @@ async def write_note(
147148
entity = Entity(
148149
title=title,
149150
folder=folder,
150-
entity_type=entity_type,
151+
entity_type=note_type,
151152
content_type="text/markdown",
152153
content=content,
153154
entity_metadata=metadata,

tests/mcp/test_tool_write_note.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ async def test_write_note_with_custom_entity_type(app, test_project):
538538
folder="guides",
539539
content="# Guide Content\nThis is a guide",
540540
tags=["guide", "documentation"],
541-
entity_type="guide",
541+
note_type="guide",
542542
)
543543

544544
assert result
@@ -574,14 +574,14 @@ async def test_write_note_with_custom_entity_type(app, test_project):
574574

575575
@pytest.mark.asyncio
576576
async def test_write_note_with_report_entity_type(app, test_project):
577-
"""Test creating a note with entity_type="report"."""
577+
"""Test creating a note with note_type="report"."""
578578
result = await write_note.fn(
579579
project=test_project.name,
580580
title="Monthly Report",
581581
folder="reports",
582582
content="# Monthly Report\nThis is a monthly report",
583583
tags=["report", "monthly"],
584-
entity_type="report",
584+
note_type="report",
585585
)
586586

587587
assert result
@@ -599,13 +599,13 @@ async def test_write_note_with_report_entity_type(app, test_project):
599599

600600
@pytest.mark.asyncio
601601
async def test_write_note_with_config_entity_type(app, test_project):
602-
"""Test creating a note with entity_type="config"."""
602+
"""Test creating a note with note_type="config"."""
603603
result = await write_note.fn(
604604
project=test_project.name,
605605
title="System Config",
606606
folder="config",
607607
content="# System Configuration\nThis is a config file",
608-
entity_type="config",
608+
note_type="config",
609609
)
610610

611611
assert result
@@ -659,21 +659,21 @@ async def test_write_note_update_existing_with_different_entity_type(app, test_p
659659
folder="test",
660660
content="# Initial Content\nThis starts as a note",
661661
tags=["test"],
662-
entity_type="note",
662+
note_type="note",
663663
)
664664

665665
assert result1
666666
assert "# Created note" in result1
667667
assert f"project: {test_project.name}" in result1
668668

669-
# Update the same note with a different entity_type
669+
# Update the same note with a different note_type
670670
result2 = await write_note.fn(
671671
project=test_project.name,
672672
title="Changeable Type",
673673
folder="test",
674674
content="# Updated Content\nThis is now a guide",
675675
tags=["guide"],
676-
entity_type="guide",
676+
note_type="guide",
677677
)
678678

679679
assert result2
@@ -976,7 +976,7 @@ async def test_write_note_security_with_all_parameters(self, app, test_project):
976976
folder="../../../etc/malicious",
977977
content="# Malicious Content\nThis should be blocked by security validation.",
978978
tags=["malicious", "test"],
979-
entity_type="guide",
979+
note_type="guide",
980980
)
981981

982982
assert isinstance(result, str)
@@ -1026,7 +1026,7 @@ async def test_write_note_preserves_functionality_with_security(self, app, test_
10261026
Additional content with various formatting.
10271027
""").strip(),
10281028
tags=["security", "test", "full-feature"],
1029-
entity_type="guide",
1029+
note_type="guide",
10301030
)
10311031

10321032
# Should succeed normally

0 commit comments

Comments
 (0)