bazylhorsey/obsidian-mcp-server
If you are the rightful owner of obsidian-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
Obsidian MCP Server is a comprehensive Model Context Protocol (MCP) server designed for Obsidian, providing advanced vault access, knowledge graph analysis, and integration features.
Obsidian MCP Server
A comprehensive Model Context Protocol (MCP) server for Obsidian that provides powerful vault access, knowledge graph analysis, and advanced integration features.
📚 Documentation
- - Get up and running in 5 minutes
- - Connect to Claude Desktop
- - Understanding local/remote/API configurations
- - Running tests and contributing
- - Complete tool reference
Features
🗂️ Multi-Vault Support
- Local Vaults: Direct file system access with real-time file watching
- Remote Vaults: HTTP/REST API integration with automatic sync
- Seamless switching between multiple vaults
🔗 Knowledge Graph
- Build and analyze complete knowledge graphs from your notes
- Find related notes based on links, tags, and content similarity
- Analyze graph structure (hubs, orphan notes, clusters)
- Suggest potential links between related notes
- Path finding between notes
🔍 Advanced Search
- Full-text search across all notes
- Filter by tags, folders, and metadata
- Server-side and client-side search strategies
📝 Note Operations
- Read, create, update, and delete notes
- Parse Obsidian-flavored markdown with frontmatter
- Extract and track internal links, embeds, and tags
- Automatic backlink generation
📊 Analytics
- Vault statistics (note count, word count, link count)
- Tag usage analysis
- Folder structure insights
🎯 Obsidian Integration
- Optional integration with community "Local REST API" plugin
- Open notes directly in Obsidian app
- Execute Obsidian commands
- Create daily notes
- Access to Obsidian URI protocol
- Note: Requires plugin installation and app running locally
🎨 Canvas Support
- Read and manipulate Obsidian Canvas files
- Create and edit canvas nodes (file, text, link, group)
- Manage canvas edges and connections
- Full graph visualization support
- Programmatic canvas generation
📊 Dataview Queries
- SQL-like querying over your notes
- Filter by frontmatter metadata and inline fields
- Sort and group results
- Field selection and aggregation
- Support for complex WHERE clauses
- Extract metadata from notes (frontmatter + inline fields)
📝 Template System
- Dynamic template rendering with variable substitution
- Built-in date/time variables (
{{date}},{{time}},{{weekday}}, etc.) - Custom variable support
- Default values (
{{variable|default}}) - Date formatting (
{{date:YYYY-MM-DD}}) - Frontmatter merging
- Create notes from templates programmatically
📅 Periodic Notes
- Daily, weekly, monthly, and yearly notes
- Automatic date-based naming and organization
- Custom templates for each note type
- Date range calculations
- List and query periodic notes
- Configurable folder structure and formats
Architecture
The server is built with a clean, modular architecture:
┌─────────────────────────────────────────┐
│ MCP Server Layer │
│ (Tools, Resources, Protocol Handling) │
└──────────────┬──────────────────────────┘
│
┌──────────────┴──────────────────────────┐
│ Service Layer │
│ • Knowledge Graph Service │
│ • Canvas Service │
│ • Dataview Service │
│ • Template Service │
│ • Periodic Notes Service │
│ • Configuration Management │
└──────────────┬──────────────────────────┘
│
┌──────────────┴──────────────────────────┐
│ Connector Layer (Adapters) │
│ • Local Vault Connector (File System) │
│ • Remote Vault Connector (HTTP API) │
└──────────────┬──────────────────────────┘
│
┌──────────────┴──────────────────────────┐
│ Integration Layer │
│ • Obsidian API Client │
│ • Markdown Parser │
└──────────────────────────────────────────┘
Key Design Patterns
- Adapter Pattern: Abstract
BaseConnectorinterface allows seamless switching between local and remote vaults - Service Layer: Separates business logic (knowledge graph) from data access
- Configuration Management: Flexible config from files, environment, or defaults
- Real-time Updates: File watchers for local vaults, periodic sync for remote
Installation
npm install
npm run build
Configuration
Create a obsidian-mcp.json configuration file:
{
"vaults": [
{
"name": "my-local-vault",
"type": "local",
"path": "/path/to/obsidian/vault"
},
{
"name": "my-cloud-vault",
"type": "remote",
"url": "https://your-sync-server.com/api",
"apiKey": "your-api-key",
"syncInterval": 60000
}
],
"obsidianApi": {
"restApiUrl": "http://localhost:27124",
"apiKey": "your-api-key",
"vaultName": "my-local-vault"
},
"server": {
"name": "obsidian-mcp-server",
"version": "1.0.0"
}
}
Vault Types Explained
Local Vault (type: "local")
- Direct filesystem access to your Obsidian vault folder
- Fastest performance, real-time file watching
- Use this for vaults stored on your computer or mounted network drives
Remote Vault (type: "remote")
- Connects to a self-hosted sync server via HTTP/REST API
- For vaults hosted on your own cloud infrastructure (not Obsidian's sync service)
- Examples: Custom REST API, CouchDB, WebDAV wrapper, etc.
- Requires you to implement or use a compatible sync server
Obsidian API (Optional)
- Only needed if you want to control the Obsidian desktop app
- Requires the "Local REST API" community plugin in Obsidian
- Enables: Opening notes in app, executing commands, accessing app features
- NOT used for reading/writing vault content (use local/remote vaults for that)
Configuration via Environment Variables
Alternatively, use environment variables:
# Local vault
export OBSIDIAN_VAULT_PATH="/path/to/vault"
export OBSIDIAN_VAULT_NAME="my-vault"
# Remote vault
export OBSIDIAN_REMOTE_URL="https://your-sync-server.com/api"
export OBSIDIAN_REMOTE_NAME="cloud"
export OBSIDIAN_REMOTE_API_KEY="your-key"
export OBSIDIAN_SYNC_INTERVAL="60000"
# Obsidian API (optional)
export OBSIDIAN_API_URL="http://localhost:27124"
export OBSIDIAN_API_KEY="your-key"
Common Configuration Scenarios
Scenario 1: Just a local vault (most common)
{
"vaults": [
{
"name": "personal",
"type": "local",
"path": "/home/user/Documents/ObsidianVault"
}
]
}
Scenario 2: Local vault + iCloud/Dropbox (also use local type)
{
"vaults": [
{
"name": "synced",
"type": "local",
"path": "/home/user/iCloud/ObsidianVault"
}
]
}
Note: iCloud/Dropbox sync is handled by the cloud service itself - just point to the synced folder.
Scenario 3: Multiple local vaults
{
"vaults": [
{
"name": "personal",
"type": "local",
"path": "/home/user/Documents/PersonalVault"
},
{
"name": "work",
"type": "local",
"path": "/home/user/Documents/WorkVault"
}
]
}
Scenario 4: Self-hosted remote server (advanced)
{
"vaults": [
{
"name": "cloud",
"type": "remote",
"url": "https://your-server.com/obsidian-api",
"apiKey": "your-api-key",
"syncInterval": 60000
}
]
}
Note: Requires you to implement or deploy a compatible REST API server.
Usage
Start the Server
npm start
Or use the binary:
node dist/index.js
Available MCP Tools
The server exposes the following tools through the MCP protocol:
Note Operations
get_note- Retrieve a note by pathsearch_notes- Search notes with filterscreate_note- Create a new noteupdate_note- Update existing notedelete_note- Delete a note
Vault Information
get_vault_stats- Get vault statisticslist_tags- List all tagslist_folders- List all folders
Knowledge Graph
get_knowledge_graph- Get complete graph structureget_related_notes- Find related notesanalyze_graph- Analyze graph structuresuggest_links- Suggest potential links
Canvas Operations
get_canvas- Read a canvas filecreate_canvas- Create a new empty canvaslist_canvas_files- List all canvas files in vaultadd_canvas_node- Add a node (file, text, link, or group)add_canvas_edge- Add an edge/connection between nodesdelete_canvas_node- Delete a node from canvasdelete_canvas_edge- Delete an edge from canvas
Dataview Queries
dataview_query- Execute Dataview-style queries on notesget_note_metadata- Get metadata for a specific noteget_unique_values- Get all unique values for a field
Template System
list_templates- List all available templatesrender_template- Render a template with variablescreate_from_template- Create a new note from a template
Periodic Notes
create_daily_note- Create or get daily notecreate_weekly_note- Create or get weekly notecreate_monthly_note- Create or get monthly notecreate_yearly_note- Create or get yearly noteget_periodic_note_info- Get info about a periodic notelist_periodic_notes- List periodic notes in a date range
MCP Resources
All notes are exposed as resources with URIs:
obsidian://{vault-name}/{note-path}
Development
Project Structure
src/
├── index.ts # Main MCP server
├── types/ # TypeScript type definitions
│ ├── index.ts # Core types
│ ├── canvas.ts # Canvas types
│ ├── dataview.ts # Dataview types
│ ├── template.ts # Template types
│ └── periodic.ts # Periodic notes types
├── connectors/ # Vault connectors (adapters)
│ ├── BaseConnector.ts
│ ├── LocalConnector.ts
│ └── RemoteConnector.ts
├── services/ # Business logic services
│ ├── KnowledgeGraph.ts # Knowledge graph analysis
│ ├── CanvasService.ts # Canvas file operations
│ ├── DataviewService.ts # Dataview query processing
│ ├── TemplateService.ts # Template rendering
│ └── PeriodicNotesService.ts # Periodic notes management
├── api/ # External API integrations
│ └── ObsidianAPI.ts
└── utils/ # Utilities
├── config.ts
└── markdown.ts
Build
npm run build
Watch Mode
npm run watch
Integration with Obsidian
For advanced features, install the Obsidian Local REST API plugin:
- Install the plugin from Obsidian Community Plugins
- Enable the plugin and note the API key
- Configure the
obsidianApisection in your config
Use Cases
For AI Assistants
- Access and navigate your Obsidian knowledge base
- Create and update notes based on conversations
- Find related information across notes
- Suggest connections between ideas
For Automation
- Automated note creation and organization
- Batch processing of notes
- Knowledge graph analysis and visualization
- Link maintenance and suggestions
For Integrations
- Connect Obsidian with other tools via MCP
- Build custom workflows
- Create dashboards and reports
- Sync with external systems
Advanced Features
Canvas Support
Obsidian Canvas is a powerful visual workspace. This server provides full programmatic access to create and manipulate canvas files:
Example: Create a visual mind map
// Create a new canvas
await mcp.callTool('create_canvas', { canvasPath: 'diagrams/mindmap.canvas' });
// Add nodes
await mcp.callTool('add_canvas_node', {
canvasPath: 'diagrams/mindmap.canvas',
nodeType: 'file',
file: 'notes/central-idea.md',
x: 0, y: 0, width: 400, height: 200
});
await mcp.callTool('add_canvas_node', {
canvasPath: 'diagrams/mindmap.canvas',
nodeType: 'text',
text: '# Key Concept',
x: 500, y: 0, width: 300, height: 150,
color: '1' // Red
});
// Connect nodes with edges
await mcp.callTool('add_canvas_edge', {
canvasPath: 'diagrams/mindmap.canvas',
fromNode: 'node-id-1',
toNode: 'node-id-2',
label: 'relates to'
});
Dataview Queries
Query your notes like a database with SQL-like syntax:
Example: Find recent project notes
await mcp.callTool('dataview_query', {
query: {
from: '#project',
where: [
{ field: 'status', operator: 'eq', value: 'active' },
{ field: 'modified', operator: 'gte', value: '2024-01-01' }
],
sort: [{ field: 'modified', direction: 'desc' }],
limit: 10
}
});
Example: Group notes by tag
await mcp.callTool('dataview_query', {
query: {
from: 'projects/',
groupBy: 'status',
select: ['title', 'modified', 'tags']
}
});
Example: Get metadata from inline fields
// Note content: "Status:: In Progress\nPriority:: High"
const metadata = await mcp.callTool('get_note_metadata', {
notePath: 'projects/my-project.md'
});
// Returns: { status: 'In Progress', priority: 'High', ... }
Template System
Create reusable templates with variable substitution and automatic date handling:
Example: Create a meeting note template
---
tags: [meeting]
templateVariables:
- name: attendees
type: string
description: Meeting attendees
---
# Meeting: {{title}}
**Date:** {{date}}
**Time:** {{time}}
**Attendees:** {{attendees|TBD}}
## Agenda
-
## Notes
## Action Items
- [ ]
Example: Use the template
await mcp.callTool('create_from_template', {
templatePath: 'Templates/meeting.md',
targetPath: 'Meetings/2024-01-15-team-sync.md',
variables: {
attendees: 'Alice, Bob, Charlie'
},
frontmatter: {
project: 'Q1 Planning'
}
});
Built-in Variables:
{{date}}- Current date (YYYY-MM-DD){{time}}- Current time (HH:mm){{datetime}}- Current datetime{{year}},{{month}},{{day}}- Date components{{weekday}}- Day of week (Monday, Tuesday, etc.){{week}}- Week number (01-53){{title}},{{filename}},{{folder}}- File context
Periodic Notes
Automatically create and organize daily, weekly, monthly, and yearly notes:
Example: Create today's daily note
await mcp.callTool('create_daily_note', {
vault: 'my-vault'
});
// Creates: Daily Notes/2024-01-15.md
Example: Create this week's note
await mcp.callTool('create_weekly_note', {
vault: 'my-vault',
variables: {
goals: 'Complete project proposal'
}
});
// Creates: Weekly Notes/2024-W03.md
Example: List all monthly notes
await mcp.callTool('list_periodic_notes', {
vault: 'my-vault',
type: 'monthly',
startDate: '2024-01-01',
endDate: '2024-12-31'
});
Configuration: Periodic notes can be configured with custom folders, formats, and templates:
{
"periodicNotes": {
"daily": {
"folder": "Journal/Daily",
"format": "YYYY-MM-DD",
"template": "Templates/daily-note.md"
},
"weekly": {
"folder": "Journal/Weekly",
"format": "YYYY-[W]WW"
}
}
}
Technical Highlights
Markdown Parsing
- Full support for Obsidian-flavored markdown
- Frontmatter extraction (YAML)
- Internal link parsing (
[[link]],[[link|alias]]) - Embed detection (
![[embed]]) - Tag extraction (
#tag,#nested/tag) - Inline field parsing (
key:: valuepattern)
Canvas Operations
- Complete Canvas file format support (JSON-based)
- All node types: file, text, link, group
- Edge/connection management with customization
- Color and styling support
- Programmatic canvas generation
Dataview Integration
- SQL-like query language for notes
- Multiple filter operators (eq, neq, gt, gte, lt, lte, contains, startsWith, endsWith, exists)
- Sorting and grouping capabilities
- Field selection and projection
- Support for frontmatter and inline fields
- Nested field access with dot notation
Template System
- Variable substitution with
{{variable}}syntax - Built-in date/time variables with formatting
- Default values:
{{variable|default}} - Date formatting:
{{date:YYYY-MM-DD}} - Frontmatter merging and manipulation
- Template discovery and listing
Periodic Notes
- Automatic date-based note generation
- Configurable folder structure and naming
- Template integration for custom layouts
- Date range calculations (daily, weekly, monthly, yearly)
- ISO week number support
- Flexible date format patterns
Link Resolution
- Smart link resolution (title-based and path-based)
- Automatic backlink generation
- Bidirectional link tracking
Performance
- Efficient caching strategies
- File watching for instant updates
- Lazy loading and pagination support
Security Considerations
- Local vaults: Requires file system access to vault directory
- Remote vaults: Use HTTPS and secure API keys
- API keys: Never commit to version control
- File watching: Only monitors
.mdfiles
Requirements
- Node.js 18 or higher
- TypeScript 5.x
- Access to Obsidian vault(s)
License
MIT
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
Related Projects
- Obsidian - The knowledge base application
- Obsidian Local REST API - REST API plugin
- Model Context Protocol - MCP specification
Support
For issues and questions:
- GitHub Issues: Create an issue
- Documentation: See this README
Built with ❤️ for the Obsidian and MCP communities