obsidian-mcp

obsidian-mcp

Remote MCP server that gives AI agents read/write access to your Obsidian vaults, supporting both local desktop vaults and headless mode.

Category
访问服务器

README

obsidian-mcp

Remote MCP server that gives AI agents read/write access to your Obsidian vaults. On personal machines it mounts the real local vault folders used by the Obsidian app; on server-style machines without local desktop vaults it falls back to syncing with obsidian-headless.

Installation

curl -fsSL https://raw.githubusercontent.com/hanzpo/obsidian-mcp/main/install.sh | bash

That installs the app, runs interactive setup, and prints a remote MCP config. On personal machines it uses your real desktop vaults directly and lets you choose either a temporary Cloudflare URL or a persistent Cloudflare Tunnel hostname.

Which Mode Should I Use?

  • Laptop or desktop with the Obsidian app already installed: use local.
  • VPS, home server, or separate always-on machine: use production.
  • If local desktop vaults are detected, obsidian-headless is blocked on that machine to avoid sync conflicts.

Modes

Mode Best for Remote URL URL stability Infra burden Survives reboot by default
Local Running on your own machine with the Obsidian app Yes Temporary or stable, depending on tunnel choice Medium No
Production Long-term self-hosting Yes Stable domain Higher Yes

1. Local

  • Uses local desktop vaults directly.
  • Lets you choose a temporary trycloudflare.com URL or a persistent Cloudflare Tunnel hostname.
  • Persistent local mode requires a Cloudflare-managed domain.
  • Best for running on your own machine without obsidian-headless.

Manage local-mode processes:

npm run setup
npm run status
npm run logs
npm run stop

2. Production

curl -fsSL https://raw.githubusercontent.com/hanzpo/obsidian-mcp/main/install.sh | sudo bash
  • Uses obsidian-headless, Caddy, and system services.
  • Refuses to run on machines with local desktop vaults.
  • Best for a stable endpoint on a separate always-on machine.
  • If you use your own domain, point its A record or AAAA record at the server's public IP.
  • If you use sslip.io, no DNS changes are needed. The setup flow prefers an IPv4-based hostname when available because it is more widely reachable from clients.

Prerequisites

  • a machine that can stay online while you use the MCP server
  • for server or headless mode: an Obsidian Sync subscription and a machine without local Obsidian desktop vaults
  • for local mode on your own machine: the Obsidian app installed with at least one local vault configured
  • for persistent local mode: a Cloudflare-managed domain

Where Files Live

  • Install directory:
    • user install default: ~/.local/share/obsidian-mcp
    • production install default: /opt/obsidian-mcp
  • Local generated config for this install: .env
  • Local runtime state for this install: .obsidian-mcp/
    • PID files
    • logs
    • active mode marker
    • mounted desktop-vault map
  • Headless sync mirrors: vaults/
    • only used when the machine is running obsidian-headless
  • Real desktop vault folders:
    • not copied into this repo
    • not owned by this app
    • mounted directly from the paths already managed by the Obsidian app
  • ~/.obsidian-headless
    • owned by obsidian-headless
    • stores its auth/local sync state
    • not removed by npm run uninstall
  • Cloudflare Tunnel resources for local mode
    • named tunnel and DNS route live in your Cloudflare account
    • not removed by npm run uninstall

Manual Setup

If you want to install things yourself instead of using install.sh:

  1. Clone and enter the repo:
git clone https://github.com/hanzpo/obsidian-mcp.git
cd obsidian-mcp
  1. Install dependencies:

Local mode also needs:

brew install cloudflared              # macOS
# or install cloudflared another way on Linux

Headless/server mode also needs:

npm install -g obsidian-headless

Production also needs:

# install Caddy
  1. Run setup:
npm run setup

Client Config

Both modes print a ready-to-paste MCP config at the end. It looks like this:

{
  "mcpServers": {
    "obsidian": {
      "type": "streamableHttp",
      "url": "https://your-endpoint.example/mcp",
      "headers": {
        "Authorization": "Bearer <your-api-key>"
      }
    }
  }
}

