Generated banner for MCPVault
Generated logo for MCPVault

MCPVault

Memory server

First committed by bitbonsai

Published in bitbonsai/mcpvault. Publisher page

1,722 GitHub stars

What it is

Universal AI bridge for Obsidian vaults - connect any MCP-compatible assistant
— the description by bitbonsai

AutoGineer overview, from the brain’s own files

MCPVault is a universal AI bridge designed to connect any MCP-compatible assistant to a local Obsidian vault. By operating as a local stdio process, it allows AI agents to interact with markdown files without requiring an Obsidian plugin or the application to be running. It provides a comprehensive suite of 18 tools for file management, search, and metadata handling, while enforcing strict security boundaries to prevent unauthorized file access or traversal outside the vault root.

How it works

Memory model: Markdown vault

AutoGineer overview, from the brain’s own files

The system runs as a local server that accepts a vault path. It uses a filesystem service to perform operations like reading, writing, patching, and moving notes. A path filter ensures all operations remain within the vault, blocking access to sensitive directories like .obsidian or .git. It uses a frontmatter handler to manage YAML metadata while preserving document formatting, and a search service to provide token-optimized, ranked results.

Folders
FolderRoleFiles
.claudeagent-config3
.githubagent-config5
scriptsscripts7
skillsagent-instructions8
srcsource-code25
.plansfolder2
benchmarksfolder3
deployfolder1
website-shibumifolder124

The agent reads

The agent writes

Requirements

Runtimes: Node.js >=22.12.0, Bun

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Google Antigravity, Kiro, OpenCode, Amp, Roo Code, Cline, JetBrains Junie, Devin (ex-Windsurf)

Set it up

  1. This brain runs code automatically: 1 hook (claude-code), 1 script. Review .claude/settings.json, scripts/triage/bootstrap.sh before opening the folder in Claude Code. No step below turns a hook on for you.

    • .claude/settings.json: if [ -f .plans/next.md ]; then cat .plans/next.md && mv .plans/next.md .plans/next.prev.md; fi
    • scripts/triage/bootstrap.sh: sh scripts/triage/bootstrap.sh
  2. Not scanned by AutoGineerIts dependencies are installed by npm when you run it and were not scanned by AutoGineer (4 declared). https://www.npmjs.com/package/@bitbonsai/mcpvault
  3. First committed by bitbonsai. Published in bitbonsai/mcpvault. Licence: MIT License.

Usage

AutoGineer overview, from the brain’s own files

  • Connects AI agents to local Obsidian vaults via the Model Context Protocol.
  • Supports read, write, and patch operations on markdown notes.
  • Provides metadata management including frontmatter and tag operations.
  • Enables full-text search with BM25 reranking across vault content.
  • Offers batch processing and directory listing capabilities.
  • Includes a read-only mode for secure, non-destructive agent access.
“Read my note called 'project-ideas.md'”
The agent retrieves the content and parsed frontmatter of the specified note.
“Create a new note with today's date”
The agent generates a new markdown file within the vault root with the provided content and metadata.
“List all notes with 'AI' in the title”
The agent performs a search across the vault and returns a list of matching notes.
“Append today's journal entry to my daily note”
The agent updates the existing daily note by appending the new text to the end of the file.

Documentation by bitbonsai

<div align="center"> <img width="256" height="256" alt="image" src="https://github.com/user-attachments/assets/1e21d898-811b-42c2-a810-bf921dde0f58" /> </div>

MCPVault

Image: MCP Toplist

A local MCP server that lets compatible clients read, search, and edit notes in an Obsidian vault. MCPVault works directly with vault files, restricts file operations to the configured vault root, and preserves formatting for unchanged frontmatter fields.

<div align="center">

https://mcpvault.org

Changelog

</div>

<div align="center">

Image: GitHub Stars Image: npm version Image: npm downloads Image: GitHub Sponsors Image: Ko-Fi Image: Liberapay

</div>

Supported clients

Configuration examples are available for Claude Desktop, Claude Code, ChatGPT Desktop (Enterprise+), OpenCode, Gemini CLI, OpenAI Codex, IntelliJ IDEA 2025.1+, Cursor, Windsurf, and Ontheia. Other clients can use MCPVault if they support local stdio MCP servers.

https://github.com/user-attachments/assets/657ac4c6-1cd2-4cc3-829f-fd095a32f71c

Quick start

  1. Install Node.js runtime:

    # Download from https://nodejs.org (v22.12.0 or later)
    # or use a package manager like nvm, brew, apt, etc.
  2. Test the server:

    If using the published package:

    npx @modelcontextprotocol/inspector npx @bitbonsai/mcpvault@latest /path/to/your/vault
  3. Configure your AI client:

    Claude Desktop - Copy this to claude_desktop_config.json:

    {
      "mcpServers": {
        "obsidian": {
          "command": "npx",
          "args": ["@bitbonsai/mcpvault@latest", "/path/to/your/vault"]
        }
      }
    }

    Claude Code - Copy this to ~/.claude.json:

    {
      "mcpServers": {
        "obsidian": {
          "command": "npx",
          "args": ["@bitbonsai/mcpvault@latest", "/path/to/your/vault"],
          "env": {}
        }
      }
    }

    OpenCode - Copy this to ~/.config/opencode/opencode.json

    {
      "mcp": {
        "obsidian": {
          "type": "local",
          "command": [
            "npx",
            "@bitbonsai/mcpvault@latest",
            "/path/to/your/vault/"
          ],
          "enabled": true
        }
      }
    }

    Replace /path/to/your/vault with your actual Obsidian vault path.

    For other platforms, see detailed configuration guides below.

  4. Test with your AI:

    • "List files in my Obsidian vault"

    • "Read my note called 'project-ideas.md'"

    • "Create a new note with today's date"

