Skip to main content
Glama

mcp-obsidian

Obsidian Local REST API를 통해 Obsidian vault와 상호작용하는 MCP(Model Context Protocol) 서버입니다.

개요

Claude 등 MCP 클라이언트가 Obsidian vault의 파일을 읽고, 쓰고, 검색하는 기능을 Tool 형태로 제공합니다. Obsidian 커뮤니티 플러그인인 Local REST API를 통해 vault와 통신합니다.

Related MCP server: obsidian-mcp-server

디렉토리 구조

mcp-obsidian/
├── src/
│   └── mcp_obsidian/
│       ├── __init__.py     # 패키지 진입점, main() 함수 정의
│       ├── server.py       # MCP 서버 설정 및 tool 핸들러 등록
│       ├── tools.py        # 각 Tool 핸들러 클래스 정의
│       └── obsidian.py     # Obsidian REST API 클라이언트
├── pyproject.toml
└── README.md

파일별 기능

obsidian.py — REST API 클라이언트

Obsidian 클래스가 Obsidian Local REST API와 직접 통신합니다. 환경변수(OBSIDIAN_PROTOCOL, OBSIDIAN_HOST, OBSIDIAN_PORT)로 접속 정보를 설정하며, 모든 HTTP 요청에 Bearer 토큰 인증을 적용합니다.

메서드

설명

list_files_in_vault()

vault 루트의 파일/디렉토리 목록 조회

list_files_in_dir(dirpath)

특정 디렉토리의 파일 목록 조회

get_file_contents(filepath)

단일 파일 내용 반환

get_batch_file_contents(filepaths)

여러 파일 내용을 헤더와 함께 연결하여 반환

search(query, context_length)

텍스트 기반 단순 검색

search_json(query)

JsonLogic 쿼리 기반 복합 검색

append_content(filepath, content)

파일 끝에 내용 추가

patch_content(filepath, ...)

헤딩/블록/프론트매터 기준으로 내용 삽입

put_content(filepath, content)

파일 생성 또는 전체 내용 덮어쓰기

delete_file(filepath)

파일 또는 디렉토리 삭제

get_periodic_note(period, type)

현재 주기적 노트(일간/주간 등) 조회

get_recent_periodic_notes(period, limit, include_content)

최근 주기적 노트 목록 조회

get_recent_changes(limit, days)

최근 수정된 파일 목록 조회 (Dataview DQL 사용)


tools.py — Tool 핸들러

ToolHandler 추상 클래스를 기반으로 각 MCP Tool을 클래스로 구현합니다. 각 클래스는 get_tool_description()(Tool 스키마 반환)과 run_tool(args)(실제 실행)을 구현합니다.

클래스

Tool 이름

설명

ListFilesInVaultToolHandler

obsidian_list_files_in_vault

vault 루트의 전체 파일 목록

ListFilesInDirToolHandler

obsidian_list_files_in_dir

특정 디렉토리의 파일 목록

GetFileContentsToolHandler

obsidian_get_file_contents

단일 파일 내용 반환

BatchGetFileContentsToolHandler

obsidian_batch_get_file_contents

여러 파일 내용 일괄 반환

SearchToolHandler

obsidian_simple_search

텍스트 단순 검색

ComplexSearchToolHandler

obsidian_complex_search

JsonLogic 복합 검색

AppendContentToolHandler

obsidian_append_content

파일에 내용 추가

PatchContentToolHandler

obsidian_patch_content

헤딩/블록/프론트매터 기준 부분 수정

PutContentToolHandler

obsidian_put_content

파일 생성 또는 전체 교체

DeleteFileToolHandler

obsidian_delete_file

파일 삭제 (confirm 필수)

PeriodicNotesToolHandler

obsidian_get_periodic_note

현재 주기적 노트 조회

RecentPeriodicNotesToolHandler

obsidian_get_recent_periodic_notes

최근 주기적 노트 목록

RecentChangesToolHandler

obsidian_get_recent_changes

최근 수정 파일 목록

BlogConversionToolHandler

obsidian_convert_to_blog

노트를 블로그 포스팅 형식으로 변환 (커스텀)

BlogConversionToolHandler (커스텀 Tool 상세)

obsidian_convert_to_blog는 기존 Obsidian 노트를 블로그 포스팅 형식으로 변환하여 저장하는 커스텀 Tool입니다.

동작 방식

