A TypeScript-based Model Context Protocol (MCP) server that provides secure access to Obsidian vaults for AI assistants. Run locally with support for multiple vaults, configurable file access, and comprehensive markdown operations.
- Multi-Vault Support: Access multiple Obsidian vaults with individual configuration
- Secure File Operations: Path validation, size limits, and configurable scope restrictions
- YAML Frontmatter: Parse and manipulate frontmatter in markdown files
- File Type Filtering: Support for
.md,.png,.pdf, and configurable additional extensions - Content Search: Basic text search across markdown files with context
- Cross-Platform: Works on Windows, macOS, and Linux
npm install -g obsidian-mcp-servergit clone <repository-url>
cd obsidian-mcp-server
npm install
npm run buildCreate a config.json file to define your vault settings:
{
"vaults": [
{
"name": "main",
"path": "/path/to/your/obsidian-vault",
"allowedPaths": [
"notes/",
"projects/"
]
},
{
"name": "work",
"path": "/path/to/work-vault"
}
],
"fileExtensions": [
".md",
".png",
".pdf",
".txt"
],
"maxFileSize": "10MB",
"logLevel": "info",
"logToFile": true,
"verifyVaultsOnStartup": true
}- vaults: Array of vault configurations
name: Unique identifier for the vaultpath: Absolute path to the vault directoryallowedPaths: (Optional) Array of subdirectory paths to restrict access
- fileExtensions: Array of allowed file extensions (default:
.md,.png,.pdf) - maxFileSize: Maximum file size for reading (default:
10MB) - logLevel: Logging verbosity (default:
info) - options:error,warn,info,debug - logToFile: Enable file-based logging (default:
true) - creates logs inlogs/directory - verifyVaultsOnStartup: Verify vault access and log top folders on startup (default:
true)
# With config file
obsidian-mcp-server --config /path/to/config.json
# With config file and specific log level
obsidian-mcp-server --config /path/to/config.json --log-level debug
# With default configuration (uses current directory)
obsidian-mcp-serverAdd to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"obsidian": {
"command": "obsidian-mcp-server",
"args": ["--config", "/path/to/your/config.json"]
}
}
}{
"mcpServers": {
"obsidian": {
"command": "node",
"args": ["/path/to/obsidian-mcp-server/dist/index.js", "--config", "/path/to/obsidian-mcp-server/config/config.json"]
}
}
}
The server provides the following tools for AI assistants:
Read content from markdown files or metadata from binary files.
{
"vault_name": "main",
"file_path": "notes/example.md",
"include_content": true,
"include_frontmatter": true
}Create or update markdown files with optional frontmatter.
{
"vault_name": "main",
"file_path": "notes/new-note.md",
"content": "# New Note\n\nContent here...",
"frontmatter": {
"title": "My New Note",
"tags": ["example", "new"]
},
"create_directories": true
}List files in vault directories with filtering.
{
"vault_name": "main",
"directory_path": "notes",
"include_metadata": false
}Search for text across markdown files.
{
"vault_name": "main",
"query": "search term",
"directory_path": "notes",
"case_sensitive": false,
"whole_word": false,
"max_results": 50
}Get file metadata including frontmatter without full content.
{
"vault_name": "main",
"file_path": "notes/example.md"
}# Build the project
npm run build
# Development with watch mode
npm run dev
# Run tests
npm run test
npm run test:watch
npm run test:coverage
# Linting and formatting
npm run lint
npm run lint:fix
npm run format
npm run format:checksrc/
├── config/ # Configuration loading and validation
├── obsidian/ # Vault operations and metadata parsing
├── tools/ # MCP tool implementations
├── server.ts # Main MCP server
└── index.ts # CLI entry point
The project includes comprehensive tests:
- Unit tests for all core functionality
- Integration tests with mock vaults
- 90%+ test coverage target
- Cross-platform compatibility tests
Run tests:
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # With coverage report- Path Validation: Prevents directory traversal attacks
- Scope Restriction: Configurable allowed paths per vault
- File Size Limits: Prevents reading of excessively large files
- Extension Filtering: Only processes specified file types
- Read-Only Binary Files: Binary files return metadata only
- Permission Errors: Ensure the server has read/write access to vault directories
- Path Issues: Use absolute paths in configuration
- File Size Errors: Adjust
maxFileSizeif needed for larger files - Extension Errors: Add required extensions to
fileExtensionsarray
Enable detailed logging:
# Using command line option
obsidian-mcp-server --config config.json --log-level debug
# Or set in config.json
{
"logLevel": "debug",
"vaults": [...],
...
}Available log levels: error, warn, info, debug
The server uses Winston for comprehensive logging with the following features:
- Console Logging: All logs output to stderr (colorized for better readability)
- File Logging: Persistent logs stored in
logs/directorycombined.log: All log levels (rotated, max 5MB, keeps 5 files)error.log: Error-level logs only (rotated, max 5MB, keeps 5 files)exceptions.log: Uncaught exceptionsrejections.log: Unhandled promise rejections
Log Structure: Each log entry includes timestamp, level, message, and structured metadata Performance Timing: Operations include execution timing for performance monitoring Operation Tracking: Each tool execution gets a unique operation ID for tracing
Disable file logging by setting "logToFile": false in your configuration.
On startup, the server automatically verifies vault access and logs the top 10 folders (by file count) in each vault. This helps confirm that:
- Vault paths are accessible
- File permissions are correct
- Expected content structure is present
Example verification output:
[INFO] Starting vault verification process
[INFO] Verifying vault access {"vaultName":"main","path":"/path/to/vault"}
[INFO] Top folders in vault {"vaultName":"main","folders":[
{"name":"notes","path":"notes","fileCount":45},
{"name":"projects","path":"projects","fileCount":23},
{"name":"archive","path":"archive","fileCount":12}
]}
[INFO] Vault verification completed {"vaultName":"main","foldersFound":8,"durationMs":156}
Disable verification by setting "verifyVaultsOnStartup": false in your configuration.
MIT
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request