MCP HubMCP Hub
MarkusPfundstein

mcp-obsidian

by: MarkusPfundstein

MCP server that interacts with Obsidian via the Obsidian rest API community plugin

643created 29/11/2024
Visit
Obsidian
API

📌Overview

Purpose: The MCP server for Obsidian enables users to interact with their Obsidian vault through a Local REST API, streamlining access to notes and file management.

Overview: This server acts as a bridge between the MCP platform and Obsidian, providing several tools to enhance productivity by allowing users to easily manipulate and retrieve data from their Obsidian vault.

Key Features:

  • File Management Tools: Includes functionalities like listing all files and directories in the vault, retrieving specific file contents, and appending or patching content in notes, facilitating efficient file organization and access.

  • Search Capability: Users can perform text queries across all documents, allowing for quick retrieval of information and better contextual understanding of terms or topics mentioned in the notes.

  • User-Friendly Configuration: Easy setup via server configurations or environment variables ensures a smooth integration with the existing Obsidian setup for both new and experienced users.


MCP Server for Obsidian

The MCP server allows interaction with Obsidian via the Local REST API community plugin.

Components

Tools

The server implements several tools to interact with Obsidian:

  • list_files_in_vault: Lists all files and directories in the root directory of your Obsidian vault.
  • list_files_in_dir: Lists all files and directories in a specific Obsidian directory.
  • get_file_contents: Returns the content of a single file in your vault.
  • search: Searches for documents matching a specified text query across all files in the vault.
  • patch_content: Inserts content into an existing note relative to a heading, block reference, or frontmatter field.
  • append_content: Appends content to a new or existing file in the vault.

Example Prompts

  • Get the contents of the last architecture call note and summarize them.
  • Search for all files where Azure CosmosDb is mentioned and explain the context in which it is mentioned.
  • Summarize the last meeting notes and create a new note 'summary meeting.md' with an introduction for email sharing.

Configuration

Obsidian REST API Key

You can configure the environment with the Obsidian REST API Key in two ways:

  1. Add to server config (preferred):

    {
      "mcp-obsidian": {
        "command": "uvx",
        "args": [
          "mcp-obsidian"
        ],
        "env": {
          "OBSIDIAN_API_KEY":"<your_api_key_here>"
        }
      }
    }
    
  2. Create a .env file in the working directory with the following:

    OBSIDIAN_API_KEY=your_api_key_here
    

Quickstart

Install

  1. Obsidian REST API: Install the Obsidian REST API community plugin and copy the API key from the settings.

  2. Claude Desktop Configuration:

    • On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • On Windows: %APPDATA%/Claude/claude_desktop_config.json

Server Configuration

Development/Unpublished Servers

{
  "mcpServers": {
    "mcp-obsidian": {
      "command": "uv",
      "args": [
        "--directory",
        "<dir_to>/mcp-obsidian",
        "run",
        "mcp-obsidian"
      ]
    }
  }
}

Published Servers

{
  "mcpServers": {
    "mcp-obsidian": {
      "command": "uvx",
      "args": [
        "mcp-obsidian"
      ],
      "env": {
        "OBSIDIAN_API_KEY": "<YOUR_OBSIDIAN_API_KEY>"
      }
    }
  }
}

Development

Building

To prepare the package for distribution:

uv sync

Debugging

For effective debugging, use the MCP Inspector:

npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-obsidian run mcp-obsidian

You can also monitor server logs:

tail -n 20 -f ~/Library/Logs/Claude/mcp-server-mcp-obsidian.log