Obsidian MCP Server

Obsidian MCP Server

Enables AI assistants to search, read, and append content to notes in an Obsidian vault via the MCP protocol.

Category
访问服务器

README

Obsidian MCP Server Plugin

Project Overview

This is an Obsidian plugin that functions as an MCP (Model Context Protocol) server, enabling Claude Desktop and other AI assistants to interact directly with an Obsidian vault. It provides a bridge between the MCP protocol (used by Claude Desktop) and the Obsidian API.

Author: Bas van Laarhoven / Sensei Bas License: MIT Version: 1.0.0

Architecture

High-Level Design

Claude Desktop (stdio)
    ↓
stdio-bridge.js (converts stdio ↔ HTTP)
    ↓
MCP Server (HTTP on localhost:3000)
    ↓
Obsidian API (vault access)

Why HTTP Instead of stdio?

Obsidian runs in Electron, which doesn't have direct stdio access. This plugin runs an HTTP server locally (localhost:3000) and uses a stdio bridge (stdio-bridge.js) to convert between:

  • Claude Desktop's stdio-based MCP protocol
  • This plugin's HTTP-based implementation

This architecture is security-conscious: the HTTP server only listens on localhost, preventing external network access.

Core Components

1. MCP Server (src/mcp-server.ts)

The main server class that:

  • Runs an HTTP server on port 3000 (localhost only)
  • Implements MCP protocol over JSON-RPC 2.0
  • Handles three core MCP methods:
    • initialize - Protocol handshake
    • tools/list - Returns available tools
    • tools/call - Executes a tool

Key Implementation Details:

  • Uses Electron's built-in http module (not Node's)
  • CORS enabled for localhost
  • All requests are POST (OPTIONS for CORS preflight)
  • Notifications (methods starting with notifications/) are acknowledged but not processed

2. Available Tools

The plugin provides four tools for vault interaction:

search_notes

Location: src/tools/search-notes.ts Purpose: Search vault notes by query text Parameters:

  • query (required): Search text (searches titles and content)
  • folder (optional): Filter by folder path
  • tag (optional): Filter by tag (without #)
  • limit (optional): Max results (default: 10)

Returns: JSON array of matching notes with snippets

get_note

Location: src/tools/get-note.ts Purpose: Read a specific note's full content and metadata Parameters:

  • path (required): Vault path to note

Returns: Note content, metadata, frontmatter, tags, links

Important: Use search_notes first to find the correct path, then use get_note to read the full content.

get_related_notes

Location: src/tools/get-related-notes.ts Purpose: Find notes related to a specific note Parameters:

  • path (required): Vault path to note

Returns:

  • Outgoing links (notes this note links to)
  • Incoming links/backlinks (notes that link to this note)

Note: Returns only paths - use get_note to read full content of related notes.

append_to_note

Location: src/tools/append-to-note.ts Purpose: Append content to the end of an existing note Parameters:

  • path (required): Vault path to note
  • content (required): Markdown content to append

Returns: Success message

Use Cases: Adding new information, logging, extending notes without replacing content

3. Plugin Entry Point (main.ts)

The main Obsidian plugin class that:

  • Loads/unloads the plugin
  • Starts/stops the MCP server
  • Integrates with Obsidian's plugin system

4. stdio Bridge (stdio-bridge.js)

Standalone Node.js script that:

  • Reads JSON-RPC from stdin (from Claude Desktop)
  • Forwards to HTTP server (this plugin)
  • Sends HTTP responses back to stdout
  • Handles initialization and tool calls

Development Guide

Build Commands

npm install          # Install dependencies
npm run dev          # Watch mode (rebuilds on changes)
npm run build        # Production build

Project Structure

.
├── src/
│   ├── mcp-server.ts          # Main MCP server implementation
│   ├── types.ts               # TypeScript types
│   └── tools/
│       ├── search-notes.ts    # Search functionality
│       ├── get-note.ts        # Note reading
│       ├── get-related-notes.ts  # Link traversal
│       └── append-to-note.ts  # Note appending
├── main.ts                    # Obsidian plugin entry point
├── stdio-bridge.js            # Claude Desktop bridge
├── manifest.json              # Plugin manifest
└── package.json               # Dependencies

Key Dependencies

  • obsidian - Obsidian API types
  • esbuild - Build tool
  • typescript - Language
  • Built-in Node.js http module (via Electron)

Testing

node test-connection.js  # Test HTTP server directly
node test-mcp.js        # Test MCP protocol

Protocol Details

MCP (Model Context Protocol)

This plugin implements MCP 2024-11-05 protocol version over JSON-RPC 2.0.

Supported Methods:

  • initialize - Handshake, returns capabilities
  • tools/list - Returns tool definitions with JSON schemas
  • tools/call - Executes a tool with arguments

Tool Response Format:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Tool result as string"
      }
    ]
  }
}

Error Handling

Standard JSON-RPC error codes:

  • -32601 - Method not found
  • -32603 - Internal error / tool execution failed

Configuration

Claude Desktop Setup

Windows:

{
  "mcpServers": {
    "obsidian-vault": {
      "command": "node",
      "args": [
        "C:\\Path\\To\\Vault\\.obsidian\\plugins\\mcp-server\\stdio-bridge.js"
      ]
    }
  }
}

macOS/Linux:

{
  "mcpServers": {
    "obsidian-vault": {
      "command": "node",
      "args": [
        "/path/to/vault/.obsidian/plugins/mcp-server/stdio-bridge.js"
      ]
    }
  }
}

Common Patterns

Searching for Notes

  1. Use search_notes with a query
  2. Optionally filter by folder or tag
  3. Get list of matching notes with paths

Reading Note Content

  1. Use search_notes to find the note path
  2. Use get_note with the exact path to read full content

Exploring Related Notes

  1. Use get_related_notes to find linked notes
  2. Use get_note on each related path to read content
  3. Recursively explore to build a knowledge graph

Adding to Notes

  1. Use search_notes or get_note to verify note exists
  2. Use append_to_note to add content to the end

Security Considerations

  • HTTP server only listens on localhost (127.0.0.1)
  • No external network access
  • No authentication required (assumes trusted local environment)
  • CORS enabled only for localhost

Troubleshooting

Server won't start

  • Check if port 3000 is already in use
  • Check Obsidian Developer Console (Ctrl+Shift+I)

Claude Desktop can't connect

  • Verify Obsidian is running
  • Verify plugin is enabled in Obsidian settings
  • Check path in claude_desktop_config.json is correct
  • Restart Claude Desktop completely

Tool calls fail

  • Check Obsidian console for error messages
  • Verify note paths are correct (case-sensitive)
  • Ensure notes exist before reading

Future Enhancement Ideas

Based on findings.md, potential features to add:

  1. Bases Query Execution - Execute Dataview queries, return results
  2. Plugin Integration - List installed plugins, access their data
  3. Note Creation - Create new notes (currently only append)
  4. Note Modification - Edit existing content (not just append)
  5. File Operations - Move, rename, delete notes
  6. Graph Analysis - Advanced link graph queries
  7. Canvas Integration - Read/modify canvas files

References

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选