To verify the connection, ask your client to list MCPVault tools or read a known note.

How it connects

An MCP client starts MCPVault as a local stdio process and passes the vault path. MCPVault exposes the same tools to each supported client, so the server is not tied to one AI provider. Obsidian does not need to be running, and no Obsidian plugin is required.

Features

  • AST-aware frontmatter updates preserve formatting for unchanged YAML fields.

  • Path checks block traversal, symlink escapes, dotfiles, .obsidian, .git, and node_modules.

  • Eighteen MCP tools cover note and file operations:

    • File operations: read_note, write_note, patch_note, delete_note, move_note, move_file

    • Partial reads: get_note_outline, read_note_lines

    • Directory and batch reads: list_directory, read_multiple_notes

    • Search: search_notes with multi-word matching and BM25 reranking

    • Metadata and tags: get_frontmatter, update_frontmatter, get_notes_info, get_vault_stats, manage_tags, list_all_tags

    • Wiki links: wiki_link resolves names and returns alternative paths when a name is ambiguous

  • write_note supports overwrite, append, and prepend modes.

  • delete_note and move_file require matching confirmation paths.

  • Path arguments are trimmed before validation.

  • Search and batch tools return compact fields by default; set prettyPrint: true for expanded output.

  • The package exports TypeScript declarations and public types.

  • MCPVault requires no Obsidian plugin.

Prerequisites

  • Node.js runtime (v22.12.0 or later)

  • An Obsidian vault (local directory with .md, .markdown, .txt, .base, or .canvas files)

  • MCP-compatible AI client (Claude Desktop, ChatGPT Desktop, Claude Code, etc.)

Installation

For end users

npx downloads and runs the package:

npx @bitbonsai/mcpvault@latest /path/to/your/obsidian/vault

If you omit the vault path, the server uses your current working directory as the vault root.

For developers
  1. Clone this repository

  2. Use the correct Node.js version:

nvm use  # Uses Node 24 from .nvmrc
  1. Install dependencies with npm:

npm install  # Corepack automatically uses npm 10.9.0
  1. Test locally with MCP inspector:

npx @modelcontextprotocol/inspector npm start /path/to/your/vault

Use MCP Inspector to test the server before adding it to a client:

# Install globally for easier access
npm install -g @modelcontextprotocol/inspector

# Test with any vault
mcp-inspector npx @bitbonsai/mcpvault@latest /path/to/your/vault

Usage

Running the Server

End users:

npx @bitbonsai/mcpvault@latest
npx @bitbonsai/mcpvault@latest /path/to/your/obsidian/vault
npx @bitbonsai/mcpvault@latest ./Vault

Developers:

npm start
npm start /path/to/your/obsidian/vault
npm start ./Vault
AI Client Configuration
Claude Desktop

Add to your Claude Desktop configuration file:

Single Vault:

{
  "mcpServers": {
    "obsidian": {
      "command": "npx",
      "args": [
        "@bitbonsai/mcpvault@latest",
        "/Users/yourname/Documents/MyVault"
      ]
    }
  }
}

Multiple Vaults:

{
  "mcpServers": {
    "obsidian-personal": {
      "command": "npx",
      "args": [
        "@bitbonsai/mcpvault@latest",
        "/Users/yourname/Documents/PersonalVault"
      ]
    },
    "obsidian-work": {
      "command": "npx",
      "args": [
        "@bitbonsai/mcpvault@latest",
        "/Users/yourname/Documents/WorkVault"
      ]
    }
  }
}

Read-only mode:

Add --read-only after the vault path to expose only read tools. Mutating tools are omitted from discovery and rejected if called directly.

{
  "mcpServers": {
    "obsidian-read-only": {
      "command": "npx",
      "args": [
        "@bitbonsai/mcpvault@latest",
        "/Users/yourname/Documents/ResearchVault",
        "--read-only"
      ]
    }
  }
}

The CLI also accepts --read-only true and --read-only=true for configuration systems that require explicit values. Omit the option, or set it to false, to keep normal read/write access.

Default search and listing exclusions:

Repeat --exclude <subtree> to hide vault-relative folders from search_notes and list_directory in every session. Per-call excludePaths add to these defaults. Direct read and write tools remain available for excluded paths.

"args": [
  "@bitbonsai/mcpvault@latest",
  "/Users/yourname/Documents/ResearchVault",
  "--exclude", "Archive",
  "--exclude", "Snapshots/Old"
]

MCPVault does not read Obsidian's .obsidian/app.json; exclusions stay explicit in the MCP server configuration.

Configuration File Locations:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: C:\Users\{username}\AppData\Roaming\Claude\claude_desktop_config.json

  • Linux: ~/.config/Claude/claude_desktop_config.json

