mcp-fs-obsidian

mcp-fs-obsidian

Provides Claude with safe read/write access to Obsidian vaults, with YAML frontmatter protection and path filtering to prevent corruption.

Category
访问服务器

README

MCP-FS-Obsidian

A lightweight Model Context Protocol (MCP) server for safe Obsidian vault access. This server provides Claude with the ability to read and write notes in an Obsidian vault while preventing YAML frontmatter corruption.

Features

  • ✅ Safe frontmatter parsing and validation using gray-matter
  • ✅ Path filtering to exclude .obsidian directory and other system files
  • ✅ Core MCP methods: read_note, write_note, list_directory, delete_note
  • ✅ Safe deletion with confirmation requirement to prevent accidents
  • ✅ TypeScript support with Bun runtime (no compilation needed)
  • ✅ Comprehensive error handling and validation

Prerequisites

  • Bun runtime (v1.0.0 or later)
  • An Obsidian vault (local directory with .md files)
  • Claude Desktop (for MCP integration)

Installation

For End Users (Recommended)

No installation needed! Use bunx to run directly:

bunx mcp-fs-obsidian /path/to/your/obsidian/vault

For Developers

  1. Clone this repository
  2. Install dependencies with Bun:
bun install

Usage

Running the Server

End users:

bunx mcp-fs-obsidian /path/to/your/obsidian/vault

Developers:

bun server.ts /path/to/your/obsidian/vault

Claude Desktop Configuration

Single Vault

Add to your Claude Desktop configuration file:

{
  "mcpServers": {
    "obsidian": {
      "command": "bunx",
      "args": ["mcp-fs-obsidian", "/Users/yourname/Documents/MyVault"]
    }
  }
}

Multiple Vaults

You can configure multiple vaults by creating separate MCP server entries:

{
  "mcpServers": {
    "obsidian-personal": {
      "command": "bunx",
      "args": ["mcp-fs-obsidian", "/Users/yourname/Documents/PersonalVault"]
    },
    "obsidian-work": {
      "command": "bunx",
      "args": ["mcp-fs-obsidian", "/Users/yourname/Documents/WorkVault"]
    },
    "obsidian-research": {
      "command": "bunx",
      "args": ["mcp-fs-obsidian", "/Users/yourname/Documents/ResearchVault"]
    }
  }
}

Configuration File Locations:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Examples

Ask Claude about your notes:

  • "What files are in my Obsidian vault?"
  • "Read my note called 'project-ideas.md'"
  • "Show me all notes with 'AI' in the title"

Have Claude help with note management:

  • "Create a new note called 'meeting-notes.md' with today's date in the frontmatter"
  • "Update the tags in my 'research.md' note to include 'machine-learning'"
  • "List all markdown files in my 'Projects' folder"
  • "Delete the old draft note 'draft-ideas.md' (with confirmation)"

Troubleshooting

Common Issues

"command not found: bunx"

  • Solution: Install Bun runtime from bun.sh
  • Alternative: Use npm: npx mcp-fs-obsidian /path/to/vault

"Usage: bun server.ts /path/to/vault"

  • Cause: No vault path provided
  • Solution: Specify the full path to your Obsidian vault directory

"Permission denied" errors

  • Cause: Insufficient file system permissions
  • Solution: Ensure the vault directory is readable/writable by your user

"Path traversal not allowed"

  • Cause: Trying to access files outside the vault
  • Solution: All file paths must be relative to the vault root

Claude Desktop not recognizing the server

  1. Check the configuration file path is correct for your OS
  2. Ensure JSON syntax is valid (use a JSON validator)
  3. Restart Claude Desktop after configuration changes
  4. Check Claude Desktop logs for error messages

