Obsidian CLI MCP Server
Enables AI assistants to perform over 80 Obsidian vault operations locally via the Obsidian CLI, with a single tool and no network dependencies.
README
obsidian-cli-mcp-server
A local MCP server that wraps the official Obsidian CLI (v1.12+), giving LLM agents full access to 80+ vault operations through a single tool.
- Zero network dependencies — no API keys, no cloud services; everything runs locally
- Single-tool design — one
obsidian_exectool accepts any CLI command, so new Obsidian CLI features work instantly without updating the server - Safety-first — dangerous commands (
eval,devtools, etc.) are blocked at two layers; all execution usesspawnwithout shell interpretation, preventing command injection - Dual execution mode — direct spawn for terminal environments + HTTP relay for Electron-hosted clients (Claude Desktop, Cowork)
Prerequisites
- Obsidian v1.12.4+ with CLI enabled (Settings → General → Command line interface)
- The
obsidianbinary in yourPATH(or setOBSIDIAN_CLI_PATH) - Node.js ≥ 18
expect(pre-installed on macOS; needed forsearch/search:context)
Quick Start
# Clone and build
git clone https://github.com/cks850711/obsidian-cli-mcp-server.git
cd obsidian-cli-mcp-server
npm install
npm run build
Configuration
Claude Code
Add to your Claude Code MCP settings:
{
"mcpServers": {
"obsidian-cli": {
"command": "node",
"args": ["/absolute/path/to/obsidian-cli-mcp-server/dist/index.js"]
}
}
}
Claude Desktop
{
"mcpServers": {
"obsidian-cli": {
"command": "node",
"args": ["/absolute/path/to/obsidian-cli-mcp-server/dist/index.js"]
}
}
}
Note: Claude Desktop is an Electron app, and spawning the Obsidian CLI (also Electron) from it causes a SingletonSocket IPC conflict. You must start the HTTP relay server from a terminal first — see HTTP Relay below.
Available Tools
obsidian_exec
Execute any Obsidian CLI sub-command and return its output.
| Parameter | Type | Required | Description |
|---|---|---|---|
command |
string | ✅ | CLI sub-command and arguments (without the leading obsidian) |
vault |
string | — | Target a specific vault by name |
Examples:
command="help"
command="read file=MyNote"
command="search query=\"meeting notes\" limit=10"
command="create name=NewNote content=\"Hello world\""
command="files folder=Projects ext=md"
command="tasks todo"
command="tags counts sort=count"
command="properties file=MyNote"
command="backlinks file=MyNote"
command="bookmarks"
For the full list of available CLI commands, run command="help".
obsidian_blocked_commands
Returns the list of CLI commands that are blocked by this server for safety reasons. Takes no parameters.
HTTP Relay
When the MCP server runs inside an Electron process tree (e.g., Claude Desktop), the Obsidian CLI binary hangs due to Electron's SingletonSocket IPC mechanism. The relay server solves this by running in a separate terminal.
# Start the relay (keep this terminal open)
npm run relay
# Default: http://127.0.0.1:27182
The MCP server automatically tries the relay first, then falls back to direct spawn. No configuration needed — just start the relay before using the MCP server from Electron-based clients.
| Environment variable | Default | Description |
|---|---|---|
OBSIDIAN_RELAY_PORT |
27182 |
Relay server port |
OBSIDIAN_CLI_PATH |
obsidian |
Path to the Obsidian CLI binary |
Security
Blocked Commands
The following commands are blocked by default to prevent unintended side effects:
| Command | Reason |
|---|---|
eval |
Arbitrary JavaScript execution inside Obsidian |
restart |
Restarts the Obsidian app |
devtools |
Toggles Electron DevTools |
dev:cdp |
Chrome DevTools Protocol — arbitrary method execution |
dev:css |
CSS inspection |
dev:debug |
Debugger attach/detach |
dev:dom |
DOM query |
dev:mobile |
Mobile emulation toggle |
The blocklist is enforced at two layers — both the MCP server (cli.ts) and the relay server (relay-server.ts) independently reject blocked commands. To customize, edit src/constants.ts.
Command Injection Prevention
All commands are executed via Node.js child_process.spawn without a shell (shell: false by default). User input is parsed into an argv array by a custom parser (parse-args.ts) — not by sh -c. This means:
- Shell metacharacters (
;,|,$(),` `,&&) are not interpreted - The executable is always the fixed
obsidianbinary — it cannot be changed by user input - No command substitution, variable expansion, or piping is possible
For search / search:context (which require a TTY), commands are wrapped with expect. Arguments are quoted using Tcl brace-quoting ({...}), which is fully literal with no substitution.
Architecture
LLM (Claude)
│
│ MCP (stdio)
▼
┌──────────────────────┐
│ MCP Server │
│ (index.ts) │
│ │
│ obsidian_exec tool │
│ ┌────────────────┐ │
│ │ isBlocked() │──│── Layer 1: block dangerous commands
│ │ parseArgs() │──│── Parse without shell
│ └───────┬────────┘ │
└──────────┼───────────┘
│
┌─────┴──────┐
▼ ▼
┌─────────┐ ┌───────────┐
│ Relay │ │ Direct │
│ Server │ │ Spawn │
│ (HTTP) │ │ │
│ :27182 │ │ │
└────┬────┘ └─────┬─────┘
│ │
▼ ▼
┌─────────────────┐
│ obsidian CLI │
│ (Electron) │
└─────────────────┘
Development
npm run dev # Watch mode (tsx)
npm run build # Compile TypeScript
npm test # Run parse-args unit tests
npm run relay # Start HTTP relay server
License
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。