Tools

Tool Description
read_note Read a note's content and metadata
read_notes Batch read up to 10 notes
create_note Create a note with optional frontmatter
edit_note Append, prepend, or find-and-replace
delete_note Delete a note (requires confirmation)
move_note Move or rename a note
list_directory Browse vault structure
search_notes Full-text search with BM25 ranking
get_frontmatter Read YAML frontmatter as JSON
update_frontmatter Merge or remove frontmatter fields
manage_tags Add, remove, or list tags
get_vault_stats Vault statistics and recent files
get_links Outgoing wikilinks and backlinks

Path model:

  • In single-vault mode, tool paths are relative to that vault root.
  • In mounted desktop mode, list_directory with an empty path shows the top-level vault aliases first, and other tool paths should be prefixed with one of those aliases such as work/... or personal/....

Commands

Start with:

npm run help

Recommended commands:

Command What it does
npm run setup Interactive setup. Choose local or production
npm run status Show status for the active mode
npm run logs Tail logs for the active mode
npm run stop Stop the active mode
npm run restart Restart the active mode
npm run update Refresh repo files and rerun setup for the active mode
npm run build Compile TypeScript
npm run check Type-check, lint, and test
npm run keygen Generate or rotate the API key
npm run uninstall Safely remove obsidian-mcp setup from this machine

Active Mode

  • npm run setup is the only setup entrypoint.
  • During setup, you choose local or production.
  • That choice is remembered in .obsidian-mcp/mode.
  • After that, npm run status, logs, stop, restart, and update act on the active mode automatically.
  • If no active mode is detected, those commands tell you to run npm run setup first.

Auth Notes

  • The printed client config uses Authorization: Bearer <api-key>, which is the preferred option.
  • For compatibility with some clients and transports, the server also accepts X-API-Key, ?api_key=..., and ?token=....
  • Temporary local mode uses trycloudflare.com, so the URL can change on restart.
  • Persistent local mode uses a named Cloudflare Tunnel hostname, so the URL stays the same, but the machine and tunnel still need to be running.

Troubleshooting

Local tunnel did not come up

npm run logs

Look at .obsidian-mcp/logs/cloudflared.log.

Sync is not working

ob sync-list-remote
npm run logs

If ob login keeps asking for credentials, run it again and rerun setup.

Production HTTPS/certificate errors

If using sslip.io, make sure ports 80 and 443 are open. Caddy needs port 80 for the ACME challenge.

ufw allow 80/tcp
ufw allow 443/tcp

Re-running setup

setup.sh is safe to re-run. In local mode it restarts the background MCP and tunnel processes. In production it refreshes services and configuration.

What npm run update does

  • refreshes the repo files
  • uses git pull for git checkouts
  • falls back to downloading the latest repo archive for installer-style checkouts
  • reruns setup for the active mode
  • local stays local, production stays production

Start over safely

npm run uninstall

That removes obsidian-mcp's generated config and services from this machine after an explicit confirmation prompt, but intentionally preserves:

  • your real Obsidian desktop vault folders
  • synced vault contents under vaults/
  • ~/.obsidian-headless
  • Cloudflare Tunnel resources such as named tunnels and DNS routes
  • remote Obsidian Sync state

Uninstall vs Purge

  • npm run uninstall is a safe uninstall.
  • It removes this app's generated config, runtime files, and installed services from this machine.
  • It does not delete your notes, your desktop vault folders, your headless state, your Cloudflare Tunnel resources, or your remote Obsidian Sync state.
  • If you want a real purge of synced mirrors, ~/.obsidian-headless, or Cloudflare tunnel resources, do that manually after uninstall.

Recovery

  • If something looks broken, start with npm run status and npm run logs.
  • If you changed configuration or updated the repo, run npm run update.
  • If you want to choose the mode again or rebuild local state, rerun npm run setup.
  • If you want to remove the app cleanly without touching note state, run npm run uninstall.

Development

npm ci
npm run dev
npm test
npm run check

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选