This project provides a TypeScript implementation of the Obsidian Model Context Protocol (MCP) server. It allows AI models to interact with an Obsidian vault using the Obsidian Local REST API.
- Simple Search - Search for documents matching a specified text query across all files in the vault
- Complex Search - Search using JsonLogic queries for more advanced filtering
- List Files in Vault - Lists all files and directories in the root directory
- List Files in Directory - Lists all files and directories in a specific path
- Get Content - Get content from a single file
- Get Batch Contents - Get contents from multiple files at once
- Append Content - Append content to a new or existing file
- Patch Content - Insert content relative to a heading, block reference, or frontmatter field
- Note Summarization - Generate summaries for long notes
# Clone the repository
git clone https://github.com/DataScienceDisciple/obsidian-mcp.git
cd obsidian-mcp
# Install dependencies
npm install
# Build the project
npm run buildThis project implements a Model Context Protocol (MCP) server that can be used with MCP-compatible LLM clients like Claude.
# Start the MCP server (after building)
npm startFor development, you can use:
# Start with TypeScript directly (no build needed)
npm run dev
# Start with auto-reloading on file changes
npm run start:devThe MCP server communicates through standard input/output (stdio), so it's designed to be run by an MCP client.
-
Make sure you have Claude for Desktop installed. Download it here if you don't have it yet.
-
Make sure you've built the project with
npm run buildfirst. -
Open your Claude for Desktop App configuration:
MacOS:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows:
code $env:AppData\Claude\claude_desktop_config.json -
Add the Obsidian MCP server to the
mcpServerssection (create the file if it doesn't exist):MacOS:
{ "mcpServers": { "obsidian": { "command": "node", "args": ["/ABSOLUTE/PATH/TO/obsidian-mcp/dist/main.js"], "env": { "OBSIDIAN_API_KEY": "your_api_key_here" } } } }Windows:
{ "mcpServers": { "obsidian": { "command": "node", "args": ["C:\\ABSOLUTE\\PATH\\TO\\obsidian-mcp\\dist\\main.js"], "env": { "OBSIDIAN_API_KEY": "your_api_key_here" } } } }Replace
/ABSOLUTE/PATH/TO/obsidian-mcpwith the actual path to your project directory.Replace
your_api_key_herewith your actual Obsidian API key. This is essential - without this environment variable, the server won't be able to connect to your Obsidian vault. -
Save the file and restart Claude for Desktop.
-
When you open Claude for Desktop, you should see a hammer icon in the top right corner, indicating that MCP servers are available.
If the server isn't showing up in Claude Desktop:
- Make sure you've built the project with
npm run build - Make sure you've restarted Claude for Desktop completely
- Check your
claude_desktop_config.jsonfile syntax - Ensure the file paths in
claude_desktop_config.jsonare absolute, not relative - Verify that you've added the
envsection with yourOBSIDIAN_API_KEY - Look at Claude logs:
- macOS:
~/Library/Logs/Claude/mcp*.log - Windows:
%APPDATA%\Claude\logs\mcp*.log
- macOS:
- Node.js 16 or later
- Obsidian with the Local REST API plugin installed and configured
Here are examples of how to use the various tools:
This tool adds content to the end of a file:
Tool: obsidian_append_content
Arguments:
{
"filepath": "Projects/Project X.md",
"content": "New content to add at the end of the file"
}
This tool is for adding or modifying content at specific locations in a file:
Tool: obsidian_patch_content
Arguments:
{
"filepath": "π Periodic Notes/π Daily/2025-03-20.md",
"operation": "append",
"target_type": "heading",
"target": "2025-03-20::Notes",
"content": "Hello from Claude\n\n"
}
Tool: obsidian_patch_content
Arguments:
{
"filepath": "Projects/Development.md",
"operation": "prepend",
"target_type": "heading",
"target": "Development::Web Projects::Current",
"content": "- New project idea\n"
}
Tool: obsidian_patch_content
Arguments:
{
"filepath": "Projects/ProjectX.md",
"operation": "replace",
"target_type": "frontmatter",
"target": "status",
"content": "In Progress"
}
Simple text search:
Tool: obsidian_simple_search
Arguments:
{
"query": "project deadline",
"context_length": 150
}
Advanced search using JsonLogic query expressions for complex criteria:
Tool: obsidian_complex_search
Arguments:
{
"query": {
"and": [
{"glob": ["*.md", {"var": "path"}]},
{"in": ["#project", {"var": "tags"}]}
]
}
}
Get a single file:
Tool: obsidian_get_file_contents
Arguments:
{
"filepath": "Projects/Project X.md"
}
Get multiple files:
Tool: obsidian_batch_get_file_contents
Arguments:
{
"filepaths": [
"Projects/Project X.md",
"Projects/Project Y.md"
]
}
List all files at the root:
Tool: obsidian_list_files_in_vault
Arguments: {}
List files in a specific directory:
Tool: obsidian_list_files_in_dir
Arguments:
{
"dirpath": "Projects"
}
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue.
- Fork the project
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See the Contributing Guide for more information.
If you encounter any problems or have questions, please open an issue.