Skip to main content
Glama
Obsidian MCP Server

Obsidian MCP Server

by sunub

Obsidian MCP Server

npm version

obsidian-mcp-server is an MCP server that allows AI agents to browse, search, and summarize Markdown documents in an Obsidian Vault.

Beyond simply reading documents, this project provides local hybrid search using transformers.js and includes an interactive CLI AI Agent UI that allows you to chat with your Vault directly from the terminal.

Key Features

  • πŸ” Hybrid Search: Combines keyword search with semantic (vector) search, providing optimal results through RRF (Reciprocal Rank Fusion) and Reranking.

  • πŸš€ Zero-Dependency Local AI: Uses @huggingface/transformers to run embedding and reranking models directly within the Node.js process (no external API server required).

  • πŸ’¬ Built-in CLI Agent: Provides a terminal-based UI that uses MCP tools to ask questions about Vault content and receive answers. View Details

  • πŸ“¦ Token Optimization: Offers various compression modes and output limits to control the AI agent's token usage.

Related MCP server: Obsidian MCP

What You Can Do (MCP Tools)

  • Integrated Search (vault, action="search"): Performs keyword and semantic-based searches simultaneously to find highly relevant documents.

  • Read Document (vault, action="read"): Retrieves the content and metadata of a specific note.

  • List and Stats (vault, action="list_all"|"stats"): Checks the overall status and file list of the Vault.

  • Collect Context (vault, action="collect_context"): Generates high-density knowledge packets related to a specific topic.

  • Load Knowledge (vault, action="load_memory"): Recalls saved memory snapshots.

  • Frontmatter Management (generate_property|write_property): Generates and applies AI-based metadata.

  • Organize Attachments (organize_attachments): Automatically moves images within documents to a dedicated folder and updates links.


Installation and Setup

1. Prerequisites

  • Node.js: v22.0.0 or higher

  • Obsidian Vault: You must know the absolute path.

2. Install Local AI Models (Required)

To enable semantic search and reranking features, you must download the necessary local models using the command below:

# 둜컬 μž„λ² λ”© 및 λ¦¬λž­ν‚Ή λͺ¨λΈ μ„€μΉ˜
npx @sunub/obsidian-mcp-server setup

Or, if you have already installed the package:

obsidian-mcp-server setup

This command downloads the Xenova/paraphrase-multilingual-MiniLM-L12-v2 (embedding) and Xenova/bge-reranker-base (reranking) models and saves them to the local cache.

3. Environment Variable Setup

Environment Variable

Default

Role

Required

VAULT_DIR_PATH

β€”

Absolute path to the Obsidian Vault

Required

LLM_API_URL

http://127.0.0.1:8080

Chat model API endpoint for CLI UI

Required for CLI

LLM_CHAT_MODEL

llama3

Model name to use for chat

Required for CLI

LOGGING_LEVEL

info

Log level (debug / info / warn / error)

Optional


MCP Client Configuration Example

In each client configuration, modify env.VAULT_DIR_PATH to your own Vault path.

Claude Desktop / Cursor / Copilot

{
  "mcpServers": {
    "obsidian": {
      "command": "npx",
      "args": ["-y", "@sunub/obsidian-mcp-server@latest"],
      "env": {
        "VAULT_DIR_PATH": "/Users/username/Documents/MyVault"
      }
    }
  }
}

How Hybrid Search Works

To capture semantic relationships that are difficult to find with traditional keyword search alone, it goes through the following pipeline:

  1. Keyword Search: Extracts exact word matching results via the internal Indexer.

  2. Vector Search: Searches for semantically similar chunks using LanceDB and transformers.js embeddings.

  3. RRF Fusion: Merges the rankings of both search results using the Reciprocal Rank Fusion algorithm.

  4. Local Reranking: Re-evaluates the merged top results with the BGE Reranker model to determine the final ranking.

If the models are not installed, it automatically operates in keyword-only mode and displays a message in the terminal recommending the execution of npx @sunub/obsidian-mcp-server setup.