You can also access this through Claude Desktop → Settings → Developer → Edit Config

ChatGPT Desktop

Requirements: ChatGPT Enterprise, Education, or Team subscription (not available for individual Plus users)

ChatGPT uses MCP through Deep Research and developer mode. Configuration is done through the ChatGPT interface:

  1. Access ChatGPT developer mode (beta feature)

  2. Configure MCP servers through the built-in MCP client

  3. Create custom connectors for your organization

Note: ChatGPT Desktop's MCP integration is currently limited to enterprise subscriptions and uses a different setup process than file-based configuration.

Claude Code

Claude Code uses .claude.json configuration file:

User-scoped (recommended): Edit ~/.claude.json:

{
  "mcpServers": {
    "obsidian": {
      "command": "npx",
      "args": ["@bitbonsai/mcpvault@latest", "/path/to/your/vault"],
      "env": {}
    }
  }
}

Project-scoped: Edit .claude.json in your project or add to the projects section:

{
  "projects": {
    "/path/to/your/project": {
      "mcpServers": {
        "obsidian": {
          "command": "npx",
          "args": ["@bitbonsai/mcpvault@latest", "/path/to/your/vault"]
        }
      }
    }
  }
}

Using Claude Code CLI:

claude mcp add obsidian --scope user npx @bitbonsai/mcpvault /path/to/your/vault
Goose Desktop

On Goose Desktop settings, click Add custom extension, and on the command field add:

npx @bitbonsai/mcpvault@latest /path/to/your/vault
Other MCP-Compatible Clients (2025)

Confirmed MCP Support:

  • IntelliJ IDEA 2025.1+ - Native MCP client support

  • Cursor IDE - Built-in MCP compatibility

  • Windsurf IDE - Full MCP integration

  • Ontheia - Self-hosted, open-source AI agent platform

  • Zed, Replit, Codeium, Sourcegraph - In development

  • Microsoft Copilot Studio - Native MCP support with one-click server connections

Most modern MCP clients use similar JSON configuration patterns. Refer to your specific client's documentation for exact setup instructions.

Examples
Ask your AI assistant about your notes:
  • "What files are in my Obsidian vault?"

  • "Read my note called 'project-ideas.md'"

  • "Show me all notes with 'AI' in the title"

Have your AI assistant help with note management:
  • "Create a new note called 'meeting-notes.md' with today's date in the frontmatter"

  • "Append today's journal entry to my daily note"

  • "Prepend an urgent task to my todo list"

  • "Add the tags 'project' and 'urgent' to my task note"

  • "List all tags in my research note"

  • "Remove the 'draft' tag from my completed article"

  • "List all markdown files in my 'Projects' folder"

  • "Delete the old draft note 'draft-ideas.md' (with confirmation)"

Example workflows
  • "Summarize my research notes tagged with 'machine-learning' from the last month"

  • "Update the status in my project notes to 'completed' and add today's date"

  • "Find notes that mention 'API design' and draft a guide from them"

  • "Review my untagged notes and suggest tags based on their content"

Troubleshooting

Common Issues
"command not found: npx"
  • Solution: Install Node.js runtime from nodejs.org

  • Alternative: Use global install: npm install -g @bitbonsai/mcpvault

"File not found" when paths look correct
  • Cause: The server is using the wrong vault root

  • Solution: Either run the command from your vault directory or pass the vault path explicitly

"Permission denied" errors
  • Cause: Insufficient file system permissions

  • Solution: Ensure the vault directory is readable/writable by your user

"Path traversal not allowed"
  • Cause: Trying to access files outside the vault

  • Solution: All file paths must be relative to the vault root

AI client not recognizing the server
  1. Check the configuration file path is correct for your OS

  2. Ensure JSON syntax is valid (use a JSON validator)

  3. Restart your AI client after configuration changes

  4. Check your AI client's logs for error messages

  5. Verify your AI client supports MCP (Model Context Protocol)

