Skip to main content
Glama
HY2MHY

obsidian-knowledge-mcp

by HY2MHY
README.md
# Obsidian Knowledge MCP

> A private-by-default MCP server that lets AI clients search, read, and traverse a local Obsidian vault without uploading it to an external index.

**Status:** public-safe prototype · **Role:** independent design and implementation · **Origin:** sanitized reconstruction of a knowledge-retrieval component built during a 2026 summer automation project.

[中文说明](README.zh-CN.md) · [Bilingual docs index](docs/README.md) · [Architecture](docs/ARCHITECTURE.md) · [Evaluation](docs/EVALUATION.md) · [Failure analysis](docs/FAILURE_ANALYSIS.md)

## What it demonstrates

- Five read-only MCP tools for discovery, evidence reading, graph navigation, and vault health.
- Transparent ranking: exact phrase + title/heading boosts + English tokens + Chinese 2-grams.
- Source-grounded results with vault-relative paths, headings, excerpts, scores, and pagination.
- Local privacy boundary: no cloud index, no API key, hidden folders excluded, path traversal rejected.
- MCP Python SDK 2.x, structured output, annotations, in-memory integration tests, and a synthetic demo vault.

## Tools

| Tool | Workflow role |
|---|---|
| `obsidian_search_notes` | Find relevant note sections with filters and pagination |
| `obsidian_read_note` | Read one note or an exact heading as evidence |
| `obsidian_list_notes` | Browse by folder prefix or tag |
| `obsidian_find_backlinks` | Follow Obsidian `[[wikilinks]]` back to related notes |
| `obsidian_vault_stats` | Inspect vault size, link count, and top tags |

All tools are declared read-only and closed-world. The server never edits the vault.

## Quick start

Requirements: Python 3.10+ and [`uv`](https://docs.astral.sh/uv/).

```bash
git clone <your-repository-url>
cd obsidian-knowledge-mcp
uv sync --extra dev
export OBSIDIAN_VAULT_PATH="/absolute/path/to/your/Obsidian Vault"
uv run obsidian-knowledge-mcp
```

The process uses stdio and waits for an MCP client. For an interactive inspection UI:

```bash
uv run mcp dev src/obsidian_knowledge_mcp/server.py
```

Run the included sample vault ([English demo](demo/README.md) · [中文演示](demo/README.zh-CN.md)):

```bash
export OBSIDIAN_VAULT_PATH="$PWD/examples/sample_vault"
uv run mcp dev src/obsidian_knowledge_mcp/server.py
```

## Client configuration

Use an absolute path to the repository and vault:

```json
{
  "mcpServers": {
    "obsidian-knowledge": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/obsidian-knowledge-mcp",
        "run",
        "obsidian-knowledge-mcp"
      ],
      "env": {
        "OBSIDIAN_VAULT_PATH": "/absolute/path/to/your/Obsidian Vault"
      }
    }
  }
}
```

## Test and lint

```bash
uv run pytest
uv run ruff check .
```

The tests cover ranking, Chinese retrieval, filters, pagination, section reads, backlink resolution, hidden-folder exclusion, traversal prevention, tool discovery, and structured MCP responses.

## Privacy and security

- Keep private vaults local; do not commit them to this repository.
- Only Markdown under `OBSIDIAN_VAULT_PATH` is scanned.
- `.obsidian`, `.git`, `.trash`, `node_modules`, and `attachments` are excluded by default.
- Returned paths are vault-relative, not absolute.
- The project contains only synthetic sample notes. It does not contain employer data, chat exports, credentials, or production identifiers.

## Current limitations

- Ranking is lexical, not embedding-based; distant paraphrases may need query reformulation.
- Wiki-link resolution does not implement every Obsidian alias or duplicate-title edge case.
- The index is rebuilt per tool call in v0.1; a watched incremental cache is a future optimization.
- The server trusts the local OS user who launches it. It is not a multi-tenant remote service.

## Project map

```text
src/obsidian_knowledge_mcp/  search engine and MCP adapter
tests/                       unit and in-memory MCP integration tests
examples/sample_vault/       synthetic, reproducible demo data
eval/                        stable evaluation questions
docs/                        architecture, case, PRD, evaluation, failures
```

## License

MIT. See [LICENSE](LICENSE).

TDQS

A4.4/5.0

Scored across 5 tools

Disambiguation5/5

Each tool serves a clearly distinct purpose: reading a specific note, searching content, browsing by folder/tag, finding backlinks, and viewing vault stats. There is no meaningful overlap between tools, and the descriptions reinforce when to use each one.

Naming Consistency4/5

Tool names follow a consistent snake_case pattern with the common `obsidian_` prefix, using clear action-noun combinations like `read_note`, `search_notes`, and `list_notes`. `vault_stats` is the only name that deviates from the verb-object pattern, but the convention remains predictable overall.

Tool Count5/5

Five tools is a well-scoped set for an Obsidian knowledge retrieval server. Each tool adds a distinct capability without redundancy, and the count is neither too thin nor bloated for the domain.

Completeness5/5

For a read-only knowledge retrieval surface, the tool set covers discovery, browsing, targeted reading, relationship exploration via backlinks, and vault-level stats. Search and list together handle navigation, while backlinks cover knowledge graph traversal; no obvious retrieval workflow is missing.

Maintenance

ActivityMaintained
ResponsivenessNo issues