Second Brain MCP Server
An MCP (Model Context Protocol) server that helps you create structured markdown notes from your Claude Code sessions. Capture commands executed, file changes, conversation summaries, and code snippets, then organize everything into a searchable second brain.
Features
Session Capture & Analysis
Pattern Detection: Automatically identifies session type (š New Feature, š Bug Fix, ā»ļø Refactoring, š Documentation, āļø Configuration, ā Testing)
Complexity Analysis: Simple file count-based classification (š¢ Simple: <3 files, š” Moderate: 3-7 files, š“ Complex: 8+ files)
Automatic Organization: Notes organized by project into subdirectories
Rich Metadata: Captures commands, file changes, code snippets, and summaries with structured metadata
Clean Markdown: Readable format with emoji indicators and Key Changes bullets
Search & Discovery
Advanced Search: Multi-criteria filters (project, tags, pattern, complexity, date range, text query) with relevance scoring
Similarity Search: Find related sessions using Jaccard similarity across tags, patterns, and projects
Unified Search Tool: Single
search_notestool handles both text search and similarity search
Weekly Reports
Comprehensive Summaries: Statistics on sessions, files changed, and commands executed
Pattern & Complexity Distribution: Visual breakdown of work patterns and complexity levels
Project Breakdown: Sessions grouped by project
Session List: Chronological list of all sessions with summaries
Technical
No External Dependencies: Everything runs locally without API keys or external services
Metadata Caching: Fast queries with JSON metadata files
Flexible Configuration: Customize where notes are stored
TypeScript: Full type safety with comprehensive test coverage
Installation
Clone or download this repository
Install dependencies:
Build the TypeScript code:
Configuration
Add the MCP server to your Claude Code configuration file (~/.claude/settings.local.json):
Replace /absolute/path/to/second_brain_mcp with the actual path to this project.
Notes Directory Configuration
By default, notes are saved to ~/notes (your home directory). You can customize this in two ways:
Option 1: Environment Variable (Recommended)
Set the SECOND_BRAIN_NOTES_DIR environment variable:
Or add it to your MCP server configuration:
Option 2: Per-Tool Parameter
Pass notesDirectory parameter when calling any tool (overrides environment variable):
Priority: Tool parameter > Environment variable > Default (~/notes)
Available Tools
This MCP server provides 3 focused tools for managing your session notes:
Tool | Purpose |
| Capture and save detailed session notes with automatic pattern and complexity analysis |
| Search notes with advanced filters, text search, and similarity-based discovery |
| Generate comprehensive weekly summary reports |
Usage
Once configured, you can use these tools in your Claude Code conversations:
Basic Example
Full Example with All Fields
Searching Notes
Weekly Reports
Tool Reference
capture_session_note
Capture and save a markdown note from a Claude Code session with automatic analysis.
Parameters:
Parameter | Type | Required | Description |
| string | Yes | High-level summary of what was accomplished |
| string | No | Project name (used for organizing into subdirectories) |
| string | No | Specific topic or feature being worked on |
| array | No | List of commands executed with descriptions |
| array | No | Files created, modified, or deleted |
| array | No | Important code snippets from the session |
| array | No | Tags for categorizing the note |
| string | No | Working directory (defaults to current directory) |
| string | No | Custom notes directory (defaults to ~/notes or $SECOND_BRAIN_NOTES_DIR) |
Command Object:
File Change Object:
Code Snippet Object:
search_notes
Search session notes with advanced filters, text search, and similarity-based discovery.
Parameters:
Parameter | Type | Required | Description |
| string | No | Text to search for in notes |
| string | No | Filter by project name |
| array | No | Filter by tags (notes must have at least one) |
| string | No | Filter by session pattern (new-feature, bug-fix, refactoring, documentation, configuration, testing, mixed) |
| string | No | Filter by complexity level (simple, moderate, complex) |
| string | No | Filter by start date (ISO format) |
| string | No | Filter by end date (ISO format) |
| string | No | Path to note for similarity search. Results ranked by similarity to this note. |
| string | No | Custom notes directory (defaults to ~/notes or $SECOND_BRAIN_NOTES_DIR) |
Text Search Examples:
Similarity Search Examples:
Combined Search:
Similarity is calculated using weighted Jaccard similarity:
Tags (40% weight)
Pattern matching (30% weight)
Project name (30% weight)
Results are sorted by relevance score (combined text relevance and similarity if applicable) and include project, summary, date, tags, matched tags, and file path.
generate_weekly_report
Generate a comprehensive weekly summary of all sessions.
Parameters:
Parameter | Type | Required | Description |
| string | No | Custom notes directory (defaults to ~/notes or $SECOND_BRAIN_NOTES_DIR) |
Example:
The report includes:
Total sessions, files changed, commands executed
Project breakdown
Work patterns distribution (š New Feature, š Bug Fix, etc.)
Complexity distribution (š¢ Simple, š” Moderate, š“ Complex)
List of all sessions with date, time, and summaries
Note Organization
Notes are saved to a centralized location (~/notes by default) and organized by project:
Organization structure:
All notes are in one centralized directory (easier to search and backup)
Each project gets its own subdirectory
Filenames include date, time, project name, and topic
Notes without a project name go into a
session/folder
Benefits of centralized storage:
Easy to search across all projects
Simple to backup (one directory)
Works well with version control
Can be synced to cloud storage
Output Format
Generated notes include:
Header: Project name and topic
Metadata: Date, working directory, tags, Pattern (š/š/ā»ļø/etc.), Complexity (š¢/š”/š“ with file count)
Summary: High-level description
Key Changes: 2-3 concise bullet points summarizing main changes
Commands Executed: All commands with outputs (collapsible)
File Changes: Organized by created/modified/deleted with descriptions
Code Snippets: With syntax highlighting and context
Example Note
Run tests
File Changes
Created Files
src/auth/jwt.ts- JWT token generation and validationsrc/auth/routes.ts- Login and registration endpoints
Modified Files
src/server.ts- Added authentication middleware
Code Snippets
JWT validation middleware
From:
Watch Mode
Run Locally
Testing
The project has comprehensive test coverage (95%+) covering all services and utilities.
Tips
End of Session: Call the capture tool at the end of your coding session to document your work
Consistent Project Names: Use the same project name across sessions for better organization
Meaningful Summaries: Write clear summaries that you can search for later
Use Tags: Add relevant tags to make notes easier to find
Include Context: Add code snippets and file changes to provide context for future reference
File Descriptions: Add descriptions to file changes - they become Key Changes bullets in your notes
Contributing
Contributions are welcome! Please read our Contributing Guide for details on:
Setting up the development environment
Code style and conventions
Commit message format (we use Conventional Commits)
Pull request process
Running tests
Quick Start for Contributors
Versioning
This project uses Semantic Versioning and automated releases via semantic-release. Version numbers and changelog entries are automatically generated based on commit messages.
License
MIT