fenced-obsidian-sync-mcp
A deny-by-default MCP server for Obsidian vaults where operators declare exact capabilities (list, read, create, etc.) scoped by path globs; everything not permitted is impossible by construction as disallowed tools are never registered.
README
fenced-obsidian-sync-mcp
A deny-by-default, finely fenced MCP server
over an Obsidian vault. The operator declares exactly which capabilities (list,
read, create, …) an agent gets, each scoped by path globs — and everything
else is impossible by construction, not merely guarded.
Other Obsidian MCP servers hand an agent broad read/write/search/delete. Here
the fence is the product: you can run it so an agent may only create notes
under Inbox/, or only see note titles, or touch nothing at all — and prove
the rest is impossible because the tools are never registered.
Full design brief:
docs/SPEC.md. The "Core principles (security invariants)" there are requirements, and each is backed by a test.
Install
pip install -e ".[http,dev]" # http extra for remote serving; dev for tests
Requires Python ≥ 3.10.
Run
fenced-obsidian-sync-mcp --config examples/create-only.yaml
# or
python -m fenced_obsidian_sync_mcp --config examples/create-only.yaml
By default this speaks stdio (for a local MCP client). Set
transport.type: http for remote serving (see below).
The three canonical postures
Each is a complete, runnable config (full files in examples/).
1. Deny-all — a dark vault
The server runs but exposes no tools at all.
mode: local
vault: /path/to/your/vault
capabilities: {}
2. Create-only — file, never read
The agent can drop new notes into Inbox/ and do nothing else. No
read/list/update/delete tool is registered. Collisions never overwrite.
mode: local
vault: /path/to/your/vault
collision: suffix # fail | suffix
capabilities:
create:
enabled: true
allow: ["Inbox/**"]
3. Titles-only — see names, not bodies
The agent learns which notes exist (to suggest links) but no registered tool
can open their contents. read and read_metadata are absent.
mode: local
vault: /path/to/your/vault
capabilities:
list:
enabled: true
allow: ["**/*.md"]
deny: ["Private/**", "Journal/**"]
Capabilities
Every capability is off by default and independently path-scoped. Enabling one registers exactly one tool; disabling it means the tool is absent from the MCP tool list.
| Capability | Tool | Exposes | Opens file contents? |
|---|---|---|---|
list |
list_notes |
enumerate paths / filenames | no — readdir only |
read_metadata |
read_metadata |
frontmatter, tags, stat | frontmatter only |
read |
read_note |
full note contents | yes |
search |
search_notes |
content search (implies read) |
yes |
create |
create_note |
new files only, never overwrite | no |
update |
update_note |
modify / append existing files | n/a |
delete |
delete_note |
remove files | n/a |
move |
move_note |
rename / relocate, never overwrite | n/a |
search implies read: enabling search without read is a config error,
because returning snippets while read is off would be a content oracle.
Glob semantics
Globs use wcmatch with GLOBSTAR,
evaluated against vault-relative POSIX paths:
**spans directories (**/*.mdmatches at any depth);*matches within a single segment.- Case-sensitive.
- Dotfiles are not matched unless a pattern names the leading dot, so
.obsidian/stays out of**/*.md. denyalways beatsallowon every capability.
Modes
mode: local— pointvaultat a directory you already keep current (Syncthing, iCloud, git, or nothing). No sync subprocess, noobsidian-headlessdependency. Works anywhere, including a phone via Termux.mode: sync—vaultis your remote Obsidian Sync vault name andvault_diris the local directory the officialobsidian-headlessclient (ob sync --continuous) mirrors into. The server supervises that process.
The fence is identical in both modes; only how the directory stays current differs.
⚠️ Sync-mode write warning: in
syncmode,update/delete/movepropagate to every device on your Obsidian Sync. Create-only is the conflict-free default; enable writes deliberately.
Transports
- stdio (default) — for a local MCP client.
- HTTP (
transport.type: http) — streamable-http behind a bearer token (required) and TLS. Terminate TLS in-process (transport.tls.certfile/keyfile) or at a reverse proxy such as Caddy. Full OAuth is a future extension; bearer + TLS is the supported remote posture today.
transport:
type: http
host: 0.0.0.0
port: 8080
auth: { bearer_token: "a-long-random-secret" }
tls: { certfile: /etc/ssl/certs/server.crt, keyfile: /etc/ssl/private/server.key }
Audit log
Optional structured JSONL of every allowed and denied call (capability, path, decision, and — for denials — an internal reason never shown to the client):
audit:
enabled: true
path: /var/log/fenced-obsidian-sync-mcp/audit.jsonl # omit -> stderr
Deploy with Docker (mode: sync)
The repo ships a Dockerfile, docker-compose.yml, and Makefile for running
mode: sync behind a reverse proxy (e.g. the central Caddy on a Hetzner box).
The image bundles both the Python server and the official obsidian-headless
(ob) client; TLS is terminated at the proxy, so the container speaks plain
HTTP on 0.0.0.0:4012 and the bearer token comes from $FOSM_BEARER_TOKEN.
# 1. one-time obsidian-headless auth (persists in named volumes)
make ob-login # interactive: email, password, MFA
make ob-setup VAULT="My Vault" # links the remote vault into /vault
# 2. config + secret
cp examples/config.docker-sync.yaml config.yaml # edit vault name + globs
cp .env.example .env && echo "FOSM_BEARER_TOKEN=$(openssl rand -hex 32)" > .env
# 3. run
make deploy # docker compose up -d --build
bearer_token_env: FOSM_BEARER_TOKEN in the config sources the token from the
container environment, keeping the secret out of the config file and git. Point
your reverse proxy at 172.18.0.1:4012 (the Docker bridge gateway) and, because
MCP streamable-http uses SSE, disable proxy buffering — in Caddy:
reverse_proxy 172.18.0.1:4012 { flush_interval -1 }.
Security invariants
These are guaranteed and tested (tests/):
- Deny by default — a disabled capability's tool is not registered.
- Capabilities are independent — knowing a note exists (
list) is separate from its metadata (read_metadata) is separate from its body (read). - Path confinement —
.., absolute paths, escaping symlinks, and percent-/double-encoded separators are all rejected. - No silent overwrite —
createusesO_EXCL; collisionsfailorsuffix. - Glob-scoped, deny-wins —
denyalways beatsallow. - No existence oracle — denied paths return a uniform
not permitted. - Auditable — optional structured log; a small, readable codebase.
Development
pip install -e ".[http,dev]"
pytest # full invariant + acceptance suite
ruff check .
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。