Interactive CLI AI Agent UI

This project includes a terminal-based AI chat interface optimized for Obsidian Vault.

Features

  • RAG Integration: Automatically collects relevant context from the Vault when asked a question and passes it to the LLM.

  • Real-time Streaming: Renders the LLM's response and "thought process ()" in real-time.

  • Slash Commands: MCP tools such as /search, /read, and /index can be called directly as commands from the CLI.

  • Multi-MCP Management: Monitors the status and tool list of all connected MCP servers.

How to Run

  1. Run Chat Model Server: Start a server like llama.cpp or Ollama in OpenAI-compatible mode.

    • Example: llama-server -m models/gemma-2-9b-it.Q4_K_M.gguf --port 8080

  2. Run CLI:

    # ν™˜κ²½λ³€μˆ˜μ™€ ν•¨κ»˜ μ‹€ν–‰
    VAULT_DIR_PATH="/your/vault" LLM_API_URL="http://localhost:8080" npx @sunub/obsidian-mcp-server

Slash Command Help

  • /search <keyword>: Execute hybrid search

  • /read "filename": Read a specific document

  • /stats: Check Vault status

  • /index: Force re-indexing of the vector DB

  • /tools: View a list of all available MCP tools

  • /help: View help


License

Apache-2.0

Available Tools

5 tools
create_document_with_propertiesCreate Document with PropertiesAInspect

Starts and completes a two-step workflow for AI-generated frontmatter properties.

Step 1: Call this tool with sourcePath (and optional outputPath). It returns a structured instruction payload and a content preview for AI analysis. Step 2: Call this same tool again with aiGeneratedProperties. The tool then writes those properties by executing the same write logic used by the 'write_property' tool.

Use this tool when an AI agent should orchestrate analysis and write in a consistent workflow.

Inputs: sourcePath (required), quiet, overwrite, outputPath, +1 more.

generate_propertyGenerate Obsidian PropertyAInspect

Reads a target markdown document and returns an AI-facing payload for generating frontmatter properties.

This tool does not write to disk. It returns content_preview and a target output schema so an AI can produce a valid property object.

Use Cases:

  • After completing a draft, when you need property suggestions from content.

  • When missing frontmatter fields (title, tags, summary, slug, date, category, completed) should be generated.

To apply generated properties to a file, call 'write_property' with the resulting JSON.

Inputs: filename (required), overwrite.

organize_attachmentsOrganize AttachmentsAInspect

Scans a specified markdown file for linked images (or other attachments), moves them to a dedicated folder named after the document's title, and updates the links within the markdown file automatically.

Use Cases:

  • When a post is finalized and you want to clean up all associated images into a neat folder.

  • To automatically organize attachments for better vault management.

Example Workflow:

  1. Specify 'my-awesome-post.md' as the fileName.

  2. The tool finds the 'title' property in the frontmatter (e.g., "My Awesome Post").

  3. It finds all image links like ![[my-image.png]].

  4. It creates a folder at '{vault}/images/My Awesome Post/'.

  5. It moves 'my-image.png' into that new folder.

  6. It updates the link in the markdown file to ![[images/My Awesome Post/my-image.png]].

Inputs: keyword (required), quiet, destination, useTitleAsFolderName.

vaultObsidian Content GetterAInspect

Retrieves and searches the content of Markdown (.md, .mdx) documents stored in an Obsidian vault. Use this tool to find notes related to a specific topic or keyword and understand their core content.

When to use:

  • When you need to find a specific note by its title or a keyword to check its content.

  • When you want to synthesize and summarize information scattered across multiple notes.

  • When looking for answers to questions based on your saved records, such as "What was the project deadline?"

  • To discover connections by finding all notes that link to a specific note.

  • When you need to retrieve a list of unfinished tasks (- [ ]) from daily notes or meeting minutes.

  • Use "index_vault_to_vectordb" to manually trigger a full re-indexing of the vault for the vector database.

Returns the content of the most relevant document(s) in text format. It can also include metadata such as the document's title, tags, and creation date.

