obsidian-mcp

obsidian-mcp

A self-hosted MCP server with a management UI for reading, searching, editing, and organizing notes in an Obsidian vault, with OAuth and token authentication, git snapshots, and optional Obsidian Sync.

Category
访问服务器

README

obsidian-mcp

A self-hosted MCP server + management UI for your Obsidian vault. One container gives you:

  • An MCP server (Streamable HTTP) with 10 carefully designed tools for reading, searching, editing, and organizing notes — built for Claude Desktop, claude.ai, and Claude Code.
  • A passkey-protected management UI (passkeys only, no passwords) for tokens, OAuth connections, sync, and snapshot history.
  • OAuth 2.1 + Dynamic Client Registration so Claude Desktop/claude.ai connect with just a URL, plus named bearer tokens for Claude Code and other clients.
  • Optional Obsidian Sync via the official obsidian-headless client (ob sync --continuous), supervised by the server and configured entirely from the web UI — including end-to-end-encrypted vaults. Requires an Obsidian Sync subscription; skip it and bring your own sync (Syncthing, git, nothing).
  • Automatic git snapshots of the vault (debounced after every MCP mutation, before destructive operations, hourly, and at shutdown) stored in a bare repo outside the vault. Browse and restore from the UI.

Obsidian MCP management UI

All state lives in a single bind-mounted ./data directory:

data/
├── Vault/               your Obsidian vault
├── db/app.db            server state (passkeys, tokens, OAuth grants)
├── obsidian-headless/   ob CLI auth + sync state
└── snapshots/vault.git  bare git repo with vault history

Quick start

The server must be reachable over HTTPS (passkeys and Claude connectors require it). The recommended setup is a tunnel — no ports exposed at home:

mkdir obsidian-mcp && cd obsidian-mcp
curl -fsSLo docker-compose.yml https://raw.githubusercontent.com/jclement/obsidian-mcp/main/deploy/docker-compose.gatecrash.yml
# create .env with tunnel credentials (see comments in the compose file)
docker compose up -d
docker compose logs app        # ← copy the FIRST-RUN SETUP token

Just want to try it locally (no tunnel, no published image)? From a checkout:

docker compose -f deploy/docker-compose.local.yml up --build
docker compose -f deploy/docker-compose.local.yml logs app   # ← setup token
# open http://localhost:3000/setup

Open https://your-host/setup, paste the token, and register a passkey. That passkey is now the only way into the management UI; add more from the Passkeys page.

Connect Claude Desktop / claude.ai

Settings → Connectors → Add custom connector → https://your-host/mcp. Claude discovers the OAuth endpoints, registers itself, and sends you to your server to approve with your passkey. Done.

Connect Claude Code

Create a token in the UI (Tokens → name it → copy once), then:

claude mcp add --transport http obsidian https://your-host/mcp \
  --header "Authorization: Bearer obmcp_..."

Connect Obsidian Sync (optional)

UI → Sync → sign in with your Obsidian account (+2FA), pick a remote vault, optionally provide the end-to-end encryption password. The server runs ob sync --continuous, restarts it with backoff if it dies, and shows a live log. Credentials are passed straight to the ob CLI and never stored by this server.

The MCP tools

Tool What it does
vault_info Orientation: counts, daily-note config, templates, recent notes
browse_vault Folder listing or compact tree
search_vault Unified content + filename + tag search with highlighted snippets, filters, pagination
read_note Frontmatter + body + content hash; outline/section modes for huge notes; batch reads; images render inline
create_note New notes, structured frontmatter, template instantiation ({{date}}, {{time}}, {{title}})
edit_note Surgical edits: exact-match replace, append (under a heading), section replace, frontmatter set/remove — atomic, hash-guarded
manage_note Move/copy/delete with automatic backlink rewriting; deletes go to .trash/
get_links Backlinks (with context), outgoing links, embeds, unresolved links
list_tags All tags (frontmatter + inline, nested) with counts
daily_note Read/append today's (or any date's) daily note honoring the vault's own settings and template

Design notes:

  • Safe concurrent editing. The vault can change underneath the server (Obsidian Sync). Every read returns a content hash; edits verify it and fail with a retryable error if the note changed. Whole-content replacement requires the hash. Writes are atomic (temp file + rename) and serialized per note.
  • Obsidian-native behavior. Wikilink resolution, daily-note paths, templates, and link rewriting all honor the vault's .obsidian/ settings. The server never writes into .obsidian/.
  • Recoverable by design. Deletes are soft (.trash/), every mutation is git-snapshotted, and destructive ops take a synchronous pre-snapshot.

Configuration

Env var Default Purpose
PUBLIC_URL — (optional) Pin the external URL. Leave unset to auto-derive it from your reverse proxy's X-Forwarded-Proto/X-Forwarded-Host per request (the common case behind a single tunnel). Set it only when you want to hard-pin the origin or run behind multiple/untrusted proxies.
PORT 3000 Listen port
DATA_DIR /data Root for all persistent state
VAULT_DIR $DATA_DIR/Vault Vault location
SYNC_AUTOSTART true Resume ob sync on boot if previously enabled
OB_KILL_GRACE_MS 5000 SIGTERM→SIGKILL grace for ob (it ignores SIGTERM)
SNAPSHOT_DEBOUNCE_MS 30000 Snapshot debounce after mutations
SNAPSHOT_INTERVAL_MS 3600000 Periodic dirty-check snapshot
AUTH_RESET Set to 1 to wipe passkeys/sessions and re-enter setup (e.g. after a hostname change)
LOG_LEVEL info debug / info / warn / error

Security model

  • Management UI: passkeys only, user verification required, discoverable credentials (one-tap). Sessions are DB-backed, HttpOnly, SameSite=Lax cookies.
  • First-run trust: /setup requires a token printed to server logs (proof of box ownership); the page 404s once a passkey exists.
  • Hostname handling: when PUBLIC_URL is unset the origin/rpID are derived from the proxy's forwarded headers, and the WebAuthn rpID is pinned at first-passkey setup — a later request arriving with a different host is rejected (use AUTH_RESET=1 to re-key if the hostname legitimately changes). WebAuthn's crypto binds each credential to the browser-signed origin regardless, so a forged forwarded header cannot impersonate your host.
  • MCP: OAuth 2.1 (PKCE S256 mandatory, RFC 8414/9728 metadata, RFC 7591 DCR, refresh rotation with reuse detection) or static bearer tokens. All tokens stored as SHA-256 hashes, shown once, revocable from the UI; revocation also kills live streams.
  • Host-header guard (DNS rebinding), Origin checks on /mcp, CSRF protection on the UI, rate-limited auth endpoints.
  • data/db/app.db contains only hashes and public keys — safe to back up.

Development

Requires mise (pins bun + node) and git.

mise install
bun install
mise run dev          # server with hot reload + tailwind watch → http://localhost:3000
mise run test         # bun test (133 tests)
mise run typecheck
mise run docker:build
mise run ob:install   # optional: real obsidian-headless for local sync testing

Local dev uses the same ./data layout as production and passkeys work on http://localhost.

Recovery cheatsheet

# full vault history
git --git-dir data/snapshots/vault.git --work-tree data/Vault log --oneline

# restore everything to a snapshot
git --git-dir data/snapshots/vault.git --work-tree data/Vault checkout <sha> -- .

# lost your passkey?
AUTH_RESET=1 docker compose up -d   # re-enters setup mode; unset afterwards

License

MIT © Jeff Clement

推荐服务器

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

官方
精选