".obsidian files still showing up"
  • Expected: The path filter automatically excludes .obsidian/** patterns

  • If still seeing them: The filter is working as designed for security

Debug Mode

Run with error logging:

npx @bitbonsai/mcpvault /path/to/vault 2>debug.log
Getting Help
  • Open an issue on GitHub

  • Include your OS, Node.js version, and error messages

  • Provide the vault directory structure (without sensitive content)

Testing

Run the test suite:

npm test

API Methods

read_note

Read a note from the vault with parsed frontmatter.

Request:

{
  "name": "read_note",
  "arguments": {
    "path": "project-ideas.md",
    "prettyPrint": false
  }
}

Compact response:

{
  "fm": {
    "title": "Project Ideas",
    "tags": ["projects", "brainstorming"],
    "created": "2023-01-15T10:30:00.000Z"
  },
  "content": "# Project Ideas\n\n## AI Tools\n- MCP server for Obsidian\n- Voice note transcription\n\n## Web Apps\n- Task management system"
}

Response (with prettyPrint: true):

{
  "fm": {
    "title": "Project Ideas",
    "tags": ["projects", "brainstorming"],
    "created": "2023-01-15T10:30:00.000Z"
  },
  "content": "# Project Ideas\n\n## AI Tools\n- MCP server for Obsidian\n- Voice note transcription\n\n## Web Apps\n- Task management system"
}
write_note

Write a note to the vault with optional frontmatter and write mode.

Write Modes:

  • overwrite (default): Replace entire file content

  • append: Add content to the end of existing file

  • prepend: Add content to the beginning of existing file

Request (Overwrite):

{
  "name": "write_note",
  "arguments": {
    "path": "meeting-notes.md",
    "content": "# Team Meeting\n\n## Agenda\n- Project updates\n- Next milestones",
    "frontmatter": {
      "title": "Team Meeting Notes",
      "date": "2023-12-01",
      "tags": ["meetings", "team"]
    },
    "mode": "overwrite"
  }
}

Request (Append):

{
  "name": "write_note",
  "arguments": {
    "path": "daily-log.md",
    "content": "\n\n## 3:00 PM Update\n- Completed project review\n- Started new feature",
    "mode": "append"
  }
}

Response:

{
  "message": "Successfully wrote note: meeting-notes.md (mode: overwrite)"
}
patch_note

Replace an exact string inside an existing note without rewriting the full file.

Request:

{
  "name": "patch_note",
  "arguments": {
    "path": "meeting-notes.md",
    "oldString": "- Next milestones",
    "newString": "- Next milestones (owner: Alex)",
    "replaceAll": false
  }
}

Response (success):

{
  "success": true,
  "path": "meeting-notes.md",
  "message": "Successfully replaced 1 occurrence",
  "matchCount": 1
}

Response (multiple matches with replaceAll=false):

{
  "success": false,
  "path": "meeting-notes.md",
  "message": "Found 3 occurrences of the string. Use replaceAll=true to replace all occurrences, or provide a more specific string to match exactly one occurrence.",
  "matchCount": 3
}
list_directory

List files and directories in the vault.

Note: this includes non-note filenames (for example pdf, png, jpg) so AI assistants can see vault structure, but note tools like read_note and write_note still operate on note files only (.md, .markdown, .txt, .base, .canvas).

Request:

{
  "name": "list_directory",
  "arguments": {
    "path": "Projects",
    "prettyPrint": false
  }
}

Compact response:

{
  "dirs": ["AI-Tools", "Web-Development"],
  "files": ["project-template.md", "roadmap.md"]
}
delete_note

Delete a note from the vault (requires confirmation for safety).

Request:

{
  "name": "delete_note",
  "arguments": {
    "path": "old-draft.md",
    "confirmPath": "old-draft.md",
    "trashMode": "local"
  }
}

Response (Success):

{
  "success": true,
  "path": "old-draft.md",
  "message": "Successfully moved note to vault trash: old-draft.md"
}

Trash modes:

  • none (default): permanent delete

  • local: move to .trash inside the vault, preserving folder structure

  • system: move to the OS trash/recycle bin

Response (Confirmation Failed):

{
  "success": false,
  "path": "old-draft.md",
  "message": "Deletion cancelled: confirmation path does not match. For safety, both 'path' and 'confirmPath' must be identical."
}

Confirmation: confirmPath must exactly match path before deletion proceeds.

get_frontmatter

Extract only the frontmatter from a note without reading the full content.

Request:

{
  "name": "get_frontmatter",
  "arguments": {
    "path": "project-ideas.md",
    "prettyPrint": false
  }
}

Compact response, returning frontmatter directly:

{
  "title": "Project Ideas",
  "tags": ["projects", "brainstorming"],
  "created": "2023-01-15T10:30:00.000Z"
}
manage_tags

Add, remove, or list tags in a note. Tags are managed in the frontmatter and inline tags are detected.

Request (List Tags):

{
  "name": "manage_tags",
  "arguments": {
    "path": "research-notes.md",
    "operation": "list"
  }
}

Request (Add Tags):

{
  "name": "manage_tags",
  "arguments": {
    "path": "research-notes.md",
    "operation": "add",
    "tags": ["machine-learning", "ai", "important"]
  }
}

Request (Remove Tags):

{
  "name": "manage_tags",
  "arguments": {
    "path": "research-notes.md",
    "operation": "remove",
    "tags": ["draft", "temporary"]
  }
}

Response:

{
  "path": "research-notes.md",
  "operation": "add",
  "tags": ["research", "ai", "machine-learning", "important"],
  "success": true,
  "message": "Successfully added tags"
}
search_notes

Search for notes in the vault by content or frontmatter with multi-word matching and BM25 relevance reranking.

Request:

{
  "name": "search_notes",
  "arguments": {
    "query": "machine learning",
    "limit": 5,
    "searchContent": true,
    "searchFrontmatter": false,
    "caseSensitive": false,
    "prettyPrint": false
  }
}

Compact response:

[
  {
    "p": "ai-research.md",
    "t": "AI Research Notes",
    "ex": "...machine learning...",
    "mc": 2,
    "ln": 15,
    "uri": "obsidian://open?vault=MyVault&file=ai-research.md"
  }
]

Field names:

  • p = path

  • t = title

  • ex = excerpt (21 chars context)

  • mc = match count

  • ln = line number

  • uri = Obsidian deep link for quick opening

move_note

Move or rename a note in the vault (.md, .markdown, .txt, .base, .canvas).

Request:

{
  "name": "move_note",
  "arguments": {
    "oldPath": "drafts/article.md",
    "newPath": "published/article.md",
    "overwrite": false
  }
}

Response:

{
  "success": true,
  "oldPath": "drafts/article.md",
  "newPath": "published/article.md",
  "message": "Successfully moved note from drafts/article.md to published/article.md"
}
move_file

Move or rename any file in the vault with binary-safe file operations (file-only; not recursive directory moves). For safety, this tool requires confirmation of both source and destination paths.

Request:

{
  "name": "move_file",
  "arguments": {
    "oldPath": "Miro/attachments/Pasted image 20250812140124.png",
    "newPath": "assets/images/Pasted image 20250812140124.png",
    "confirmOldPath": "Miro/attachments/Pasted image 20250812140124.png",
    "confirmNewPath": "assets/images/Pasted image 20250812140124.png",
    "overwrite": false
  }
}

Response:

{
  "success": true,
  "oldPath": "Miro/attachments/Pasted image 20250812140124.png",
  "newPath": "assets/images/Pasted image 20250812140124.png",
  "message": "Successfully moved file from Miro/attachments/Pasted image 20250812140124.png to assets/images/Pasted image 20250812140124.png"
}

Confirmation: confirmOldPath must match oldPath, and confirmNewPath must match newPath.

read_multiple_notes

Read multiple notes in a batch (maximum 10 files).

Request:

{
  "name": "read_multiple_notes",
  "arguments": {
    "paths": ["note1.md", "note2.md", "note3.md"],
    "includeContent": true,
    "includeFrontmatter": true,
    "prettyPrint": false
  }
}

Compact response:

{
  "ok": [
    {
      "path": "note1.md",
      "frontmatter": { "title": "Note 1" },
      "content": "# Note 1\n\nContent here..."
    }
  ],
  "err": [{ "path": "note2.md", "error": "File not found" }]
}

Field names:

  • ok = successful reads

  • err = failed reads

update_frontmatter

Update frontmatter of a note without changing content.

Request:

{
  "name": "update_frontmatter",
  "arguments": {
    "path": "research-note.md",
    "frontmatter": {
      "status": "completed",
      "updated": "2025-09-23"
    },
    "merge": true
  }
}

Response:

{
  "message": "Successfully updated frontmatter for: research-note.md"
}
get_notes_info

Get metadata for notes without reading full content.

Request:

{
  "name": "get_notes_info",
  "arguments": {
    "paths": ["note1.md", "note2.md"],
    "prettyPrint": false
  }
}

Compact response, returning an array directly:

[
  {
    "path": "note1.md",
    "size": 1024,
    "modified": 1695456000000,
    "hasFrontmatter": true
  }
]
get_vault_stats

Get high-level vault statistics without reading note contents.

Request:

{
  "name": "get_vault_stats",
  "arguments": {
    "recentCount": 5,
    "prettyPrint": false
  }
}

Compact response:

{
  "notes": 1248,
  "folders": 76,
  "size": 18349210,
  "recent": [
    {
      "path": "Daily/2026-02-27.md",
      "modified": 1772188800000,
      "size": 2814
    }
  ]
}

Security boundaries

MCPVault applies these checks before file operations:

Path Security
  • Path Traversal Protection: All file paths are validated to prevent access outside the vault

  • Relative Path Enforcement: Paths are normalized and restricted to the vault directory

  • Symbolic Link Safety: Resolved paths are checked against vault boundaries

File Filtering
  • Automatic Exclusions: .obsidian, .git, node_modules, and system files are filtered

  • Extension Whitelist: Only .md, .markdown, .txt, .base, and .canvas files are accessible by default

  • Hidden File Protection: Dot files and system directories are automatically excluded

Content Validation
  • YAML Frontmatter Validation: Frontmatter is parsed and validated before writing

  • Function/Symbol Prevention: Dangerous JavaScript objects are blocked from frontmatter

  • Data Type Checking: Only safe data types (strings, numbers, arrays, objects) allowed

Best Practices
  • Least Privilege: Server only accesses the specified vault directory

  • Read-Only Mode: Run with --read-only for sensitive vaults; mutating tools are hidden and rejected

  • Backup Recommended: Always backup your vault before using write operations

  • Network Isolation: Server uses stdio transport (no network exposure)

What's NOT Protected
  • File Content: The server can read/write any allowed file content

  • Vault Structure: Directory structure is visible to AI assistants

  • File Metadata: Creation times, file sizes, etc. are accessible

Only grant write access to clients and conversations you trust. Use --read-only when the client does not need to modify notes.

Architecture

  • server.ts - MCP server entry point

  • src/cli.ts - CLI option parsing for vault path, read-only mode, and default exclusions

  • src/createServer.ts - MCP tool registration, request routing, and discovery defaults

  • src/frontmatter.ts - YAML frontmatter handling with gray-matter, preserving formatting and CRLF line endings; executable JavaScript frontmatter stays inert as note content

  • src/filesystem.ts - File operations with path validation

  • src/pathfilter.ts - Directory and file filtering

  • src/search.ts - Note search functionality with content and frontmatter support

  • src/uri.ts - Obsidian URI generation for deep links

  • src/types.ts - TypeScript type definitions

  • scripts/release.mjs - Repository release command with readiness checks and explicit publishing authorization

Contributing

  1. Fork the repository

  2. Create a feature branch: git checkout -b feature-name

  3. Make your changes and add tests

  4. Ensure all tests pass: npm test

  5. Submit a pull request

Maintainers: run npm run release from prepared main to create the GitHub Release that triggers npm publishing. Add -- --yes for approved automation, or -- --check for a read-only preview. See RELEASING.md.

License

MIT

AGENTS.md

Agent Instructions

Project Overview

MCPVault is a Model Context Protocol (MCP) server that provides a universal AI bridge for Obsidian vaults. It enables any MCP-compatible AI assistant (Claude, ChatGPT, Gemini, etc.) to safely read and write notes in Obsidian vaults while preserving YAML frontmatter and enforcing security boundaries.

Commands

# MCP server
npm run build          # Compile TypeScript to dist/
npm test               # Run test suite (Vitest)
npm run test:watch     # Tests in watch mode
npm start /path/vault  # Run server locally with tsx

# Single test
npm test -- path/to/test.test.ts
npm test -- -t "test name pattern"

# Publishing
npm run publish:dry     # Dry run
npm run publish:beta    # Explicit beta publish
# Production: follow RELEASING.md and create a GitHub Release

# Website
npm run website         # Start Astro dev server with Bun (http://localhost:4321)

# MCP Inspector
npx @modelcontextprotocol/inspector npm start /path/to/vault

Architecture

File Structure
server.ts              # MCP server entry point, tool registration, request handlers
src/
  filesystem.ts        # FileSystemService — all file operations with security
  frontmatter.ts       # FrontmatterHandler — YAML parsing via gray-matter
  pathfilter.ts        # PathFilter — security layer for path validation
  search.ts            # SearchService — full-text search with token-optimized output
  uri.ts               # Obsidian URI generation
  types.ts             # All TypeScript interfaces
  *.test.ts            # Co-located test files
website-shibumi/       # Bun + Hono + TSX website serving mcpvault.org (separate package)
Core Components

server.ts — Entry point. Registers 18 MCP tools, handles CLI args (--help, --version, --read-only, vault path), initializes services, routes tool calls. Read-only mode hides mutating tools and rejects direct mutation calls. Auto-trims whitespace from all path arguments. Exits on stdin EOF / SIGTERM / SIGINT (graceful server.close()), otherwise hosts orphan the process (#159).

FileSystemService (src/filesystem.ts): Orchestrates file ops with security. Path resolution validates the nearest existing ancestor for new paths and rejects dangling symlinks. Implements: read, write, patch, delete, move, list, batch read, outline and line-range reads, frontmatter update, tag management, vault stats. Uses native fs/promises. In-place note mutations queue by canonical target within one service instance, then write a hidden sibling, sync it, and rename it over the target. Existing symlinks and POSIX file modes are preserved. Move/delete paths keep their separate symlink behavior; locks do not coordinate other processes.

FrontmatterHandler (src/frontmatter.ts) — Parses/stringifies YAML frontmatter via gray-matter. Validates structure (blocks functions, symbols, invalid types). Preserves original content.

PathFilter (src/pathfilter.ts) — Blocks .obsidian/, .git/, node_modules/, system files, dot files. Note tools allow .md, .markdown, .txt; directory listings may include other file types by filename. Checks path components independently.

SearchService (src/search.ts) — Content and frontmatter search with multi-word matching and BM25 relevance reranking. Returns token-optimized results with minified field names: {p, t, ex, mc, ln, uri}. Max 20 results.

18 MCP Tools
ToolDescription
read_noteRead a single note with frontmatter
get_note_outlineReturn note headings with levels and line numbers
read_note_linesRead an inclusive line range from a note
write_noteCreate or overwrite (supports overwrite, append, prepend modes)
patch_noteEfficient partial update via find-and-replace
list_directoryList files and folders in the vault
delete_noteDelete a note (requires path confirmation)
search_notesFull-text search across vault content
move_noteMove or rename a note
move_fileMove or rename any file (binary-safe, file-only, requires path confirmation)
read_multiple_notesBatch read up to 10 notes
update_frontmatterSafely update YAML frontmatter
get_notes_infoGet metadata without reading content
get_frontmatterExtract frontmatter only
manage_tagsAdd, remove, or list tags
get_vault_statsVault statistics: total notes, folders, size, recent files
list_all_tagsList all tags across the vault with occurrence counts
wiki_linkResolve Obsidian wiki links (incl. path-qualified folder/Note) and return the note
Design Patterns
  • Service layer: Each service has single responsibility, dependency-injected into server.ts, independently testable

  • Security-first: All paths validated through PathFilter, resolvePath() prevents traversal, confirmation required for destructive ops

  • Token optimization: Minified field names by default (fm not frontmatter), optional prettyPrint parameter, compact search format

  • Error handling: Structured results with success boolean, failed batch ops return partial results (ok + err arrays)

Key Implementation Details
  • Paths: Always relative to vault root. Leading slashes stripped. Whitespace trimmed automatically.

  • Frontmatter: Always use FrontmatterHandler for read/write. originalContent field has raw file content. Empty frontmatter = no YAML block.

  • Write modes: overwrite (default), append (content to end, merge frontmatter), prepend (content to beginning, merge frontmatter)

  • Patch: Exact string match including whitespace/newlines. replaceAll: false (default) fails on multiple matches to prevent accidents.

  • Version: Read from package.json at runtime. Used in MCP server init, --version flag, and website nav badge.

Website (Dual Content)

The website-shibumi/ directory is a separate Bun + Hono + TSX package serving mcpvault.org (deployed via shibumi-server, see website-shibumi/compose.yaml). It serves content in two formats that must be kept in sync:

FormatLocationAudience
HTML (rich, interactive)website-shibumi/src/components/Browsers
Markdown (plain text)website-shibumi/public/*.md + llm.txtLLMs and AI agents

When updating content, always update both.

Testing

Vitest with globals enabled, node environment. Test files co-located as *.test.ts.

When writing tests:

  • Test both success and error cases

  • Test path security (traversal, access denied)

  • Test frontmatter parsing edge cases

  • Use Promise.allSettled patterns for batch operations

Security

When modifying file operations:

  • Always validate paths through PathFilter

  • Always use resolvePath() to prevent traversal

  • Never expose system directories or configuration

  • Validate frontmatter before writing

  • Require confirmation for destructive operations

Config Files

  • tsconfig.json — Main TypeScript config (strict mode, ES2022 target, module/moduleResolution nodenext)

  • tsconfig.build.json — Build config (excludes tests, outputs to dist/)

  • vitest.config.ts — Test config (globals, node environment)

Gotchas

  • dist/ is committed. Every src change needs npm run build + commit dist in the SAME change; src-only merges leave dist stale (happened twice: fde15eb engine swap, PR #151).

  • TypeScript toolchain upgrades change dist output (TS7 altered .d.ts.map sourcemaps only) — rebuild + commit dist after any TS bump or the dirty tree blocks automation that requires clean main.

  • Claude Code discovers skills only under .claude/skills/; repo keeps them in skills/. Committed symlink .claude/skills/triage -> ../../skills/triage bridges it — same pattern for any new skill.

  • pathFilter.isAllowed + normalizePath must guard EVERY new tool's path input (PR #146 blocker: readNoteLines skipped them = read .obsidian/ files). Mirror readNote's guard block.

  • Outline/heading parsing must be fence-aware: headings inside code fences do not count. Support backtick and tilde fences with up to three leading spaces, and require closing fences to use the same marker with at least the opening length.

  • Read-only mode is defense-in-depth: mutating tools are both omitted from tools/list and rejected in tools/call. Every new mutating tool must be added to MUTATING_TOOLS in src/createServer.ts and covered by the read-only regression.

  • Root server uses npm + package-lock.json; website uses Bun separately. Root bun.lock becomes stale/misleading; do not recreate.

  • Before merging or publishing ANY website change, deploy a preview, capture screenshots of every affected page, and inspect them for visual regressions. Also smoke-test video playback, posters/static assets, badges/API endpoints, and direct route loads; green build/deployment checks alone are insufficient.

  • MCP SDK v2 uses split @modelcontextprotocol/server, /client, /core, /node packages. @modelcontextprotocol/sdk@latest remains v1.x.

  • Version bump updates website nav/Hero automatically only. Manually sync website-shibumi/src/components/UpdateCallout.tsx, website-shibumi/public/index.md, and CHANGELOG.md.

  • Production npm publishing is triggered by a GitHub Release and runs with provenance. Follow RELEASING.md; do not manually run npm publish for normal production releases, and do not backfill a release for an npm version that already exists.

  • website-shibumi Hono JSX: escapes string children even inside <script> — JSON-LD/inline scripts need raw(); HTML entities in JSX text double-escape, use literal Unicode chars.

  • Bun TSX parser rejects dotted attribute names: Alpine modifiers need spread form {...{"x-on:click.outside": "close()"}}.

  • Hono c.header() in middleware after next() rebuilds Response from .body — drops Bun.file().slice() Range bodies (video 206 becomes full file). Mutate c.res.headers.set() directly.

  • hono serveStatic on Bun: incomplete Range support — video served by dedicated route on Bun.file().slice() (src/routes/video.ts), never serveStatic.

  • website-shibumi container builds from REPO ROOT context (-f website-shibumi/Containerfile .): root package.json must be copied to /package.json or server exits 1 at import (version badge reads it).

  • CSS: animation-fill-mode: forwards keeps finished animation attached forever and kills descendant backdrop-filter even with final transform: none; detach via .fade-in-done { animation: none } on animationend.

239 files · 229 not served here

Advantages

Limitations

Security

Risk level: Medium risk

This brain runs

Hooks (1)

  • .claude/settings.json (SessionStart): if [ -f .plans/next.md ]; then cat .plans/next.md && mv .plans/next.md .plans/next.prev.md; fi

Agent instructions that run or fetch something (36)

  • AGENTS.md: npm run build # Compile TypeScript to dist/
  • AGENTS.md: npm test # Run test suite (Vitest)
  • AGENTS.md: npm run test:watch # Tests in watch mode
  • AGENTS.md: npm start /path/vault # Run server locally with tsx
  • AGENTS.md: npm test -- path/to/test.test.ts
  • AGENTS.md: npm test -- -t "test name pattern"
  • AGENTS.md: npm run publish:dry # Dry run
  • AGENTS.md: npm run publish:beta # Explicit beta publish
  • AGENTS.md: npm run website # Start Astro dev server with Bun (http://localhost:4321)
  • AGENTS.md: npx @modelcontextprotocol/inspector npm start /path/to/vault
  • AGENTS.md: Every src change needs `npm run build` + commit dist in the SAME change;
  • skills/obsidian/SKILL.md: Run a **preflight** before changing anything:
  • skills/obsidian/SKILL.md: `git config user.name` and `git config user.email` are set
  • skills/obsidian/SKILL.md: Try `git pull --rebase` now? · uses the network
  • skills/obsidian/SKILL.md: `git add -A`
  • skills/obsidian/SKILL.md: `git commit -m "vault sync: YYYY-MM-DD HH:mm"` (skip commit if no changes)
  • skills/obsidian/SKILL.md: `git pull --rebase` · uses the network
  • skills/obsidian/SKILL.md: `git push` · uses the network
  • skills/obsidian/SKILL.md: Explain what failed and what user should run next.
  • skills/obsidian/SKILL.md: Run a **preflight** before first CLI use:
  • skills/obsidian/SKILL.md: Otherwise run `obsidian vaults`, match the MCP vault path to a registered vault, and use its registered name.
  • skills/obsidian/SKILL.md: Run `obsidian help` for the full command reference.
  • skills/triage/SKILL.md: One run = gather → load state → triage → fan-out fix → persist → spill.
  • skills/triage/SKILL.md: If missing, run `scripts/triage/bootstrap.sh` first, it scaffolds `state.json`, `inbox.md`, `runs/`, and bootstraps `voice.md` from past comments.
  • skills/triage/SKILL.md: # CI failures since last run
  • skills/triage/SKILL.md: gh run list --status failure --created ">=$SINCE" --json databaseId,name,headSha,conclusion,url
  • skills/triage/SKILL.md: gh run view <id> --log-failed
  • skills/triage/SKILL.md: git log --since="$SINCE" --pretty='%h %s %an'
  • skills/triage/SKILL.md: Only findings with no candidate PR proceed to a new fix, up to the per-run cap in `finding-rules.md`.
  • skills/triage/SKILL.md: git worktree add ../mcpvault-triage-<id> -b triage/<id>
  • skills/triage/SKILL.md: Check the draft against the project skills and existing tests, then run in the worktree:
  • skills/triage/SKILL.md: npm ci && npm test && npm run build
  • skills/triage/SKILL.md: Clean up green worktrees after the PR is open: `git worktree remove ../mcpvault-triage-<id>`.
  • skills/triage/SKILL.md: Update `.triage/state.json`: set `last_run` to now, append an `attempts` entry per touched finding (run date, result, note, pr), update `status`, `last_seen`, and `pr`.
  • skills/triage/SKILL.md: Write the per-run log to `.triage/runs/<date>.md`.
  • skills/triage/SKILL.md: Respect the per-run finding cap;

MCP servers (7)

  • README.md (obsidian): npx @bitbonsai/mcpvault@latest /path/to/your/vault
  • README.md (obsidian): npx @bitbonsai/mcpvault@latest /path/to/your/vault
  • README.md (obsidian): npx @bitbonsai/mcpvault@latest /Users/yourname/Documents/MyVault
  • README.md (obsidian-personal): npx @bitbonsai/mcpvault@latest /Users/yourname/Documents/PersonalVault
  • README.md (obsidian-work): npx @bitbonsai/mcpvault@latest /Users/yourname/Documents/WorkVault
  • README.md (obsidian-read-only): npx @bitbonsai/mcpvault@latest /Users/yourname/Documents/ResearchVault --read-only
  • README.md (obsidian): npx @bitbonsai/mcpvault@latest /path/to/your/vault

Install scripts (1)

  • scripts/triage/bootstrap.sh: sh scripts/triage/bootstrap.sh
  • Medium risk: runs-mcp-server-unpinned-runner (README.md:50)
  • Medium risk: runs-mcp-server-unpinned-runner (README.md:63)
  • Medium risk: runs-mcp-server-unpinned-runner (README.md:203)
  • Medium risk: runs-mcp-server-unpinned-runner (README.md:219)
  • Medium risk: runs-mcp-server-unpinned-runner (README.md:219)
  • Medium risk: runs-mcp-server-unpinned-runner (README.md:244)
  • Medium risk: runs-mcp-server-unpinned-runner (README.md:302)
  • Medium risk: runs-instruction-instruction-network (skills/obsidian/SKILL.md:94)
  • Medium risk: runs-instruction-instruction-network (skills/obsidian/SKILL.md:99)
  • Medium risk: runs-instruction-instruction-network (skills/obsidian/SKILL.md:100)
  • Low risk: scripts-present (scripts/triage/bootstrap.sh)

Attribution and licence

First committed by
GitHub avatar of bitbonsaibitbonsai
Declared authors
  • bitbonsai (declared in package.json)
Publisher
Mauricio Wolff (Community)
Source
bitbonsai/mcpvault · commit 2e9deb9
Licence
MIT License (files served here)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Contributors
bitbonsai, mvanhorn

AutoGineer is not affiliated with or endorsed by bitbonsai.

Install from source

229 of its files are not served here, so there is no ZIP. bitbonsai/mcpvault at 2e9deb9