Obsidian Local REST API MCP Server

Obsidian Local REST API MCP Server

A bridge server that allows LLM tools to interact with an Obsidian vault through a local REST API, enabling file operations, note management, and metadata access through natural language.

Category
访问服务器

Tools

list_files

List all files in the Obsidian vault

get_file

Get content of a specific file from the vault

create_file

Create a new file in the vault

update_file

Update content of an existing file

delete_file

Delete a file from the vault

list_notes

List all notes in the vault with metadata

get_note

Get a specific note with its content and metadata

create_note

Create a new note with optional frontmatter

update_note

Update a note's content and/or frontmatter

delete_note

Delete a note from the vault

search_notes

Search notes by content or metadata

get_metadata_keys

Get all available frontmatter keys from notes

get_metadata_values

Get all unique values for a specific frontmatter key

README

Obsidian Local REST API MCP Server

An AI-Native MCP (Model Context Protocol) server that provides intelligent, task-oriented tools for interacting with Obsidian vaults through a local REST API.

🧠 AI-Native Design Philosophy

This MCP server has been redesigned following AI-Native principles rather than simple API-to-tool mapping. Instead of exposing low-level CRUD operations, it provides high-level, task-oriented tools that LLMs can reason about more effectively.

Before vs After: The Transformation

Old Approach (CRUD-Based) New Approach (AI-Native) Why Better
list_files (returns everything) list_directory(path, limit, offset) Prevents context overflow with pagination
create_file + update_file write_file(path, content, mode) Single tool handles create/update/append
create_note + update_note create_or_update_note(path, content, frontmatter) Intelligent upsert removes decision complexity
search_notes(query) search_vault(query, scope, path_filter) Precise, scopeable search with advanced filtering
(no equivalent) get_daily_note(date) High-level abstraction for common workflow
(no equivalent) get_recent_notes(limit) Task-oriented recent file access
(no equivalent) find_related_notes(path, on) Conceptual relationship discovery

🛠 Available Tools

Directory & File Operations

list_directory

Purpose: List directory contents with pagination to prevent context overflow

{
  "path": "Projects/",
  "recursive": false,
  "limit": 20,
  "offset": 0
}

AI Benefit: LLM can explore vault structure incrementally without overwhelming context

read_file

Purpose: Read content of any file in the vault

{"path": "notes/meeting-notes.md"}

write_file

Purpose: Write file with multiple modes - replaces separate create/update operations

{
  "path": "notes/summary.md",
  "content": "# Meeting Summary\n...",
  "mode": "append"  // "overwrite", "append", "prepend"
}

AI Benefit: Single tool handles all write scenarios, removes ambiguity

delete_item

Purpose: Delete any file or directory

{"path": "old-notes/"}

AI-Native Note Operations

create_or_update_note

Purpose: Intelligent upsert - creates if missing, updates if exists

{
  "path": "daily/2024-12-26",
  "content": "## Tasks\n- Review AI-native MCP design",
  "frontmatter": {"tags": ["daily", "tasks"]}
}

AI Benefit: Eliminates "does this note exist?" decision tree

get_daily_note

Purpose: Smart daily note retrieval with common naming patterns

{"date": "today"}  // or "yesterday", "2024-12-26"

AI Benefit: Abstracts file system details and naming conventions

get_recent_notes

Purpose: Get recently modified notes

{"limit": 5}

AI Benefit: Matches natural "what did I work on recently?" queries

Advanced Search & Discovery

search_vault

Purpose: Multi-scope search with advanced filtering

{
  "query": "machine learning",
  "scope": ["content", "filename", "tags"],
  "path_filter": "research/"
}

AI Benefit: Precise, targeted search reduces noise

find_related_notes

Purpose: Discover conceptual relationships between notes

{
  "path": "ai-research.md",
  "on": ["tags", "links"]
}

AI Benefit: Enables relationship-based workflows and serendipitous discovery

Legacy Tools (Backward Compatibility)

The server maintains backward compatibility with existing tools like get_note, list_notes, get_metadata_keys, etc.

