Obsidian MCP Server

Obsidian MCP Server

Enables AI assistants to manage Obsidian vaults programmatically with 28 tools for reading, writing, editing, and analyzing notes.

Category
访问服务器

README

Obsidian MCP Server

This project is a high-performance Model Context Protocol server for Obsidian vaults. It gives AI assistants like Claude, Gemini, and Cursor ability to manage your Obsidian vault programmatically. It provides 28 tools organized into categories: read, write, edit, frontmatter, tags, links, graph analysis, and organization.

Key design principles:

  • Simple setup. Works directly with vault files on disk. No Obsidian plugins, no REST API, no Obsidian running in the background.
  • Performance. In-memory cache + real-time file watching (watchdog) enables speedy 0(1) note lookups.
  • Flexible. 28 tools covering reading, writing, line-by-line editing, bulk editing, graph analysis, and more.
  • Safety. Path traversal protection, atomic bulk operations with rollback, comprehensive test suite (139 tests).

This server is compatible with any MCP client: Claude, Gemini, Cursor, or any applications that support the MCP protocol.

Tools

Category Tool Description
Read list_notes List all notes in the vault (paginated)
Read read_note_by_name Read a note by name (no .md extension needed)
Read search_notes Full-text search with regex support, path filtering, and pagination
Read get_vault_stats Vault-wide statistics (note count, total links, folder breakdown)
Read recent_notes Notes modified within the last N days
Write create_note Create a new note, optionally in a subfolder
Write update_note Replace a note's entire content
Write append_to_note Append content to the end of a note
Write delete_note Delete a note (requires confirmation flag)
Edit read_note_lines Read a note with line numbers (supports ranges)
Edit insert_lines Insert content after a specific line
Edit replace_lines Replace a range of lines
Edit delete_lines Delete a range of lines
Edit bulk_edit Apply multiple edits across multiple notes atomically, with automatic rollback on failure
Frontmatter get_frontmatter Read all YAML frontmatter or a specific property
Frontmatter set_frontmatter Set a frontmatter property (auto-detects types: lists, ints, bools)
Frontmatter delete_frontmatter Remove a frontmatter property
Tags list_tags All tags across the vault with occurrence counts (frontmatter + inline #hashtags)
Tags search_by_tag Find notes by tag (case-insensitive)
Links get_note_links Extract all WikiLinks from a note
Links validate_wikilinks Check which links in a note point to existing vs. missing notes
Graph Analysis vault_graph Vault-wide link structure summary, or per-note analysis with related note suggestions
Graph Analysis find_orphans Notes with zero connections (no incoming or outgoing links)
Graph Analysis find_hubs Most connected notes, ranked by total link count
Graph Analysis find_backlinks All notes linking to a given note
Organization move_note Move a note to a different folder with automatic backlink updates across the vault
Organization find_folder Search for folders by name or partial match
Organization create_folder Create a new folder

Setup

Prerequisites

  • Python 3.10+
  • An Obsidian vault

Install

Clone the repo and set up a Python virtual environment:

git clone https://github.com/faisalhossainnyc/obsidian-mcp-server.git
cd obsidian-mcp-server
python -m venv venv

Activate the virtual environment:

  • macOS/Linux: source venv/bin/activate
  • Windows: venv\Scripts\activate

Then install dependencies:

pip install -r requirements.txt

Configure

Copy the example environment file and set your vault path:

cp .env.example .env

Edit .env and set VAULT_PATH to your vault directory (replace you with your actual username and adjust the path as needed):

  • macOS: VAULT_PATH="/Users/you/Documents/My Obsidian Vault"
  • Linux: VAULT_PATH="/home/you/Documents/My Obsidian Vault"
  • Windows: VAULT_PATH="C:\Users\you\Documents\My Obsidian Vault"

Start the Server

All MCP clients (Claude Desktop, Cursor, Gemini CLI, etc.) launch the server process for you based on the config below, so you don't need to start it manually. The command field in the config tells the client how to start it.

If you want to run the server manually (e.g., to test it or debug):

source venv/bin/activate        # Windows: venv\Scripts\activate
python -m src.server

You should see output confirming the vault cache has loaded and the server is listening.

Connect to an MCP Client

This server uses the standard mcpServers configuration format supported by all major MCP clients. Add the following to your client's config file, replacing the three placeholders with your actual paths:

  • command — full path to the Python binary inside your venv (e.g. /Users/you/Projects/obsidian-mcp-server/venv/bin/python on macOS/Linux, or C:\Projects\obsidian-mcp-server\venv\Scripts\python.exe on Windows)
  • cwd — full path to the cloned repo folder (e.g. /Users/you/Projects/obsidian-mcp-server)
  • VAULT_PATH — full path to your Obsidian vault folder
{
  "mcpServers": {
    "obsidian": {
      "command": "/path/to/obsidian-mcp-server/venv/bin/python",
      "args": ["-m", "src.server"],
      "cwd": "/path/to/obsidian-mcp-server",
      "env": {
        "VAULT_PATH": "/path/to/your/vault"
      }
    }
  }
}

Find your config file based on your client:

Client Config File
Claude Desktop (macOS) ~/Library/Application Support/Claude/claude_desktop_config.json
Claude Desktop (Linux) ~/.config/Claude/claude_desktop_config.json
Claude Desktop (Windows) %APPDATA%\Claude\claude_desktop_config.json
Gemini CLI ~/.gemini/settings.json
Cursor .cursor/mcp.json in your project root
Claude Code ~/.claude/claude_code_config.json

This server implements the Model Context Protocol (MCP), an open standard adopted by Claude, Gemini CLI, ChatGPT, Cursor, VS Code, and more. If your client isn't listed above, check its documentation for the MCP config file location. The JSON format above should work universally.

Architecture

src/
├── server.py          # Entry point — initializes FastMCP + vault cache, registers tools
├── cache.py           # VaultCache: in-memory index with watchdog file watcher (O(1) lookups)
├── utils.py           # Shared utilities: safe_resolve(), read_note(), extract_wikilinks()
└── tools/
    ├── read.py        # 5 tools — list, read, search, stats, recent
    ├── write.py       # 4 tools — create, update, append, delete
    ├── edit.py        # 5 tools — line-level editing with bulk edit + rollback
    ├── frontmatter.py # 3 tools — YAML frontmatter get/set/delete
    ├── tags.py        # 2 tools — tag listing and search
    ├── links.py       # 2 tools — WikiLink extraction and validation
    ├── graph.py       # 4 tools — vault graph analysis (orphans, hubs, backlinks)
    ├── move.py        # 1 tool  — move with backlink updates
    └── folders.py     # 2 tools — folder search and creation

On startup VaultCache builds an in-memory {name → Path} index of every .md file in the vault. A watchdog file observer keeps this index in sync as files are created, deleted, moved, or renamed. every tool call does an O(1) dict lookup instead of scanning the filesystem.

All path-accepting tools use safe_resolve() to prevent path traversal attacks (e.g., ../../etc/passwd is rejected).

The bulk_edit tool reads all target files into memory before applying changes. If any write fails mid-operation, it restores every file from the in-memory backup with no partial writes.

Running Tests

./run_tests.sh

Or directly:

PYTHONPATH=. python -m pytest tests/ -v

The test suite uses a temporary vault fixture that rebuilds from scratch before each test, so tests are fully isolated and don't touch your real vault.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选