MCP server for agent-safe Obsidian vault access with lint validation
Project description
obsidian-mcp-guard
An MCP server for agent-safe Obsidian vault access. Provides read/write file tools with lint validation to prevent agents from writing malformed Obsidian markdown.
Why this exists
Most Obsidian MCP servers give agents direct write access with no markdown validation. Those that route through the Obsidian REST API gain some input sanitisation, but none validate content against Obsidian's markdown rendering rules before writing. obsidian-mcp-guard fills this gap: all writes are validated against Obsidian's markdown rules before they touch the vault, and if the content would render incorrectly, the write is rejected with a structured error explaining exactly which rule was violated. Writes can also be constrained to a single configurable vault path, giving agents a designated space to create and manage content on behalf of the user while preventing accidental or runaway writes to other vaults on the same filesystem. Directory traversal attacks are blocked at the path resolution layer, so a misconfigured, misbehaving, or prompt-injected agent cannot escape the write vault by constructing paths like Claude/../OtherVault/note.md
Features
- Read/list/create/update/delete/move notes via
HOST_VAULT_PATHon the host filesystem - Lint validation on all writes using mdlint-obsidian — blocks writes that violate Obsidian markdown rules (unclosed wikilinks, raw HTML, standard-markdown links, etc.)
- Write-vault isolation — writes are constrained to a single configurable vault; directory-traversal attacks are blocked on both read and write paths
- Composable —
create_vault_server()returns aFastMCPinstance that can be mounted into a larger server viaimport_server() - Pre-validation tool —
lint_notelets agents check content before committing a write
Installation
pip install obsidian-mcp-guard
For Claude Desktop users who don't want a manual install, uvx runs it directly with no setup:
uvx obsidian-mcp-guard
For local development:
python -m venv .venv
source .venv/bin/activate
pip install -e .
Configuration
| Environment variable | Default | Description |
|---|---|---|
HOST_VAULT_PATH |
(required) | Absolute path to the directory containing your vaults as subdirectories |
WRITE_VAULT |
Claude |
Name of the only vault where write operations are permitted |
Example layout expected under HOST_VAULT_PATH:
/path/to/your/vaults/
Claude/ ← write operations land here
Work/ ← readable but not writable
Personal/ ← readable but not writable
Usage
As a standalone stdio server
# via the installed CLI entry point
HOST_VAULT_PATH=/path/to/your/vaults obsidian-mcp-guard
# or via python -m
HOST_VAULT_PATH=/path/to/your/vaults python -m obsidian_mcp_guard
Claude Desktop / Cursor config
{
"mcpServers": {
"obsidian": {
"command": "uvx",
"args": ["obsidian-mcp-guard"],
"env": {
"HOST_VAULT_PATH": "/path/to/your/vaults",
"WRITE_VAULT": "Claude"
}
}
}
}
Claude Code
claude mcp add obsidian -- uvx obsidian-mcp-guard
Pass environment variables with -e:
claude mcp add obsidian -e HOST_VAULT_PATH=/path/to/your/vaults -e WRITE_VAULT=Claude -- uvx obsidian-mcp-guard
Mounted into another FastMCP server
from contextlib import asynccontextmanager
from fastmcp import FastMCP
from obsidian_mcp_guard import create_vault_server
@asynccontextmanager
async def lifespan(app):
await app.import_server(create_vault_server(
vault_path="/path/to/your/vaults",
write_vault="Claude"
))
yield
mcp = FastMCP("my-agent", lifespan=lifespan)
@mcp.tool()
def search_notes(...):
...
Tools
| Tool | Description |
|---|---|
read_note(source) |
Return full content of a note in vault/path.md format |
list_notes(vault, folder?, recursive?) |
List note paths within a vault or subfolder |
create_note(source, content, overwrite?) |
Create a note; blocked by lint errors |
update_note(source, content, mode?) |
Overwrite or append to a note; blocked by lint errors |
delete_note(source) |
Move a note to .trash/ (recoverable) |
move_note(source_path, dest_path, create_dirs?) |
Move a note within the write vault; rewrites wikilinks in all vault files |
lint_note(content) |
Pre-validate content without writing; returns {valid, errors, warnings} |
Development
make install # install package + test dependencies
make test # run tests with coverage (90% minimum)
make build # build source and wheel distributions
make clean # remove build artefacts and cache files
See CONTRIBUTING.md for full guidelines.
Related projects
- mdlint-obsidian — the lint engine used to validate markdown against Obsidian's rendering rules
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file obsidian_mcp_guard-0.1.8.tar.gz.
File metadata
- Download URL: obsidian_mcp_guard-0.1.8.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ea4e663c9cbbbd698d3ae1c1e7661f885eef8cbb26076ee1515050b3b233af2
|
|
| MD5 |
e9ee3e14f4b2edf939af555da37dbe0b
|
|
| BLAKE2b-256 |
b49b55b59ecbceb97f812497792679703f685f984f3f11c3ac589e763f6ff9b7
|
Provenance
The following attestation bundles were made for obsidian_mcp_guard-0.1.8.tar.gz:
Publisher:
python-publish.yml on codeafix/obsidian-mcp-guard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
obsidian_mcp_guard-0.1.8.tar.gz -
Subject digest:
0ea4e663c9cbbbd698d3ae1c1e7661f885eef8cbb26076ee1515050b3b233af2 - Sigstore transparency entry: 1059747231
- Sigstore integration time:
-
Permalink:
codeafix/obsidian-mcp-guard@0abcb7b593d2a210f86512f3bf0aa7e00290b1c1 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/codeafix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0abcb7b593d2a210f86512f3bf0aa7e00290b1c1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file obsidian_mcp_guard-0.1.8-py3-none-any.whl.
File metadata
- Download URL: obsidian_mcp_guard-0.1.8-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c30626a6e06305ca77b71ab1b0f7f2ecc2f3845a72f1abe486b46c26ade873a7
|
|
| MD5 |
7f7f225d93c377cd9b97dfcc8710a917
|
|
| BLAKE2b-256 |
ea008dc5e5156c3d703ae5e9502ca48692605b565f55b7f792b2a3c2338a5944
|
Provenance
The following attestation bundles were made for obsidian_mcp_guard-0.1.8-py3-none-any.whl:
Publisher:
python-publish.yml on codeafix/obsidian-mcp-guard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
obsidian_mcp_guard-0.1.8-py3-none-any.whl -
Subject digest:
c30626a6e06305ca77b71ab1b0f7f2ecc2f3845a72f1abe486b46c26ade873a7 - Sigstore transparency entry: 1059747233
- Sigstore integration time:
-
Permalink:
codeafix/obsidian-mcp-guard@0abcb7b593d2a210f86512f3bf0aa7e00290b1c1 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/codeafix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0abcb7b593d2a210f86512f3bf0aa7e00290b1c1 -
Trigger Event:
release
-
Statement type: