What is MCP?
The Model Context Protocol is an open standard for connecting AI assistants to external data sources and tools. Instead of each AI platform using custom integrations, MCP provides:- Standard protocol: JSON-RPC 2.0 over stdio, HTTP, or SSE
- Tool definitions: Structured interface for AI-callable functions
- Resource access: Read-only data sources the AI can browse
- Prompts: Pre-configured workflows the AI can invoke
Architecture
The MCP server acts as a bridge between AI assistants and your local knowledge:Component Flow
MCP Server
Runs locally, started by Claude Desktop. Handles protocol communication and exposes tools, resources, and prompts.
Typed Clients
MCP tools use typed clients (in
mcp/clients/) to communicate with the API:KnowledgeClient- Entity CRUDSearchClient- Search operationsMemoryClient- Context buildingDirectoryClient- Directory listingResourceClient- Resource readingProjectClient- Project management
HTTP API
FastAPI endpoints handle business logic, using services and repositories to interact with the database and file system.
Client Routing
MCP tools useget_project_client() for automatic routing based on project mode:
MCP Tools
Tools are functions the AI can call to manipulate your knowledge graph.Content Management
write_note()
write_note()
Create or update markdown notes:What it does:
- Creates entity in database
- Writes markdown file with frontmatter
- Parses observations and relations
- Returns
memory://URL for the note
mcp/tools/write_note.pyread_note()
read_note()
Read notes by title, permalink, or memory:// URL:Returns: Formatted note with frontmatter, content, observations, relations, and outgoing/incoming links.Source:
mcp/tools/read_note.pyedit_note()
edit_note()
Edit notes incrementally without full rewrite:Operations:
append, prepend, find_replace, replace_sectionSource: mcp/tools/edit_note.pymove_note()
move_note()
Move notes or directories:Updates database and maintains wiki link integrity.Source:
mcp/tools/move_note.pydelete_note()
delete_note()
Delete notes or directories:Removes from both database and file system.Source:
mcp/tools/delete_note.pyKnowledge Graph Navigation
build_context()
build_context()
Navigate the knowledge graph via memory:// URLs:Returns: JSON structure with entity + related entities following graph edges.Use case: Load conversation context from previous sessions.Source:
mcp/tools/build_context.pyrecent_activity()
recent_activity()
Get recently updated information:Returns: Recently modified entities with optional related content.Source:
mcp/tools/recent_activity.pylist_directory()
list_directory()
Browse directory contents:Returns: Directory tree with files and subdirectories.Source:
mcp/tools/list_directory.pySearch & Discovery
search_notes()
search_notes()
Full-text search with advanced filtering:Search types:
full- Match anywhere in content (default)prefix- Match at word boundaries
mcp/tools/search.pyProject Management
list_memory_projects()
list_memory_projects()
List all configured projects:Returns: Projects with their paths, modes (LOCAL/CLOUD), and status.Source:
mcp/tools/project_management.pycreate_memory_project()
create_memory_project()
Create new Basic Memory project:Source:
mcp/tools/project_management.pyMCP Resources
Resources are read-only data sources the AI can browse:memory://
List all entities:Project Info
Current project statistics:mcp/resources/project_info.py
MCP Prompts
Prompts are pre-configured workflows the AI can invoke:continue_conversation
continue_conversation
Resume a previous conversation with context:What it does:
- Searches for entities matching the topic
- Loads recent changes (timeframe)
- Builds rich context using
build_context() - Returns formatted markdown for the AI
mcp/prompts/continue_conversation.pysearch
search
Search with formatted, detailed results:Returns search results with entity metadata, observation excerpts, and relation context.Source:
mcp/prompts/search.pyrecent_activity
recent_activity
View recent changes with formatted output:Source:
mcp/prompts/recent_activity.pyConfiguration
Claude Desktop
Add to~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
VS Code
Add to.vscode/mcp.json in your workspace:
Preferences: Open User Settings (JSON) → "mcp": { "servers": {...} }
Transport Modes
MCP supports multiple transport layers:stdio (default)
JSON-RPC over standard input/output:SSE (Server-Sent Events)
HTTP-based streaming for web clients:Streamable HTTP
HTTP with streaming responses:Cloud Routing
Individual projects can route through the cloud while others stay local:Error Handling
MCP tools return structured errors:-32600- Invalid request-32601- Method not found-32602- Invalid parameters-32603- Internal error
Performance
- Tool calls: Sub-second for most operations
- Search: Sub-millisecond (FTS5 indexed)
- Context building: Scales linearly with depth × relations
- File writes: Atomic with checksum validation
Security
- Local by default: MCP server runs locally, no network access required
- Cloud mode: Optional, uses JWT tokens or API keys
- File system: Access limited to project directories
- Validation: All inputs validated via Pydantic schemas
Debugging
Enable debug logging:Best Practices
Use Specific Tools
Call specific tools (
write_note, edit_note) rather than asking the AI to “update my notes” - this ensures correct tool usage.Leverage Context Building
Use
build_context() to load rich context from previous conversations rather than re-reading multiple notes individually.Structure with Observations
Use observations for structured data within notes - they’re indexed and searchable separately from content.
Set Depth Limits
When traversing the graph, use appropriate depth limits (1-3) to avoid exponential expansion.
Next Steps
MCP Tools Reference
Complete reference for all MCP tools
Knowledge Graph
Understand entities, observations, and relations