Requirements: The user's Obsidian Vault path must be correctly configured in an environment variable or a similar setting. For searches, use the exact filename or include core keywords for content-based queries.

IMPORTANT INSTRUCTION FOR AI: If the tool response includes a 'diagnostic_message' (usually found at the beginning of the text or in a <system_directive> tag), you MUST relay this information to the user exactly once. It contains essential advice on how to improve search quality by running a local setup script via 'npx @sunub/obsidian-mcp-server setup'. Do not ignore it.

Inputs: action (required), limit, query, quiet, +14 more.

write_propertyWrite Obsidian PropertyAInspect

Description: Adds or updates properties within the frontmatter section at the top of a specified Obsidian markdown file. This tool is primarily used to apply metadata generated by the 'generate_property' tool to an actual file.

Parameters:

  • filePath (string, required): The path to the target markdown file to which properties will be added or updated. Example: "my-first-post.md"

  • properties (object, required): A JSON object containing the key-value pairs to be written to the file's frontmatter. If a property with the same key already exists in the file, it will be overwritten with the new value.

Example:

JSON { "title": "Optimizing I/O Handling in a Serverless Environment", "date": "2025-04-03", "tags": ["serverless", "optimization"], "summary": "A case study on optimizing I/O in a serverless environment by benchmarking Promise.all and Workers.", "completed": true }

Return Value:

Upon successful execution, it returns a JSON object containing the status, a confirmation message, and the property object that was applied to the file.

Example:

JSON { "status": "success", "message": "Successfully updated properties for my-first-post.md", "properties": { "title": "Optimizing I/O Handling in a Serverless Environment", "date": "2025-04-03", "tags": ["serverless", "optimization"], "summary": "A case study on optimizing I/O in a serverless environment by benchmarking Promise.all and Workers.", "completed": true } }

Dependencies & Requirements:

  • Input Data: The properties parameter should typically be the JSON object output from the 'generate_property' tool.

  • Environment Setup: The absolute path to the user's Obsidian Vault must be correctly set as an environment variable.

Inputs: filePath (required), properties (required), quiet.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 5 tools

    Disambiguation2/5

    Several tools have overlapping boundaries: generate_property and create_document_with_properties both handle AI-generated frontmatter analysis, while write_property and create_document_with_properties both perform the write step. Only vault and organize_attachments are clearly distinct.

    Naming Consistency4/5

    Most tools follow a clear verb_noun snake_case pattern like write_property and organize_attachments, but 'vault' breaks the pattern as a noun-only tool name. The naming is otherwise consistent and readable.

    Tool Count4/5

    Five tools is a reasonable size for an Obsidian-focused server, but the functionality of generate_property, write_property, and create_document_with_properties overlaps enough that the set feels slightly padded. Still, the overall count is well within an appropriate range.

    Completeness3/5

    The tool set covers vault search/read, frontmatter generation and writing, and attachment organization, but lacks broader note lifecycle operations such as creating a simple note, editing note body content, deleting files, or listing vault contents. The metadata workflow is mostly complete, but general note management has notable gaps.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables AI assistants to read, write, search, and navigate Obsidian vault notes with support for CRUD operations, full-text search, graph navigation, daily notes, and frontmatter management.
      3,650 npm
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to manage Obsidian vaults through full CRUD operations, wikilink management, and section-level manipulation. It supports frontmatter editing, tag-based searching, and automated link updates to maintain vault integrity.
      MIT
    • A
      license
      A
      quality
      A
      maintenance
      Standalone MCP server for Obsidian vaults - hybrid search (FTS5 + vector + reranking), files in agent-readable form (images, PDFs, canvases, HTML, scripts, data files), Kanban-aware tasks (Tasks-plugin + Dataview formats), structured memory with topic recall, fine-grained read/write tools, and link graph support. Run locally, self-host, or one-click deploy for remote access. OAuth 2.1.
      16
      35
      39
      MIT

    Appeared in Searches