Obsidian MCP Wrapper
Enables Claude Desktop to securely search and retrieve knowledge from an Obsidian vault through a stateless MCP interface, with progressive disclosure and gated write capabilities.
README
Obsidian MCP Wrapper
Obsidian MCP Wrapper is a session-stateless MCP retrieval system for an agency Obsidian vault. It gives Claude Desktop users controlled access to indexed Markdown knowledge without giving the model direct, unbounded filesystem access or unsupervised write privileges.
The runtime has two layers:
pf-mcp: a lightweight STDIO MCP shim that runs on each Claude Desktop workstation.pf-index: a shared LAN/VPN retrieval service that owns the vault index, signed handles, bearer-token authentication, rate limits, write locking, and the audit log.
The design goal is progressive disclosure: search returns compact snippets and signed section handles first, then Claude expands only the context it needs.
Highlights
- Standard-library core runtime for the default HTTP server path.
- Optional FastAPI/uvicorn ASGI boundary.
- SQLite FTS5 lexical search over immutable vault index epochs.
- HMAC-signed section handles that resolve against retained snapshots.
- Manifest-only filesystem access for indexed Markdown paths.
- Human-gated append writes into client, provider, carrier, and operational notes.
- Autonomous AI notes routed to a rotated capture inbox by default.
- File locking and SQLite audit records for write operations.
- Sanitized error envelopes that avoid leaking paths, tokens, URLs, or tracebacks into Claude.
- Quick-start, deployment, teardown, and nightly-refresh scripts.
Runtime Topology
Claude Desktop
-> STDIO MCP JSON-RPC
-> pf-mcp workstation shim
-> HTTP POST /tools/<tool_name>
-> pf-index LAN/VPN service
-> Obsidian_Vault Markdown snapshots and .pf_index artifacts
pf-index consumes Markdown and derived index artifacts. It does not need the
source DuckDB database at runtime.
Repository Layout
.
|-- Docs/
| |-- ARCHITECTURE.md
| |-- DEPLOYMENT.md
| |-- QUICKSTART.md
| `-- MCP_WRAPPER_MASTER_PROMPT.md
|-- config/
| |-- claude_desktop_config.example.json
| |-- deployment_manifest.example.json
| |-- pf-index.example.toml
| `-- pf-mcp.env.example
|-- pf_index/
| |-- api/ HTTP boundaries
| |-- core/ indexing, retrieval, crypto, paths, writes
| `-- config.py TOML and environment configuration
|-- pf_mcp/
| `-- main.py STDIO MCP shim
|-- scripts/
| |-- build_index.py
| |-- run_pf_index.py
| |-- quickstart.sh
| |-- quickstart_teardown.sh
| |-- nightly_refresh.sh
| |-- deploy_interactive.sh
| `-- deploy_teardown.sh
|-- tests/
|-- pyproject.toml
`-- requirements.lock
MCP Tools
The shim exposes these tools to Claude:
| Tool | Purpose |
|---|---|
vault_search |
Search indexed vault sections and return snippets with signed handles. |
strategy_search |
Search strategy, advisory, sales, renewal, and operating-system material. |
find_note |
Find likely note paths by query. |
get_note_summary |
Return a bounded summary/outline for one note path. |
get_entity_context |
Entity-oriented search wrapper. |
search_tables |
Search indexed table-like content. |
read_section |
Resolve one signed handle into a larger section excerpt. |
expand_context |
Resolve several signed handles within a token budget. |
get_full_profile |
Retrieve full materialized context for one known client or provider. |
advisory_context |
Combine profile evidence with strategy context for planning questions. |
vault_stats |
Return index and vault statistics. |
append_human_note |
Append a factual note through the gated write pipeline. |
remove_note |
Remove a specific generated note entry by note id. |
Security Model
Important boundaries:
- The MCP shim validates argument shapes and hard limits before forwarding to the LAN service.
- The LAN service requires
Authorization: Bearer <token>. - Tokens map to user ids for audit and idempotency.
- Runtime reads are limited to paths listed in the active index manifest.
- Path validation rejects absolute paths, traversal, null bytes, URL schemes, Windows drive paths, and backslash paths.
- Section handles contain path, line range, content hash, file hash, vault id, and index epoch, then are signed with HMAC-SHA256.
- Old handles resolve against retained immutable snapshots, not changed live vault files.
- Autonomous writes are redirected to the configured capture inbox unless the human explicitly directs a write to a specific note.
- Write operations are append-only/gated, locked, audited, and bounded by configured note length limits.
Requirements
- Python 3.11 or newer
- Markdown Obsidian vault directory
- HMAC secret for handle signing
- One or more bearer tokens for users
The default pf_index.api.server HTTP boundary uses only the Python standard
library. Optional FastAPI dependencies are listed in requirements.lock:
python -m pip install -r requirements.lock
Quick Start
For a complete local smoke test, use the maintained guide:
sed -n '1,240p' Docs/QUICKSTART.md
The short version:
export PF_APP_DIR="$PWD"
export PF_DEMO_ROOT=/tmp/pf-mcp-demo
export PF_VAULT_ROOT="$PF_DEMO_ROOT/Obsidian_Vault"
export PF_INDEX_ROOT="$PF_DEMO_ROOT/.pf_index"
export PF_AUDIT_DB="$PF_INDEX_ROOT/write_audit.sqlite"
export PF_INDEX_HMAC_SECRET="local-demo-secret-change-me"
export PF_INDEX_TOKEN="local-demo-token"
export PF_INDEX_CONFIG="$PF_DEMO_ROOT/pf-index.toml"
Create a small test vault and config as shown in Docs/QUICKSTART.md, then
build an index:
PYTHONPATH="$PF_APP_DIR" python -m scripts.build_index \
--config "$PF_INDEX_CONFIG" \
--epoch 2026-06-08T120000Z
Run the stdlib HTTP server:
PYTHONPATH="$PF_APP_DIR" \
PF_INDEX_HMAC_SECRET="$PF_INDEX_HMAC_SECRET" \
python -m pf_index.api.server \
--host 127.0.0.1 \
--port 8765 \
--config "$PF_INDEX_CONFIG"
Search through the API:
curl -s \
-H "Authorization: Bearer $PF_INDEX_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query":"Coverage","max_results":3,"max_tokens":1000}' \
http://127.0.0.1:8765/tools/vault_search \
| python -m json.tool
List MCP tools through the shim:
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' \
| PYTHONPATH="$PF_APP_DIR" \
PF_INDEX_URL="http://127.0.0.1:8765" \
PF_INDEX_TOKEN="$PF_INDEX_TOKEN" \
python -m pf_mcp.main \
| python -m json.tool
Or run the automated path:
bash scripts/quickstart.sh
Tear down demo artifacts:
bash scripts/quickstart_teardown.sh
Configuration
Server-side config lives in TOML. Start from:
cp config/pf-index.example.toml pf-index.toml
Key sections:
[paths]:vault_root,index_root, andaudit_db[limits]: result, token, note length, lock timeout, and concurrency limits[security]:vault_idand HMAC secret source[tokens]: bearer token to user id map[inbox]: rotated inbox path for autonomous captures[retention]: retained immutable index epochs
Workstation shim config is environment-based. Start from:
cp config/pf-mcp.env.example pf-mcp.env
Claude Desktop config example:
cat config/claude_desktop_config.example.json
Indexing
Build an immutable index epoch:
PYTHONPATH="$PWD" python -m scripts.build_index --config /path/to/pf-index.toml
Each epoch contains:
.pf_index/builds/<epoch>/
|-- manifest.json
|-- lexical.sqlite
`-- content/<sha256-of-relative-path>.md
The active epoch is selected through .pf_index/ACTIVE. Rolling back is a
controlled edit of that pointer to a retained epoch.
Running The Service
Default stdlib server:
PYTHONPATH="$PWD" python -m pf_index.api.server \
--host 127.0.0.1 \
--port 8765 \
--config /path/to/pf-index.toml
Optional FastAPI boundary:
python -m pip install -r requirements.lock
PYTHONPATH="$PWD" uvicorn pf_index.api.fastapi_app:create_app --factory \
--host 127.0.0.1 \
--port 8765
Testing
Run acceptance and structure tests:
PYTHONDONTWRITEBYTECODE=1 python -m unittest discover -s tests -v
The tests focus on safety contracts such as path validation, signed handles, indexing behavior, write routing, and repository structure.
Deployment
Use Docs/DEPLOYMENT.md for the production runbook. It covers:
- Dedicated service user and filesystem permissions
- Code and vault placement
- HMAC secret generation
- User token generation
- Index build and startup checks
systemdservice setup- LAN/VPN binding and firewall posture
- Runtime egress denial
- Token rotation
- Audit recovery
- Rollback
scripts/deploy_interactive.sh and scripts/deploy_teardown.sh support guided
deployment and cleanup flows.
Nightly Refresh
scripts/nightly_refresh.sh supports a scheduled flow:
sync or refresh source data
-> optionally rebuild Markdown vault from DuckDB
-> build a new immutable index epoch
-> atomically update ACTIVE
If DuckDB-to-Markdown generation happens elsewhere, omit PF_SOURCE_DATABASE
and rebuild the index from the current vault.
Data Boundary
Do not commit or deploy local data artifacts:
agency_core.duckdb- Generated
Obsidian_Vault/ .pf_index/builds.obsidian/.vault_salt- Real
.envfiles - Audit databases
- Exported CSVs, spreadsheets, or reports
The repository is meant to contain application code, tests, docs, and placeholder configuration only.
Further Reading
Docs/ARCHITECTURE.mdfor the full design and safety modelDocs/QUICKSTART.mdfor local smoke testingDocs/DEPLOYMENT.mdfor production operationsDocs/MCP_WRAPPER_MASTER_PROMPT.mdfor operator-facing MCP usage guidance
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。