
使用模型上下文协议(MCP)将Claude代码和其他AI工具连接到你的Obsidian笔记
概览
一个实现MCP(模型上下文协议)服务器的Obsidian插件,使Claude Code与Obsidian保险库集成。 该插件允许 Claude Code 和其他 MCP 客户端(如 Claude Desktop)与你的 Obsidian 保险库交互,提供 AI 驱动的直接访问笔记和文件的辅助。 - : 支持 WebSocket(适用于 Claude Code)和 HTTP/SSE(适用于 Claude Desktop)- : Claude Code 自动查找并连接你的保险库 - : 通过 MCP 协议读写保险库文件 - : 向 Claude 提供当前活跃的文件和保险库结构 - : 同时连接 Claude Code 和 Claude Desktop。- 避免运行多个保险库时的冲突 该插件作为MCP服务器,供各种Claude客户端连接。以下是配置不同客户端的方法: Claude Desktop 需要特殊配置才能连接到 Obsidian MCP 服务器,因为它不直接支持 HTTP 传输。
概述(AI 翻译)
一个实现MCP(模型上下文协议)服务器的Obsidian插件,使Claude Code与Obsidian保险库集成。
该插件允许 Claude Code 和其他 MCP 客户端(如 Claude Desktop)与你的 Obsidian 保险库交互,提供 AI 驱动的直接访问笔记和文件的辅助。
特色
- 双传输MCP服务器:支持WebSocket(针对Claude Code)和HTTP/SSE(针对Claude Desktop)
- 自动发现:Claude Code 会自动找到并连接到你的保险库
- 文件操作:通过MCP协议读写保险库文件
- Workspace Context:向 Claude 提供当前活跃文件和保险库结构
- 多客户端支持:同时连接Claude代码和Claude桌面
- 可配置端口:避免运行多个保险库时的冲突
MCP 客户端配置
该插件作为MCP服务器,供各种Claude客户端连接。以下是配置不同客户端的方法:
Claude桌面(截至2025-06-09)
Claude Desktop 需要特殊配置才能连接到 Obsidian MCP 服务器,因为它不直接支持 HTTP 传输。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Obsidian Claude Code
An Obsidian plugin that implements an MCP (Model Context Protocol) server to enable Claude Code integration with Obsidian vaults.
This plugin allows Claude Code and other MCP clients (like Claude Desktop) to interact with your Obsidian vault, providing AI-powered assistance with direct access to your notes and files.
Features
- Dual Transport MCP Server: Supports both WebSocket (for Claude Code) and HTTP/SSE (for Claude Desktop)
- Auto-Discovery: Claude Code automatically finds and connects to your vault
- File Operations: Read and write vault files through MCP protocol
- Workspace Context: Provides current active file and vault structure to Claude
- Multiple Client Support: Connect both Claude Code and Claude Desktop simultaneously
- Configurable Ports: Avoid conflicts when running multiple vaults
MCP Client Configuration
This plugin serves as an MCP server that various Claude clients can connect to. Here’s how to configure different clients:
Claude Desktop (as of 2025-06-09)
Claude Desktop requires a special configuration to connect to the Obsidian MCP server because it does not directly support HTTP transports. We will use mcp-remote, a tool that creates a local stdio bridge to the server’s HTTP endpoint.
Configuration Steps:
-
Install and enable this plugin in Obsidian.
-
Make sure you have Node.js installed, as
npx(which comes with Node.js) is used to run the bridge tool. -
Locate your Claude Desktop config file:
- macOS:
$HOME/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Add the Obsidian MCP server to your config using the
mcp-remotecommand.npxwill automatically download and run it for you.{ "mcpServers": { "obsidian": { "command": "npx", "args": ["mcp-remote", "http://localhost:22360/sse"], "env": {} } } } -
Restart Claude Desktop after making the configuration change.
-
Test the connection by asking Claude about your vault: “What files are in my Obsidian vault?”
Other MCP Clients (with direct HTTP support)
If you are using an MCP client that directly supports the legacy “HTTP with SSE” transport, you can use a simpler configuration without the mcp-remote bridge.
Example Configuration:
{
"mcpServers": {
"obsidian": {
"url": "http://localhost:22360/sse",
"env": {}
}
}
}
Claude Code CLI
Claude Code automatically discovers and connects to Obsidian vaults through WebSocket.
Usage Steps:
- Install and enable this plugin in Obsidian
- Run Claude Code in your terminal:
claude - Select your vault using the
/idecommand - Choose “Obsidian” from the IDE list
- Claude Code will automatically connect via WebSocket
Port Configuration
安装
npx mcp-remote http://localhost:22360/sse配置
{
"mcpServers": {
"obsidian": {
"command": "npx",
"args": ["mcp-remote", "http://localhost:22360/sse"],
"env": {}
}
}
}