".obsidian files still showing up"

  • Expected: The path filter automatically excludes .obsidian/** patterns
  • If still seeing them: The filter is working as designed for security

Debug Mode

Run with error logging:

bunx mcp-fs-obsidian /path/to/vault 2>debug.log

Getting Help

  • Open an issue on GitHub
  • Include your OS, Bun version, and error messages
  • Provide the vault directory structure (without sensitive content)

Testing

Run the test suite:

bun test

API Methods

read_note

Read a note from the vault with parsed frontmatter.

Request:

{
  "name": "read_note",
  "arguments": {
    "path": "project-ideas.md"
  }
}

Response:

{
  "path": "project-ideas.md",
  "frontmatter": {
    "title": "Project Ideas",
    "tags": ["projects", "brainstorming"],
    "created": "2023-01-15T10:30:00.000Z"
  },
  "content": "# Project Ideas\n\n## AI Tools\n- MCP server for Obsidian\n- Voice note transcription\n\n## Web Apps\n- Task management system"
}

write_note

Write a note to the vault with optional frontmatter.

Request:

{
  "name": "write_note",
  "arguments": {
    "path": "meeting-notes.md",
    "content": "# Team Meeting\n\n## Agenda\n- Project updates\n- Next milestones",
    "frontmatter": {
      "title": "Team Meeting Notes",
      "date": "2023-12-01",
      "tags": ["meetings", "team"]
    }
  }
}

Response:

{
  "message": "Successfully wrote note: meeting-notes.md"
}

list_directory

List files and directories in the vault.

Request:

{
  "name": "list_directory",
  "arguments": {
    "path": "Projects"
  }
}

Response:

{
  "path": "Projects",
  "directories": [
    "AI-Tools",
    "Web-Development"
  ],
  "files": [
    "project-template.md",
    "roadmap.md"
  ]
}

delete_note

Delete a note from the vault (requires confirmation for safety).

Request:

{
  "name": "delete_note",
  "arguments": {
    "path": "old-draft.md",
    "confirmPath": "old-draft.md"
  }
}

Response (Success):

{
  "success": true,
  "path": "old-draft.md",
  "message": "Successfully deleted note: old-draft.md. This action cannot be undone."
}

Response (Confirmation Failed):

{
  "success": false,
  "path": "old-draft.md",
  "message": "Deletion cancelled: confirmation path does not match. For safety, both 'path' and 'confirmPath' must be identical."
}

⚠️ Safety Note: The confirmPath parameter must exactly match the path parameter to proceed with deletion. This prevents accidental deletions.

Security Considerations

This MCP server implements several security measures to protect your Obsidian vault:

Path Security

  • Path Traversal Protection: All file paths are validated to prevent access outside the vault
  • Relative Path Enforcement: Paths are normalized and restricted to the vault directory
  • Symbolic Link Safety: Resolved paths are checked against vault boundaries

File Filtering

  • Automatic Exclusions: .obsidian, .git, node_modules, and system files are filtered
  • Extension Whitelist: Only .md, .markdown, and .txt files are accessible by default
  • Hidden File Protection: Dot files and system directories are automatically excluded

Content Validation

  • YAML Frontmatter Validation: Frontmatter is parsed and validated before writing
  • Function/Symbol Prevention: Dangerous JavaScript objects are blocked from frontmatter
  • Data Type Checking: Only safe data types (strings, numbers, arrays, objects) allowed

Best Practices

  • Least Privilege: Server only accesses the specified vault directory
  • Read-Only by Default: Consider running with read-only permissions for sensitive vaults
  • Backup Recommended: Always backup your vault before using write operations
  • Network Isolation: Server uses stdio transport (no network exposure)

What's NOT Protected

  • File Content: The server can read/write any allowed file content
  • Vault Structure: Directory structure is visible to Claude
  • File Metadata: Creation times, file sizes, etc. are accessible

⚠️ Important: Only grant vault access to trusted Claude conversations. The server provides full read/write access to your notes within the security boundaries above.

Architecture

  • server.ts - MCP server entry point
  • src/frontmatter.ts - YAML frontmatter handling with gray-matter
  • src/filesystem.ts - Safe file operations with path validation
  • src/pathfilter.ts - Directory and file filtering
  • src/types.ts - TypeScript type definitions

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and add tests
  4. Ensure all tests pass: bun test
  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 模型以安全和受控的方式获取实时的网络信息。

官方
精选