Prerequisites

  • Node.js 18+ or Bun runtime
  • Obsidian Local REST API running locally (default: http://obsidian-local-rest-api.test)

Installation

Using npx (Recommended)

npx obsidian-local-rest-api-mcp

From Source

# Clone the repository
git clone https://github.com/j-shelfwood/obsidian-local-rest-api-mcp.git
cd obsidian-local-rest-api-mcp

# Install dependencies with bun
bun install

# Build the project
bun run build

Configuration

Set environment variables for API connection:

export OBSIDIAN_API_URL="http://obsidian-local-rest-api.test"  # Default URL (or http://localhost:8000 for non-Valet setups)
export OBSIDIAN_API_KEY="your-api-key"          # Optional bearer token

Usage

Running the Server

# Development mode with auto-reload
bun run dev

# Production mode
bun run start

# Or run directly
node build/index.js

MCP Client Configuration

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "obsidian-vault": {
      "command": "npx",
      "args": ["obsidian-local-rest-api-mcp"],
      "env": {
        "OBSIDIAN_API_URL": "http://obsidian-local-rest-api.test",
        "OBSIDIAN_API_KEY": "your-api-key-if-needed"
      }
    }
  }
}

VS Code with MCP Extension

Use the included .vscode/mcp.json configuration file.

Development

# Watch mode for development
bun run dev

# Build TypeScript
bun run build

# Type checking
bun run tsc --noEmit

Architecture

  • ObsidianApiClient - HTTP client wrapper for REST API endpoints
  • ObsidianMcpServer - MCP server implementation with tool handlers
  • Configuration - Environment-based configuration with validation

Error Handling

The server includes comprehensive error handling:

  • API connection failures
  • Invalid tool parameters
  • Network timeouts
  • Authentication errors

Errors are returned as MCP tool call responses with descriptive messages.

Debugging

Enable debug logging by setting environment variables:

export DEBUG=1
export NODE_ENV=development

Server logs are written to stderr to avoid interfering with MCP protocol communication on stdout.

Troubleshooting

MCP Server Fails to Start

If your MCP client shows "Start Failed" or similar errors:

  1. Test the server directly:

    npx obsidian-local-rest-api-mcp --version
    

    Should output the version number.

  2. Test MCP protocol:

    # Run our test script
    node -e "
    const { spawn } = require('child_process');
    const child = spawn('npx', ['obsidian-local-rest-api-mcp'], { stdio: ['pipe', 'pipe', 'pipe'] });
    child.stdout.on('data', d => console.log('OUT:', d.toString()));
    child.stderr.on('data', d => console.log('ERR:', d.toString()));
    setTimeout(() => {
      child.stdin.write(JSON.stringify({jsonrpc:'2.0',id:1,method:'initialize',params:{protocolVersion:'2024-11-05',capabilities:{},clientInfo:{name:'test',version:'1.0.0'}}})+'\n');
      setTimeout(() => child.kill(), 2000);
    }, 500);
    "
    

    Should show initialization response.

  3. Check Environment Variables:

    • Ensure OBSIDIAN_API_URL points to a running Obsidian Local REST API
    • Test the API directly: curl http://obsidian-local-rest-api.test/api/files (or your configured API URL)
  4. Verify Obsidian Local REST API:

    • Install and run Obsidian Local REST API
    • Confirm it's accessible on the configured port
    • Check if authentication is required

Common Issues

"Command not found": Make sure Node.js/npm is installed and npx is available

"Connection refused": Obsidian Local REST API is not running or wrong URL

Laravel Valet .test domains: If using Laravel Valet, ensure your project directory name matches the .test domain (e.g., obsidian-local-rest-api.test for a project in /obsidian-local-rest-api/)

"Unauthorized": Check if API key is required and properly configured

"Timeout": Increase timeout in client configuration or check network connectivity

Cherry Studio Configuration

For Cherry Studio, use these exact settings:

  • Name: obsidian-vault (or any name you prefer)
  • Type: Standard Input/Output (stdio)
  • Command: npx
  • Arguments: obsidian-local-rest-api-mcp
  • Environment Variables:
    • OBSIDIAN_API_URL: Your API URL (e.g., http://obsidian-local-rest-api.test for Laravel Valet)
    • OBSIDIAN_API_KEY: Optional API key if authentication is required
  • Environment Variables:
    • OBSIDIAN_API_URL: http://obsidian-local-rest-api.test (or your API URL)
    • OBSIDIAN_API_KEY: your-api-key (if required)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make changes with proper TypeScript types
  4. Test with your Obsidian vault
  5. Submit a pull request

License

MIT

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选