이 Tool은 단순히 파일을 저장하는 역할만 합니다. 변환 로직은 Tool의 description에 포함된 상세한 지시문을 통해 Claude가 직접 수행합니다.

  1. Claude가 obsidian_get_file_contents로 원본 노트를 먼저 읽음

  2. Claude가 description의 변환 규칙에 따라 processed_content 생성

  3. 이 Tool이 target_path에 결과물을 저장

입력 파라미터

파라미터

타입

설명

target_path

string

저장할 파일 경로 (vault 루트 기준 상대 경로)

processed_content

string

Claude가 변환 규칙에 따라 생성한 마크다운 문자열

변환 규칙 (Claude에 전달되는 지시문 요약)

  • 프론트매터: 없으면 title, cssclasses, tags, aliases를 포함한 YAML 추가

  • 문서 구조:

    • 최상단에 > [!summary] 💡 이 글의 핵심 callout (3~6개 불릿)

    • # 1. 들어가며 또는 # 1. 개념으로 시작

    • # 2., # 3. 번호 매긴 H2 본론 전개, 하위 항목은 ## 2.1 계층 구조

    • 마지막은 > [!example] Reference callout으로 마무리

  • 문체: 건조한 평서체 (~이다), 독자 유도 표현 사용, 이모지/인사말 없음

  • 포맷팅: 볼드(**), 하이라이트(==텍스트==), 표, 코드 블록(언어 명시), Callout 박스 활용

  • LaTeX: 인라인 $수식$, 블록 $$수식$$, 정렬 필요시 \begin{align} 사용


server.py — MCP 서버

MCP 서버를 초기화하고 모든 Tool 핸들러를 등록합니다. @app.list_tools()와 @app.call_tool() 핸들러를 통해 클라이언트 요청을 처리합니다. stdio_server를 통해 표준 입출력으로 통신합니다.

__init__.py — 패키지 진입점

server.py의 main() 함수를 노출하여 pyproject.toml의 스크립트 엔트리포인트(mcp-obsidian)에서 호출됩니다.

설정

환경 변수

변수

필수

기본값

설명

OBSIDIAN_API_KEY

필수

-

Obsidian Local REST API 키

OBSIDIAN_HOST

선택

127.0.0.1

Obsidian REST API 호스트

OBSIDIAN_PORT

선택

27124

Obsidian REST API 포트

OBSIDIAN_PROTOCOL

선택

https

통신 프로토콜 (http 또는 https)

.env 파일 또는 MCP 클라이언트 설정의 env 항목으로 지정할 수 있습니다.

설치 및 설정

사전 요구사항

Obsidian 커뮤니티 플러그인 Local REST API를 설치하고 활성화한 후 API 키를 복사합니다.

Claude Desktop 설정

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mcp-obsidian": {
      "command": "uvx",
      "args": ["mcp-obsidian"],
      "env": {
        "OBSIDIAN_API_KEY": "<your_api_key_here>",
        "OBSIDIAN_HOST": "<your_obsidian_host>",
        "OBSIDIAN_PORT": "<your_obsidian_port>"
      }
    }
  }
}
{
  "mcpServers": {
    "mcp-obsidian": {
      "command": "uv",
      "args": [
        "--directory",
        "<dir_to>/mcp-obsidian",
        "run",
        "mcp-obsidian"
      ],
      "env": {
        "OBSIDIAN_API_KEY": "<your_api_key_here>",
        "OBSIDIAN_HOST": "<your_obsidian_host>",
        "OBSIDIAN_PORT": "<your_obsidian_port>"
      }
    }
  }
}

개발

의존성 설치

uv sync

디버깅

MCP Inspector를 사용하면 Tool 호출을 브라우저에서 직접 테스트할 수 있습니다.

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

서버 로그 확인 (macOS):

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

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables Claude to interact with an Obsidian vault via the Local REST API plugin, supporting file operations, search, periodic notes, commands, and semantic search.
      22
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude Desktop to interact with an Obsidian vault through the Local REST API, allowing file listing, reading, searching, creating, and updating markdown notes.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables hybrid search, reading, writing, and managing a local Obsidian vault through MCP tools and a REST API, including section patching, appending, moving notes with link rewriting, and frontmatter updates.
      AGPL 3.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients such as Claude Desktop and Claude Code to list, read, search, write, append to, move, rename and delete Markdown notes, manage folders, tags and frontmatter, and create dated daily notes in a local vault, all without Obsidian running. Paths are confined to the vault root, though write and delete operations act directly on real files, so backups or version control are advised.
      MIT