obsidian-mcp
Exposes an Obsidian vault with full-text and semantic search, and Anki-style spaced repetition active recall.
README
obsidian-mcp
A TypeScript MCP server that exposes your Obsidian vault to any MCP-compatible client (Claude Desktop, Claude Code, etc.) with full-text + semantic search and Anki-style spaced-repetition active recall.
Features
| Capability | Tools |
|---|---|
| Vault reading | list_notes, get_note, get_recent_notes, get_backlinks, get_vault_stats |
| Search | search_notes (hybrid FTS5 + semantic), get_notes_by_topic |
| Active recall | cross_question, get_due_questions, submit_review, get_topic_mastery |
| Question store | add_questions, list_questions, delete_question |
- Local embeddings —
all-MiniLM-L6-v2via@xenova/transformers. No note content leaves the machine. - SQLite — FTS5 full-text index + embedding vectors (pure-JS cosine similarity fallback if
sqlite-vecis unavailable). - Git sync — vault mirrored from MacBook → EC2 via git; health status reported in
get_vault_stats. - SM-2 scheduler — classic SuperMemo-2 algorithm for spaced repetition.
- stdio + HTTP/SSE transports — stdio for Claude Desktop, SSE for remote EC2 access.
Quick Start (local / Claude Desktop)
# 1. Clone and install
git clone https://github.com/YOUR_USERNAME/obsidian-mcp.git
cd obsidian-mcp
npm install
# If on Node 25+ (no prebuilt better-sqlite3 binary yet), build from source:
npm run rebuild:sqlite
# 2. Build
npm run build
# 3. Copy and edit .env
cp .env.example .env
# Set VAULT_PATH to your Obsidian vault directory
# 4. Run (stdio mode)
VAULT_PATH=/path/to/your/vault npm start
Claude Desktop config
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"obsidian": {
"command": "node",
"args": ["/absolute/path/to/obsidian-mcp/dist/index.js"],
"env": {
"VAULT_PATH": "/absolute/path/to/your/vault"
}
}
}
}
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
VAULT_PATH |
✅ | — | Absolute path to Obsidian vault |
TRANSPORT |
No | stdio |
stdio or http |
PORT |
No | 3000 |
HTTP port (when TRANSPORT=http) |
MCP_AUTH_TOKEN |
No* | — | Bearer token for HTTP auth (*required in production) |
DB_PATH |
No | ./data/obsidian-mcp.db |
SQLite database path |
LOG_LEVEL |
No | info |
debug | info | warn | error |
TRANSFORMERS_CACHE |
No | ~/.cache/huggingface |
Where to cache the embedding model |
EC2 Deployment
1. Set up EC2 → GitHub SSH access
# On EC2: generate a deploy key (read-only) for the vault repo
ssh-keygen -t ed25519 -C "ec2-vault-deploy" -f ~/.ssh/vault_deploy_key -N ""
cat ~/.ssh/vault_deploy_key.pub
# Add the public key to your vault repo as a read-only deploy key on GitHub
2. Run the bootstrap script
# On EC2 (as ec2-user):
export REPO_URL="https://github.com/YOUR_USERNAME/obsidian-mcp.git"
export VAULT_REPO="git@github.com:YOUR_USERNAME/obsidian-vault.git"
bash scripts/setup-ec2.sh
The script:
- Installs Node.js 20 via nvm
- Clones vault + server repos
- Builds TypeScript
- Creates
.envwith a randomly generatedMCP_AUTH_TOKEN - Installs and starts all systemd units (MCP server + 5-min vault sync timer)
3. Set up nginx + TLS
sudo apt install -y nginx certbot python3-certbot-nginx
# Copy config and replace domain
sudo cp nginx/obsidian-mcp.conf /etc/nginx/sites-available/obsidian-mcp
sudo ln -s /etc/nginx/sites-available/obsidian-mcp /etc/nginx/sites-enabled/
# Edit: sed -i 's/mcp.yourdomain.com/your.actual.domain/g' /etc/nginx/sites-available/obsidian-mcp
sudo certbot --nginx -d your.actual.domain
sudo systemctl reload nginx
4. Mac → EC2 vault sync (auto git push)
# Edit VAULT_DIR in the plist first
nano launchd/com.obsidian.sync.plist
# Install
cp launchd/com.obsidian.sync.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.obsidian.sync.plist
# Verify
launchctl list | grep obsidian
tail -f /tmp/obsidian-sync.log
5. Claude Desktop → EC2 (HTTP/SSE)
{
"mcpServers": {
"obsidian-remote": {
"url": "https://your.actual.domain/sse",
"headers": {
"Authorization": "Bearer YOUR_MCP_AUTH_TOKEN"
}
}
}
}
Active Recall Workflow
User: "Quiz me on machine learning"
→ cross_question(topic="machine learning", depth="medium")
← Server returns: relevant notes + due questions
Claude reads notes, asks due questions first, then generates new ones
→ submit_review(question_id=42, grade="good")
← SM-2 schedules next review in N days
→ add_questions(note_path="ML/Backprop.md", questions=[...])
← Stored for future review sessions
User: "How am I doing on ML?"
→ get_topic_mastery(topic="machine learning")
← Stats: 23 questions, 18 reviewed, avg ease 2.3, 3 weak areas
MCP Tools Reference
Vault Tools
| Tool | Description |
|---|---|
list_notes |
List notes, filter by tag and/or folder |
get_note |
Get full note content by path or title |
search_notes |
Hybrid FTS + semantic search (mode: hybrid/fulltext/semantic) |
get_notes_by_topic |
Semantic + tag search for a topic |
get_backlinks |
Find notes linking to a note via [[wikilinks]] |
get_recent_notes |
N most recently modified notes |
get_vault_stats |
Note count, tags, folders, git sync status |
Review Tools
| Tool | Description |
|---|---|
cross_question |
Quiz-me entry point: returns notes + due questions for a topic |
get_due_questions |
Questions due for review today (SM-2 scheduled) |
submit_review |
Record grade (again/hard/good/easy), update SM-2 schedule |
get_topic_mastery |
Aggregate stats: reviewed, overdue, avg ease, weak areas |
Question Tools
| Tool | Description |
|---|---|
add_questions |
Store LLM-generated questions for a note |
list_questions |
List all questions, filtered by note path |
delete_question |
Remove a question from the review queue |
Architecture
obsidian-mcp/
├── src/
│ ├── index.ts # Entry point (stdio / HTTP)
│ ├── server.ts # McpServer factory
│ ├── db/
│ │ ├── schema.ts # SQLite init (FTS5, embeddings, SM-2 state)
│ │ └── sm2.ts # SM-2 algorithm
│ ├── embeddings/
│ │ └── model.ts # @xenova/transformers wrapper + cosine fallback
│ ├── vault/
│ │ ├── parser.ts # Markdown → Note (gray-matter, wikilinks, tags)
│ │ ├── indexer.ts # Full scan + chokidar file watcher
│ │ └── search.ts # FTS5 + semantic + hybrid + topic search
│ ├── tools/
│ │ ├── vault.ts # Vault reading tools
│ │ ├── questions.ts # Question CRUD tools
│ │ └── review.ts # Active recall + SM-2 tools
│ └── transport/
│ └── http.ts # Express SSE + bearer auth
├── systemd/ # EC2 systemd units + timer
├── launchd/ # Mac launchd plist (auto git push)
├── nginx/ # nginx reverse proxy config
└── scripts/
└── setup-ec2.sh # EC2 one-shot bootstrap
Notes on sqlite-vec
The server automatically attempts to load the sqlite-vec native extension for vector operations. If it fails to load (e.g. on some Apple Silicon configs without Rosetta), it falls back seamlessly to a pure-JS cosine similarity implementation. This fallback works well for vaults up to ~5,000 notes; for larger vaults, ensure sqlite-vec is available.
# Test if sqlite-vec loads on your system
node -e "require('sqlite-vec')"
Backups
The SQLite DB (data/obsidian-mcp.db) holds your review state — this is the only data that can't be reconstructed from the vault. Back it up:
# Manual backup
cp data/obsidian-mcp.db "data/obsidian-mcp-$(date +%Y%m%d).db"
# Cron backup on EC2 (add to crontab)
0 3 * * * sqlite3 /home/ec2-user/obsidian-mcp/data/obsidian-mcp.db ".backup '/home/ec2-user/backups/obsidian-mcp-$(date +\%Y\%m\%d).db'"
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 模型以安全和受控的方式获取实时的网络信息。