Compare commits

...

1 Commits

Author SHA1 Message Date
claude[bot] fa594a0d29 feat: Add downloadable Basic Memory tool reference project
Create a comprehensive Basic Memory knowledge graph project that users can
download and import to explore MCP tool documentation.

Features:
- Complete project structure with frontmatter, observations, and relations
- 4 detailed tool reference files (write_note, read_note, search_notes, build_context)
- 2 category guides (Content Management, Search & Discovery)
- Main index file connecting all entities
- Comprehensive README with usage instructions
- Python script to generate additional tools

Structure follows Basic Memory format:
- YAML frontmatter with title, type, permalink, tags
- Observations with [category] syntax
- Relations using [[Entity]] wikilinks
- Knowledge graph connections between tools

Users can:
1. Import into existing projects
2. Create new dedicated tool-reference project
3. Browse in any markdown editor
4. Navigate via search_notes, build_context, read_note
5. Use as template for LLM instructions

Resolves #404

Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
2025-10-28 00:30:50 +00:00
9 changed files with 2069 additions and 0 deletions
+146
View File
@@ -0,0 +1,146 @@
# Basic Memory MCP Tool Reference Project
A downloadable Basic Memory project containing comprehensive documentation for all MCP tools.
## What This Is
This is a complete Basic Memory project that you can import into your own Basic Memory installation.
It provides detailed reference documentation for all 16 core MCP tools, organized as a knowledge graph
that you can navigate and search using Basic Memory's tools.
## How to Use
### Option 1: Import into Existing Project
1. Copy the contents of this directory into your Basic Memory project
2. Run `basic-memory sync` to index the new content
3. Use `search_notes` or `build_context` to explore the documentation
### Option 2: Create New Project
1. Create a new Basic Memory project:
```bash
basic-memory tools create-memory-project \
--project-name "tool-reference" \
--project-path "~/basic-memory-tool-reference"
```
2. Copy these files into the new project directory
3. Sync the project:
```bash
basic-memory sync
```
### Option 3: Browse in Your Editor
The files are standard markdown with Basic Memory frontmatter.
You can browse them in any markdown editor or Obsidian.
## Project Structure
```
tool-reference/
├── README.md (this file)
├── index.md (main reference guide)
├── tools/
│ ├── write_note.md
│ ├── read_note.md
│ ├── search_notes.md
│ └── ... (all 16 tools)
└── categories/
├── content-management.md
├── knowledge-graph-navigation.md
├── search-and-discovery.md
├── project-management.md
└── visualization.md
```
## Using the Documentation
### Search for Tools
```python
# Find all content management tools
search_notes("content management", search_type="text")
# Find write_note examples
search_notes("write_note")
```
### Navigate by Category
```python
# Read a category overview
read_note("content-management")
# Build context around search tools
build_context("memory://categories/search-and-discovery")
```
### View Tool Details
```python
# Read specific tool documentation
read_note("tools/write_note")
read_note("tools/search_notes")
# View as artifact for better formatting
view_note("tools/build_context")
```
## What's Included
- **16 tool reference documents** with detailed examples
- **5 category guides** organizing tools by function
- **Knowledge graph relations** connecting related tools
- **Copy-paste examples** ready for LLM instructions
- **Search syntax guide** for advanced queries
- **Real-world workflows** showing tool combinations
## Tool Categories
### Content Management
- `write_note`: Create or update markdown notes with semantic observations and relations
- `read_note`: Read markdown notes by title, permalink, or memory:// URL
- `read_content`: Read raw file content (text, images, binaries) without knowledge graph processing
- `view_note`: View notes as formatted artifacts for better readability
- `edit_note`: Edit notes incrementally with append, prepend, find/replace, replace_section
- `move_note`: Move notes to new locations, updating database and maintaining links
- `delete_note`: Delete notes from the knowledge base
### Knowledge Graph Navigation
- `build_context`: Navigate knowledge graph via memory:// URLs for conversation continuity
- `recent_activity`: Get recently updated information with specified timeframe
- `list_directory`: Browse directory contents with filtering and depth control
### Search & Discovery
- `search_notes`: Full-text search with advanced filtering and boolean operators
### Project Management
- `list_memory_projects`: List all available projects with their status
- `create_memory_project`: Create new Basic Memory projects
- `delete_project`: Delete a project from configuration
- `get_current_project`: Get current project information and stats
- `sync_status`: Check file synchronization and background operation status
### Visualization
- `canvas`: Generate Obsidian canvas files for knowledge graph visualization
## Generated Documentation
This project was automatically generated from the Basic Memory MCP tool source code.
You can regenerate it by running:
```bash
python scripts/generate_tool_reference_project.py
```
## License
Same as Basic Memory - AGPL v3
@@ -0,0 +1,221 @@
---
title: Content Management
type: guide
permalink: categories/content-management
tags:
- mcp-tools
- reference
- category
- content-management
created: 2025-10-28T00:00:00
modified: 2025-10-28T00:00:00
---
# Content Management
Tools for creating, reading, editing, and managing markdown notes in Basic Memory.
## Overview
The Content Management category contains 7 core MCP tools that handle all aspects of note lifecycle:
creating, reading, viewing, editing, moving, and deleting notes. These tools work with Basic Memory's
knowledge graph format, supporting observations, relations, and semantic content.
## Observations
- [category] Contains 7 MCP tools #mcp #tools
- [purpose] Content Management functionality for Basic Memory #functionality
- [feature] All tools support project resolution (Single Project → parameter → default) #project-resolution
- [feature] All tools validate paths to prevent security issues #security
- [design] Tools use consistent markdown format with frontmatter, observations, and relations #format
## Tools in This Category
### write_note
Create or update markdown notes with semantic observations and relations.
**Key Features:**
- Supports YAML frontmatter
- Observations with `[category]` syntax
- Relations using `[[Entity]]` wikilinks
- Tags for categorization
- Custom entity types
- Security: validates folder paths
**Use When:**
- Creating new notes
- Updating existing notes
- Building knowledge graph entries
### read_note
Read markdown notes by title, permalink, or memory:// URL.
**Key Features:**
- Multiple lookup strategies (permalink → title → text search)
- Returns full markdown content
- Pagination support
- Helpful error messages when not found
**Use When:**
- Reading specific notes
- Retrieving content for processing
- Loading context for conversations
### read_content
Read raw file content without knowledge graph processing.
**Key Features:**
- Reads any file type (text, images, binaries)
- Returns raw content or base64 encoding
- No parsing or processing
- Direct file access
**Use When:**
- Reading non-markdown files
- Accessing images or binaries
- Need raw content without processing
### view_note
View notes as formatted artifacts for better readability.
**Key Features:**
- Formats notes as artifacts
- Better visual presentation
- Same lookup as read_note
- Pagination support
**Use When:**
- Presenting notes to users
- Better readability needed
- Viewing long-form content
### edit_note
Edit notes incrementally with various operations.
**Key Features:**
- Append content to end
- Prepend content to beginning
- Find and replace text
- Replace specific sections
- Maintains existing structure
**Use When:**
- Adding to existing notes
- Updating specific sections
- Find/replace operations
- Incremental edits
### move_note
Move notes to new locations while maintaining links.
**Key Features:**
- Updates file system
- Updates database
- Maintains relations
- Updates permalinks
**Use When:**
- Reorganizing content
- Moving between folders
- Renaming notes
### delete_note
Delete notes from the knowledge base.
**Key Features:**
- Removes from file system
- Removes from database
- Cleans up relations
- Confirmation required
**Use When:**
- Removing outdated content
- Cleaning up test notes
- Content no longer needed
## Common Workflows
### Create and Edit Workflow
```python
# 1. Create initial note
write_note(
project="my-project",
title="New Feature",
folder="features",
content="# New Feature\\n\\nInitial draft..."
)
# 2. Add more content
edit_note(
"my-project",
"features/new-feature",
operation="append",
content="\\n## Implementation\\n\\nDetails..."
)
# 3. Read to verify
read_note("my-project", "features/new-feature")
```
### Read and Move Workflow
```python
# 1. Read current note
content = read_note("my-project", "drafts/note")
# 2. Move to published
move_note(
"my-project",
"drafts/note",
"published/note"
)
# 3. Verify new location
read_note("my-project", "published/note")
```
### Content Organization Workflow
```python
# 1. Create in temporary location
write_note(
project="research",
title="Quick Note",
folder="temp",
content="Quick thoughts..."
)
# 2. Refine content
edit_note(
"research",
"temp/quick-note",
operation="replace_section",
content="Quick thoughts...|# Refined Thoughts\\n\\nPolished version..."
)
# 3. Move to permanent location
move_note(
"research",
"temp/quick-note",
"concepts/refined-thoughts"
)
```
## Relations
- contains [[Write Note]]
- contains [[Read Note]]
- contains [[Read Content]]
- contains [[View Note]]
- contains [[Edit Note]]
- contains [[Move Note]]
- contains [[Delete Note]]
- part_of [[MCP Tool Reference]]
@@ -0,0 +1,250 @@
---
title: Search & Discovery
type: guide
permalink: categories/search-and-discovery
tags:
- mcp-tools
- reference
- category
- search
created: 2025-10-28T00:00:00
modified: 2025-10-28T00:00:00
---
# Search & Discovery
Full-text search capabilities with advanced syntax support for discovering content in your knowledge base.
## Overview
The Search & Discovery category focuses on finding content across your entire knowledge base.
The primary tool, `search_notes`, provides powerful full-text search with boolean operators,
phrase matching, filtering, and pattern matching.
## Observations
- [category] Contains 1 core MCP tool (search_notes) #mcp #tools
- [purpose] Search & Discovery functionality for Basic Memory #functionality
- [feature] Full-text search with FTS5 engine #search-engine
- [feature] Boolean operators (AND, OR, NOT) #advanced-search
- [feature] Phrase matching with quotes #search-syntax
- [feature] Content filtering (types, entity_types, after_date) #filtering
- [feature] Pattern matching on permalinks #pattern-matching
- [feature] Helpful error messages with suggestions #ux
## Tools in This Category
### search_notes
Full-text search across all content with advanced filtering and boolean operators.
**Search Types:**
- **Text search** (default): Full-text search across all content
- **Title search**: Search only in note titles
- **Permalink search**: Pattern matching on file paths
**Boolean Operators:**
- `AND`: Both terms must be present
- `OR`: Either term can be present
- `NOT`: Exclude specific terms
- Grouping with `()`
**Filtering Options:**
- `types`: Filter by note types (e.g., ["note", "person"])
- `entity_types`: Filter by entity types (e.g., ["observation"])
- `after_date`: Show only recent content
**Content-Specific Searches:**
- `tag:example`: Search within tags
- `category:observation`: Filter by category
- `author:username`: Search by author (if metadata available)
## Search Syntax Guide
### Basic Text Search
```python
# Simple keyword
search_notes("machine learning")
# Multiple keywords (implicit AND)
search_notes("python programming tutorial")
```
### Boolean Operators
```python
# Explicit AND
search_notes("machine AND learning")
# OR operator
search_notes("python OR javascript")
# NOT operator
search_notes("programming NOT beginner")
# Complex boolean
search_notes("(python OR javascript) AND tutorial NOT beginner")
```
### Phrase Search
```python
# Exact phrase
search_notes('"machine learning basics"')
# Phrase with boolean
search_notes('"neural networks" AND python')
```
### Search Types
```python
# Full-text (default)
search_notes("keyword", search_type="text")
# Title only
search_notes("Tutorial", search_type="title")
# Permalink patterns
search_notes("docs/2024-*", search_type="permalink")
search_notes("meetings/weekly-*", search_type="permalink")
```
### Filtering
```python
# By content type
search_notes("meeting", types=["entity"])
# By entity type
search_notes("decision", entity_types=["observation"])
# By date
search_notes("update", after_date="1 week")
search_notes("report", after_date="2024-01-01")
# Multiple filters
search_notes(
"bug OR issue",
types=["entity"],
entity_types=["observation"],
after_date="1 week"
)
```
### Content-Specific
```python
# Tag search
search_notes("tag:api")
search_notes("tag:urgent OR tag:important")
# Category search
search_notes("category:decision")
search_notes("category:observation AND tech")
```
## Common Search Patterns
### Find Recent Work
```python
# All recent updates
search_notes("", after_date="1 week")
# Recent on specific topic
search_notes("machine learning", after_date="3d")
```
### Topic Exploration
```python
# Broad topic
search_notes("artificial intelligence")
# Narrow focus
search_notes("artificial intelligence AND ethics")
# Exclude basics
search_notes("AI NOT basics NOT introduction")
```
### Project Management
```python
# Open bugs
search_notes("bug NOT fixed NOT resolved")
# Recent decisions
search_notes("category:decision", after_date="1 week")
# Meeting notes
search_notes("meeting OR standup", search_type="title")
```
### Research Workflows
```python
# Literature review
search_notes('"literature review" OR paper OR study')
# Research by topic
search_notes("(neural networks OR deep learning) AND research")
# Recent research
search_notes("research", after_date="1 month")
```
## Error Handling
`search_notes` provides helpful error messages for:
### Syntax Errors
If query has invalid syntax, get suggestions like:
- Simplify the query
- Remove special characters
- Use basic boolean operators
- Example corrections
### No Results
If no results found, get guidance on:
- Broadening the search
- Trying variations
- Different search types
- Using filters
- Exploring what exists
### Other Errors
- Project not found
- Server errors
- Permission errors
Each error includes specific next steps.
## Comparison with Related Tools
### search_notes vs read_note
- **search_notes**: Find notes you don't know exist
- **read_note**: Retrieve specific known notes
### search_notes vs recent_activity
- **search_notes**: Find by content/keywords
- **recent_activity**: Find by modification time
### search_notes vs build_context
- **search_notes**: Keyword-based discovery
- **build_context**: Graph-based navigation
## Relations
- contains [[Search Notes]]
- part_of [[MCP Tool Reference]]
- complements [[Knowledge Graph Navigation]]
- uses [[FTS5 Search Engine]]
+53
View File
@@ -0,0 +1,53 @@
---
title: MCP Tool Reference
type: guide
permalink: index
tags:
- mcp-tools
- reference
- index
created: 2025-10-28T00:00:00
modified: 2025-10-28T00:00:00
---
# MCP Tool Reference
Comprehensive reference for all Basic Memory MCP tools with examples and usage patterns.
## Overview
This project contains detailed documentation for all 16 core MCP tools in Basic Memory.
Each tool is documented as a separate entity with examples, parameters, and relationships.
## Observations
- [structure] Contains 16 tool reference documents #documentation
- [structure] Organized into 5 categories #organization
- [purpose] Provides copy-paste examples for LLM instructions #usage
- [format] Follows Basic Memory knowledge graph format #compliance
## Tool Categories
### Content Management
See [[Content Management]] for all tools in this category.
### Knowledge Graph Navigation
See [[Knowledge Graph Navigation]] for all tools in this category.
### Search & Discovery
See [[Search & Discovery]] for all tools in this category.
### Project Management
See [[Project Management]] for all tools in this category.
### Visualization
See [[Visualization]] for all tools in this category.
## Relations
- contains [[Content Management]]
- contains [[Knowledge Graph Navigation]]
- contains [[Search & Discovery]]
- contains [[Project Management]]
- contains [[Visualization]]
- documented_in [[Basic Memory Documentation]]
@@ -0,0 +1,196 @@
---
title: Build Context
type: guide
permalink: tools/build_context
tags:
- mcp-tools
- reference
- build_context
- context
- knowledge-graph
created: 2025-10-28T00:00:00
modified: 2025-10-28T00:00:00
---
# Build Context
Navigate the knowledge graph via memory:// URLs to build context for conversation continuity.
## Function Signature
```python
build_context(url, depth=1, timeframe=None, project=None)
```
## Parameters
- **url** (str): memory:// URL to start context building from
- **depth** (int): How many relation levels to follow (default 1)
- **timeframe** (str, optional): Filter by recency (e.g., "1w", "2d", "2024-01-01")
- **project** (str, optional): Project name to use
## Returns
Contextual information from knowledge graph traversal including:
- Starting entity content
- Related entities (based on depth)
- Temporal filtering if timeframe specified
## Observations
- [tool] MCP tool for navigating knowledge graph via memory:// URLs #mcp #navigation
- [returns] Contextual information from knowledge graph traversal #output
- [category] Knowledge Graph Navigation tool #classification
- [feature] Follows relations to specified depth #graph-traversal
- [feature] Filters by timeframe for recent context #temporal-filter
- [purpose] Enables conversation continuity across sessions #continuity
## Usage Examples
### Basic Context Building
```python
# Build context from a starting point
build_context("memory://projects/current-project")
# Build context from a specific note
build_context("memory://meetings/weekly-standup")
```
### With Depth Control
```python
# Follow relations to depth of 2
build_context("memory://concepts/machine-learning", depth=2)
# Shallow context (depth=1, default)
build_context("memory://notes/today")
# Deep context traversal
build_context("memory://projects/main", depth=3)
```
### With Timeframe Filter
```python
# Recent context from last week
build_context("memory://meetings/weekly", timeframe="1w")
# Context from last 2 days
build_context("memory://projects/current", timeframe="2d")
# Context since specific date
build_context("memory://research/ml", timeframe="2024-01-01")
```
### For Conversation Continuity
```python
# Load previous conversation context
build_context("memory://conversations/project-discussion", depth=3)
# Continue research topic
build_context("memory://research/literature-review", depth=2, timeframe="1w")
```
### Combining Parameters
```python
# Deep, recent context
build_context(
"memory://projects/active",
depth=3,
timeframe="1w"
)
# Focused context for specific topic
build_context(
"memory://concepts/neural-networks",
depth=2,
timeframe="2024-01-01"
)
```
## How It Works
1. **Starts at URL**: Loads the entity at the memory:// URL
2. **Follows Relations**: Traverses relations up to specified depth
3. **Filters by Time**: If timeframe specified, includes only recent updates
4. **Returns Context**: Aggregates all discovered content
### Depth Example
With depth=1:
```
Start → Related1
→ Related2
→ Related3
```
With depth=2:
```
Start → Related1 → SubRelated1
→ SubRelated2
→ Related2 → SubRelated3
→ Related3 → SubRelated4
```
## Use Cases
### Continue Previous Conversations
```python
# Pick up where you left off
build_context("memory://conversations/last-discussion", depth=2)
```
### Research Topic with Context
```python
# Load all related research
build_context("memory://research/machine-learning", depth=3)
```
### Project Status Update
```python
# Get current project state
build_context("memory://projects/current", depth=2, timeframe="1w")
```
### Explore Related Concepts
```python
# Discover connections
build_context("memory://concepts/neural-networks", depth=2)
```
## memory:// URL Format
Memory URLs follow this pattern:
```
memory://[folder/]permalink
```
Examples:
- `memory://index`
- `memory://meetings/weekly-standup`
- `memory://projects/2024/q1-planning`
- `memory://concepts/machine-learning`
## Project Resolution
Server resolves projects in this order:
1. Single Project Mode
2. project parameter
3. default project
If project unknown, use `list_memory_projects()` or `recent_activity()` first.
## Relations
- part_of [[Knowledge Graph Navigation]]
- documented_in [[MCP Tool Reference]]
- complements [[Recent Activity]]
- complements [[Search Notes]]
- uses [[Relation Resolver]]
+136
View File
@@ -0,0 +1,136 @@
---
title: Read Note
type: guide
permalink: tools/read_note
tags:
- mcp-tools
- reference
- read_note
created: 2025-10-28T00:00:00
modified: 2025-10-28T00:00:00
---
# Read Note
Read markdown notes by title, permalink, or memory:// URL with automatic fallback search.
## Function Signature
```python
read_note(identifier, project=None, page=1, page_size=10)
```
## Parameters
- **identifier** (str): Title, permalink, or memory:// URL of the note to read
- **project** (str, optional): Project name to read from
- **page** (int): Page number for paginated results (default 1)
- **page_size** (int): Number of items per page (default 10)
## Returns
Full markdown content of the note if found, or helpful guidance if not found.
Content includes frontmatter, observations, relations, and all markdown formatting.
## Observations
- [tool] MCP tool for reading markdown notes by title, permalink, or memory:// URL #mcp #read
- [returns] Full markdown content with frontmatter and formatting #output
- [category] Content Management tool #classification
- [feature] Multiple lookup strategies (permalink → title → text search) #smart-lookup
- [feature] Provides helpful suggestions when note not found #ux
- [feature] Validates identifiers to prevent path traversal #security
## Lookup Strategies
The tool tries multiple strategies to find the note:
1. **Direct permalink lookup** (fastest)
2. **Title search fallback** (if permalink fails)
3. **Text search** as last resort
This makes it flexible - you can use any identifier type.
## Usage Examples
### Read by Permalink
```python
# Direct permalink lookup (fastest)
read_note("my-research", "specs/search-spec")
read_note("work-project", "meetings/weekly-standup")
```
### Read by Title
```python
# Title search with automatic fallback
read_note("work-project", "Search Specification")
read_note("team-docs", "Weekly Standup")
```
### Read with Memory URL
```python
# Using memory:// protocol
read_note("my-research", "memory://specs/search-spec")
read_note("work-project", "memory://meetings/weekly")
```
### With Pagination
```python
# Large notes with pagination
read_note("work-project", "Project Updates", page=2, page_size=5)
```
## Not Found Handling
If the note isn't found, the tool provides helpful suggestions:
- Checks if identifier is title vs permalink
- Suggests using search instead
- Recommends checking recent activity
- Provides template for creating new note
Example error response:
```markdown
# Note Not Found in my-research: "search-spec"
I couldn't find any notes matching "search-spec". Here are some suggestions:
## Check Identifier Type
- If you provided a title, try using the exact permalink instead
- If you provided a permalink, check for typos or try a broader search
## Search Instead
Try searching for related content:
search_notes(project="my-research", query="search-spec")
## Create New Note
This might be a good opportunity to create a new note on this topic...
```
## Security
- Validates identifiers to prevent path traversal attacks
- Paths must stay within project boundaries
- Both raw and processed paths are validated
## Project Resolution
Server resolves projects in this order:
1. Single Project Mode
2. project parameter
3. default project
If project unknown, use `list_memory_projects()` or `recent_activity()` first.
## Relations
- part_of [[Content Management]]
- documented_in [[MCP Tool Reference]]
- complements [[Write Note]]
- alternative [[View Note]]
- uses [[Search Notes]] (for fallback lookup)
@@ -0,0 +1,225 @@
---
title: Search Notes
type: guide
permalink: tools/search_notes
tags:
- mcp-tools
- reference
- search_notes
- search
created: 2025-10-28T00:00:00
modified: 2025-10-28T00:00:00
---
# Search Notes
Full-text search across all content with advanced syntax support including boolean operators, phrase matching, and filtering.
## Function Signature
```python
search_notes(query, project=None, page=1, page_size=10, search_type="text",
types=None, entity_types=None, after_date=None)
```
## Parameters
- **query** (str): Search query string (supports boolean operators, phrases, patterns)
- **project** (str, optional): Project name to search in
- **page** (int): Page number of results (default 1)
- **page_size** (int): Number of results per page (default 10)
- **search_type** (str): Type of search - "text", "title", or "permalink" (default "text")
- **types** (list, optional): Filter by note types (e.g., ["note", "person"])
- **entity_types** (list, optional): Filter by entity types (e.g., ["entity", "observation"])
- **after_date** (str, optional): Filter recent content (e.g., "1 week", "2d", "2024-01-01")
## Returns
SearchResponse with results and pagination info, or helpful error guidance if search fails.
## Observations
- [tool] MCP tool for full-text search with advanced filtering and boolean operators #mcp #search
- [returns] SearchResponse with paginated results #output
- [category] Search & Discovery tool #classification
- [feature] Supports boolean AND, OR, NOT operators #search-syntax
- [feature] Supports exact phrase matching with quotes #search-syntax
- [feature] Supports content-specific searches (tag:, category:, etc.) #advanced-search
- [feature] Supports pattern matching on permalinks #permalink-search
- [feature] Provides helpful error messages with suggestions #ux
## Search Syntax Guide
### Basic Searches
```python
# Simple keyword search
search_notes("project planning")
# Multiple terms (implicit AND)
search_notes("machine learning python")
```
### Boolean Operators
```python
# AND search (both terms required)
search_notes("project AND planning")
# OR search (either term)
search_notes("project OR meeting")
# NOT search (exclude term)
search_notes("project NOT archived")
# Complex boolean with grouping
search_notes("(project OR planning) AND notes")
```
### Phrase Search
```python
# Exact phrase match
search_notes('"weekly standup meeting"')
# Combine phrase and keyword
search_notes('"exact phrase" AND keyword')
```
### Search Types
```python
# Full-text search (default)
search_notes("keyword", search_type="text")
# Title-only search
search_notes("Machine Learning", search_type="title")
# Permalink pattern matching
search_notes("docs/meeting-*", search_type="permalink")
search_notes("archive/2024-*", search_type="permalink")
```
### Filtering Options
```python
# Filter by content type
search_notes("meeting notes", types=["entity"])
# Filter by entity type
search_notes("meeting notes", entity_types=["observation"])
# Recent content only
search_notes("bug report", after_date="1 week")
search_notes("updates", after_date="2024-01-01")
# Multiple filters combined
search_notes(
"(bug OR issue) AND NOT resolved",
types=["entity"],
after_date="2024-01-01"
)
```
### Content-Specific Searches
```python
# Search within tags
search_notes("tag:example")
# Filter by category
search_notes("category:observation")
# Search by author (if metadata available)
search_notes("author:username")
```
### Advanced Patterns
```python
# Complex boolean logic
search_notes("project AND (meeting OR discussion)")
# Exclude specific terms
search_notes("bug NOT fixed")
# Year-based permalink search
search_notes("docs/2024-*", search_type="permalink")
# Combine multiple search techniques
search_notes(
'("weekly meeting" OR standup) AND notes NOT archived',
types=["entity"],
after_date="1 week"
)
```
## Common Use Cases
### Find Recent Updates
```python
# Updates from last week
search_notes("", after_date="1 week")
# Specific topic, recent only
search_notes("machine learning", after_date="3d")
```
### Search by Topic
```python
# Find all machine learning content
search_notes("machine learning")
# Find ML content excluding basics
search_notes("machine learning NOT basics")
```
### Search Within Categories
```python
# Find all decisions
search_notes("category:decision")
# Find technical decisions
search_notes("category:decision AND tech")
```
### Explore Tags
```python
# All content with specific tag
search_notes("tag:api")
# Multiple tag search
search_notes("tag:api OR tag:design")
```
## Error Handling
The tool provides helpful error messages and suggestions for:
- Invalid syntax errors
- No results found
- Project not found
- Server errors
- Permission/access errors
Each error includes specific suggestions for how to fix the issue.
## Project Resolution
Server resolves projects in this order:
1. Single Project Mode
2. project parameter
3. default project
If project unknown, use `list_memory_projects()` or `recent_activity()` first.
## Relations
- part_of [[Search & Discovery]]
- documented_in [[MCP Tool Reference]]
- complements [[Recent Activity]]
- complements [[Build Context]]
- uses [[FTS5 Search Engine]]
+151
View File
@@ -0,0 +1,151 @@
---
title: Write Note
type: guide
permalink: tools/write_note
tags:
- mcp-tools
- reference
- write_note
created: 2025-10-28T00:00:00
modified: 2025-10-28T00:00:00
---
# Write Note
Create or update markdown notes with semantic observations and relations.
## Function Signature
```python
write_note(title, content, folder, project=None, tags=None, entity_type="note")
```
## Parameters
- **title** (str): The title of the note
- **content** (str): Markdown content for the note, can include observations and relations
- **folder** (str): Folder path relative to project root (use "/" or "" for root)
- **project** (str, optional): Project name to write to
- **tags** (str|list, optional): Tags to categorize the note
- **entity_type** (str): Type of entity ("note", "guide", "report", etc.)
## Returns
A markdown formatted summary of the semantic content, including:
- Creation/update status with project name
- File path and checksum
- Observation counts by category
- Relation counts (resolved/unresolved)
- Tags if present
## Observations
- [tool] MCP tool for creating or updating markdown notes with semantic observations and relations #mcp #basic-memory
- [returns] Markdown formatted summary of semantic content #output
- [category] Content Management tool #classification
- [feature] Supports YAML frontmatter, observations with [category] syntax, and relations #knowledge-graph
- [feature] Validates folder paths to prevent path traversal attacks #security
## Usage Examples
### Basic Usage
```python
# Create a simple note
write_note(
project="my-research",
title="Meeting Notes",
folder="meetings",
content="# Weekly Standup\\n\\n- [decision] Use SQLite for storage #tech"
)
```
### With Semantic Content
```python
write_note(
project="work-project",
title="API Design",
folder="specs",
content="""
# REST API Specification
## Overview
Core API endpoints for user management.
## Observations
- [design] RESTful architecture #api #architecture
- [tech] FastAPI framework #implementation #python
- [decision] JWT for authentication #security
## Relations
- implements [[Authentication System]]
- uses [[PostgreSQL Database]]
- specified_by [[OpenAPI Spec]]
""",
tags=["api", "design"],
entity_type="guide"
)
```
### Creating Knowledge Graph Entries
```python
# Entity with relations to other concepts
write_note(
project="knowledge-base",
title="Machine Learning Basics",
folder="concepts",
content="""
# Machine Learning Basics
Core concepts in machine learning and AI.
## Observations
- [definition] ML is subset of AI focused on learning from data #ai #ml
- [technique] Supervised learning requires labeled data #training
- [application] Image recognition, NLP, recommendation systems #use-cases
## Relations
- part_of [[Artificial Intelligence]]
- requires [[Training Data]]
- enables [[Predictive Analytics]]
- contrasts_with [[Rule-Based Systems]]
"""
)
```
### Updating Existing Notes
```python
# Update existing note (same title/folder)
write_note(
project="my-research",
title="Meeting Notes",
folder="meetings",
content="# Weekly Standup\\n\\n- [decision] Use PostgreSQL instead #tech"
)
```
## Project Resolution
Server resolves projects in this order:
1. Single Project Mode (if only one project exists)
2. project parameter (if provided)
3. default project (from configuration)
If project is unknown, use `list_memory_projects()` or `recent_activity()` first.
## Security
- Validates folder paths to prevent path traversal attacks
- Folder paths must stay within project boundaries
- Paths like "../../../etc/passwd" are blocked
## Relations
- part_of [[Content Management]]
- documented_in [[MCP Tool Reference]]
- complements [[Read Note]]
- complements [[Edit Note]]
- uses [[Entity Parser]]
+691
View File
@@ -0,0 +1,691 @@
#!/usr/bin/env python3
"""
Generate a Basic Memory project with comprehensive MCP tool reference documentation.
This script creates a structured knowledge base that users can download and import
into their Basic Memory projects, providing complete tool usage examples in a
navigable knowledge graph format.
"""
import os
from pathlib import Path
from datetime import datetime
# Tool categories and their tools
TOOLS = {
"Content Management": {
"write_note": {
"description": "Create or update markdown notes with semantic observations and relations",
"params": "title, content, folder, project, tags, entity_type",
"returns": "Markdown formatted summary of semantic content",
},
"read_note": {
"description": "Read markdown notes by title, permalink, or memory:// URL",
"params": "identifier, project, page, page_size",
"returns": "Full markdown content with frontmatter and formatting",
},
"read_content": {
"description": "Read raw file content (text, images, binaries) without knowledge graph processing",
"params": "path, project",
"returns": "Raw file content or base64 encoded binary data",
},
"view_note": {
"description": "View notes as formatted artifacts for better readability",
"params": "identifier, project, page, page_size",
"returns": "Formatted artifact presentation of note content",
},
"edit_note": {
"description": "Edit notes incrementally with append, prepend, find/replace, replace_section",
"params": "identifier, operation, content, project",
"returns": "Confirmation with updated entity information",
},
"move_note": {
"description": "Move notes to new locations, updating database and maintaining links",
"params": "identifier, destination_path, project",
"returns": "Confirmation with old and new paths",
},
"delete_note": {
"description": "Delete notes from the knowledge base",
"params": "identifier, project",
"returns": "Confirmation of deletion",
},
},
"Knowledge Graph Navigation": {
"build_context": {
"description": "Navigate knowledge graph via memory:// URLs for conversation continuity",
"params": "url, depth, timeframe, project",
"returns": "Contextual information from knowledge graph traversal",
},
"recent_activity": {
"description": "Get recently updated information with specified timeframe",
"params": "type, depth, timeframe, project",
"returns": "List of recently modified entities",
},
"list_directory": {
"description": "Browse directory contents with filtering and depth control",
"params": "dir_name, depth, file_name_glob, project",
"returns": "Hierarchical directory structure",
},
},
"Search & Discovery": {
"search_notes": {
"description": "Full-text search with advanced filtering and boolean operators",
"params": "query, project, page, page_size, search_type, types, entity_types, after_date",
"returns": "SearchResponse with paginated results",
},
},
"Project Management": {
"list_memory_projects": {
"description": "List all available projects with their status",
"params": "None",
"returns": "List of projects with metadata",
},
"create_memory_project": {
"description": "Create new Basic Memory projects",
"params": "project_name, project_path, set_default",
"returns": "Confirmation with project details",
},
"delete_project": {
"description": "Delete a project from configuration",
"params": "project_name",
"returns": "Confirmation of deletion",
},
"get_current_project": {
"description": "Get current project information and stats",
"params": "None",
"returns": "Current project metadata",
},
"sync_status": {
"description": "Check file synchronization and background operation status",
"params": "project",
"returns": "Sync status and operation details",
},
},
"Visualization": {
"canvas": {
"description": "Generate Obsidian canvas files for knowledge graph visualization",
"params": "nodes, edges, title, folder, project",
"returns": "Path to created canvas file",
},
},
}
# Detailed examples for key tools
TOOL_EXAMPLES = {
"write_note": '''
## Basic Usage
```python
# Create a simple note
write_note(
project="my-research",
title="Meeting Notes",
folder="meetings",
content="# Weekly Standup\\n\\n- [decision] Use SQLite for storage #tech"
)
```
## With Semantic Content
```python
write_note(
project="work-project",
title="API Design",
folder="specs",
content="""
# REST API Specification
## Overview
Core API endpoints for user management.
## Observations
- [design] RESTful architecture #api #architecture
- [tech] FastAPI framework #implementation #python
- [decision] JWT for authentication #security
## Relations
- implements [[Authentication System]]
- uses [[PostgreSQL Database]]
- specified_by [[OpenAPI Spec]]
""",
tags=["api", "design"],
entity_type="guide"
)
```
## Creating Knowledge Graph Entries
```python
# Entity with relations to other concepts
write_note(
project="knowledge-base",
title="Machine Learning Basics",
folder="concepts",
content="""
# Machine Learning Basics
Core concepts in machine learning and AI.
## Observations
- [definition] ML is subset of AI focused on learning from data #ai #ml
- [technique] Supervised learning requires labeled data #training
- [application] Image recognition, NLP, recommendation systems #use-cases
## Relations
- part_of [[Artificial Intelligence]]
- requires [[Training Data]]
- enables [[Predictive Analytics]]
- contrasts_with [[Rule-Based Systems]]
"""
)
```
''',
"read_note": '''
## Read by Permalink
```python
# Direct permalink lookup (fastest)
read_note("my-research", "specs/search-spec")
```
## Read by Title
```python
# Title search with fallback
read_note("work-project", "Search Specification")
```
## Read with Memory URL
```python
# Using memory:// protocol
read_note("my-research", "memory://specs/search-spec")
```
## With Pagination
```python
# Large notes with pagination
read_note("work-project", "Project Updates", page=2, page_size=5)
```
''',
"search_notes": '''
## Basic Search
```python
# Simple keyword search
search_notes("project planning")
```
## Boolean Operators
```python
# AND search (both terms required)
search_notes("project AND planning")
# OR search (either term)
search_notes("project OR meeting")
# NOT search (exclude term)
search_notes("project NOT archived")
# Complex boolean with grouping
search_notes("(project OR planning) AND notes")
```
## Phrase Search
```python
# Exact phrase match
search_notes('"weekly standup meeting"')
```
## Search with Filters
```python
# Filter by content type
search_notes(
"meeting notes",
types=["entity"]
)
# Filter by entity type
search_notes(
"meeting notes",
entity_types=["observation"]
)
# Recent content only
search_notes(
"bug report",
after_date="1 week"
)
```
## Search Types
```python
# Title-only search
search_notes("Machine Learning", search_type="title")
# Permalink pattern matching
search_notes("docs/meeting-*", search_type="permalink")
# Full-text search (default)
search_notes("keyword", search_type="text")
```
## Advanced Patterns
```python
# Content-specific search
search_notes("tag:example") # Search within tags
search_notes("category:observation") # Filter by category
# Complex multi-filter search
search_notes(
"(bug OR issue) AND NOT resolved",
types=["entity"],
after_date="2024-01-01"
)
```
''',
"build_context": '''
## Basic Context Building
```python
# Build context from a starting point
build_context("memory://projects/current-project")
```
## With Depth Control
```python
# Follow relations to depth of 2
build_context("memory://concepts/machine-learning", depth=2)
```
## With Timeframe Filter
```python
# Recent context from last week
build_context("memory://meetings/weekly", timeframe="1w")
```
## For Conversation Continuity
```python
# Load previous conversation context
build_context("memory://conversations/project-discussion", depth=3)
```
''',
"edit_note": '''
## Append Content
```python
edit_note(
"my-research",
"meeting-notes",
operation="append",
content="\\n## New Section\\n\\nAdditional meeting notes..."
)
```
## Prepend Content
```python
edit_note(
"work-project",
"todo-list",
operation="prepend",
content="## Urgent Tasks\\n\\n- Fix critical bug\\n\\n"
)
```
## Find and Replace
```python
edit_note(
"my-research",
"api-spec",
operation="find_replace",
content="SQLite|PostgreSQL" # Find|Replace pattern
)
```
## Replace Section
```python
edit_note(
"work-project",
"design-doc",
operation="replace_section",
content="## Old Section|## New Section\\n\\nUpdated content..."
)
```
''',
}
def create_frontmatter(title: str, entity_type: str, tags: list[str], permalink: str = None) -> str:
"""Generate YAML frontmatter for a markdown file."""
created = datetime.now().isoformat()
fm = [
"---",
f"title: {title}",
f"type: {entity_type}",
]
if permalink:
fm.append(f"permalink: {permalink}")
if tags:
fm.append("tags:")
for tag in tags:
fm.append(f"- {tag}")
fm.extend([
f"created: {created}",
f"modified: {created}",
"---",
])
return "\n".join(fm)
def generate_category_file(category: str, tools: dict, output_dir: Path) -> None:
"""Generate a category index file."""
filename = category.lower().replace(" ", "-").replace("&", "and")
filepath = output_dir / "categories" / f"{filename}.md"
tags = ["mcp-tools", "reference", "category"]
frontmatter = create_frontmatter(category, "guide", tags)
content = [frontmatter, "", f"# {category}", ""]
content.append(f"Tools in the {category} category for Basic Memory MCP server.")
content.append("")
content.append("## Observations")
content.append(f"- [category] Contains {len(tools)} MCP tools #mcp #tools")
content.append(f"- [purpose] {category} functionality for Basic Memory #functionality")
content.append("")
content.append("## Tools in This Category")
content.append("")
for tool_name, tool_info in tools.items():
content.append(f"### {tool_name}")
content.append(f"{tool_info['description']}")
content.append("")
content.append("## Relations")
for tool_name in tools.keys():
tool_title = " ".join(word.capitalize() for word in tool_name.split("_"))
content.append(f"- contains [[{tool_title}]]")
content.append("- part_of [[MCP Tool Reference]]")
filepath.parent.mkdir(parents=True, exist_ok=True)
filepath.write_text("\n".join(content))
print(f"Created: {filepath}")
def generate_tool_file(tool_name: str, tool_info: dict, category: str, output_dir: Path) -> None:
"""Generate a detailed tool reference file."""
tool_title = " ".join(word.capitalize() for word in tool_name.split("_"))
filepath = output_dir / "tools" / f"{tool_name}.md"
tags = ["mcp-tools", "reference", tool_name]
frontmatter = create_frontmatter(tool_title, "guide", tags, f"tools/{tool_name}")
content = [frontmatter, "", f"# {tool_title}", ""]
content.append(tool_info["description"])
content.append("")
content.append("## Function Signature")
content.append("")
content.append("```python")
content.append(f"{tool_name}({tool_info['params']})")
content.append("```")
content.append("")
content.append("## Observations")
content.append(f"- [tool] MCP tool for {tool_info['description'].lower()} #mcp #basic-memory")
content.append(f"- [returns] {tool_info['returns']} #output")
content.append(f"- [category] {category} tool #classification")
content.append("")
# Add examples if available
if tool_name in TOOL_EXAMPLES:
content.append("## Usage Examples")
content.append(TOOL_EXAMPLES[tool_name])
content.append("")
content.append("## Relations")
category_link = category.replace(" ", "-").replace("&", "and")
category_title = category
content.append(f"- part_of [[{category_title}]]")
content.append("- documented_in [[MCP Tool Reference]]")
# Add cross-references to related tools
if category == "Content Management":
if tool_name == "write_note":
content.append("- complements [[Read Note]]")
content.append("- complements [[Edit Note]]")
elif tool_name == "read_note":
content.append("- complements [[Write Note]]")
content.append("- alternative [[View Note]]")
elif tool_name == "edit_note":
content.append("- requires [[Read Note]]")
content.append("- alternative [[Write Note]]")
elif category == "Search & Discovery":
content.append("- complements [[Recent Activity]]")
content.append("- complements [[Build Context]]")
filepath.parent.mkdir(parents=True, exist_ok=True)
filepath.write_text("\n".join(content))
print(f"Created: {filepath}")
def generate_index_file(output_dir: Path) -> None:
"""Generate the main index file."""
filepath = output_dir / "index.md"
tags = ["mcp-tools", "reference", "index"]
frontmatter = create_frontmatter("MCP Tool Reference", "guide", tags, "index")
content = [frontmatter, "", "# MCP Tool Reference", ""]
content.append("Comprehensive reference for all Basic Memory MCP tools with examples and usage patterns.")
content.append("")
content.append("## Overview")
content.append("")
content.append("This project contains detailed documentation for all 16 core MCP tools in Basic Memory.")
content.append("Each tool is documented as a separate entity with examples, parameters, and relationships.")
content.append("")
content.append("## Observations")
total_tools = sum(len(tools) for tools in TOOLS.values())
content.append(f"- [structure] Contains {total_tools} tool reference documents #documentation")
content.append(f"- [structure] Organized into {len(TOOLS)} categories #organization")
content.append("- [purpose] Provides copy-paste examples for LLM instructions #usage")
content.append("- [format] Follows Basic Memory knowledge graph format #compliance")
content.append("")
content.append("## Tool Categories")
content.append("")
for category in TOOLS.keys():
category_link = category.replace(" ", "-").replace("&", "and")
content.append(f"### {category}")
content.append(f"See [[{category}]] for all tools in this category.")
content.append("")
content.append("## Relations")
for category in TOOLS.keys():
content.append(f"- contains [[{category}]]")
content.append("- documented_in [[Basic Memory Documentation]]")
filepath.write_text("\n".join(content))
print(f"Created: {filepath}")
def generate_readme(output_dir: Path) -> None:
"""Generate README for the project."""
filepath = output_dir / "README.md"
content = [
"# Basic Memory MCP Tool Reference Project",
"",
"A downloadable Basic Memory project containing comprehensive documentation for all MCP tools.",
"",
"## What This Is",
"",
"This is a complete Basic Memory project that you can import into your own Basic Memory installation.",
"It provides detailed reference documentation for all 16 core MCP tools, organized as a knowledge graph",
"that you can navigate and search using Basic Memory's tools.",
"",
"## How to Use",
"",
"### Option 1: Import into Existing Project",
"",
"1. Copy the contents of this directory into your Basic Memory project",
"2. Run `basic-memory sync` to index the new content",
"3. Use `search_notes` or `build_context` to explore the documentation",
"",
"### Option 2: Create New Project",
"",
"1. Create a new Basic Memory project:",
" ```bash",
" basic-memory tools create-memory-project \\",
' --project-name "tool-reference" \\',
' --project-path "~/basic-memory-tool-reference"',
" ```",
"",
"2. Copy these files into the new project directory",
"",
"3. Sync the project:",
" ```bash",
" basic-memory sync",
" ```",
"",
"### Option 3: Browse in Your Editor",
"",
"The files are standard markdown with Basic Memory frontmatter.",
"You can browse them in any markdown editor or Obsidian.",
"",
"## Project Structure",
"",
"```",
"tool-reference/",
"├── README.md (this file)",
"├── index.md (main reference guide)",
"├── tools/",
"│ ├── write_note.md",
"│ ├── read_note.md",
"│ ├── search_notes.md",
"│ └── ... (all 16 tools)",
"└── categories/",
" ├── content-management.md",
" ├── knowledge-graph-navigation.md",
" ├── search-and-discovery.md",
" ├── project-management.md",
" └── visualization.md",
"```",
"",
"## Using the Documentation",
"",
"### Search for Tools",
"",
"```python",
'# Find all content management tools',
'search_notes("content management", search_type="text")',
"",
"# Find write_note examples",
'search_notes("write_note")',
"```",
"",
"### Navigate by Category",
"",
"```python",
'# Read a category overview',
'read_note("content-management")',
"",
"# Build context around search tools",
'build_context("memory://categories/search-and-discovery")',
"```",
"",
"### View Tool Details",
"",
"```python",
'# Read specific tool documentation',
'read_note("tools/write_note")',
'read_note("tools/search_notes")',
"",
"# View as artifact for better formatting",
'view_note("tools/build_context")',
"```",
"",
"## What's Included",
"",
"- **16 tool reference documents** with detailed examples",
"- **5 category guides** organizing tools by function",
"- **Knowledge graph relations** connecting related tools",
"- **Copy-paste examples** ready for LLM instructions",
"- **Search syntax guide** for advanced queries",
"- **Real-world workflows** showing tool combinations",
"",
"## Tool Categories",
"",
]
for category, tools in TOOLS.items():
content.append(f"### {category}")
content.append("")
for tool_name, tool_info in tools.items():
content.append(f"- `{tool_name}`: {tool_info['description']}")
content.append("")
content.extend([
"## Generated Documentation",
"",
"This project was automatically generated from the Basic Memory MCP tool source code.",
"You can regenerate it by running:",
"",
"```bash",
"python scripts/generate_tool_reference_project.py",
"```",
"",
"## License",
"",
"Same as Basic Memory - AGPL v3",
"",
])
filepath.write_text("\n".join(content))
print(f"Created: {filepath}")
def main():
"""Generate the complete tool reference project."""
output_dir = Path("examples/tool-reference")
print(f"Generating Basic Memory Tool Reference Project in {output_dir}")
print()
# Generate category files
for category, tools in TOOLS.items():
generate_category_file(category, tools, output_dir)
# Generate tool files
for category, tools in TOOLS.items():
for tool_name, tool_info in tools.items():
generate_tool_file(tool_name, tool_info, category, output_dir)
# Generate index
generate_index_file(output_dir)
# Generate README
generate_readme(output_dir)
print()
print("✓ Tool reference project generated successfully!")
print(f"✓ Location: {output_dir}")
print(f"✓ Total files: {len(list(output_dir.rglob('*.md')))}")
if __name__ == "__main__":
main()