obsidian-mcp-server 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- obsidian_mcp_server-0.1.0/.github/workflows/publish.yml +28 -0
- obsidian_mcp_server-0.1.0/.gitignore +36 -0
- obsidian_mcp_server-0.1.0/LICENSE +21 -0
- obsidian_mcp_server-0.1.0/PKG-INFO +149 -0
- obsidian_mcp_server-0.1.0/README.md +126 -0
- obsidian_mcp_server-0.1.0/obsidian_mcp/__init__.py +1 -0
- obsidian_mcp_server-0.1.0/obsidian_mcp/server.py +470 -0
- obsidian_mcp_server-0.1.0/pyproject.toml +39 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
id-token: write # Required for trusted publishing
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Set up Python
|
|
17
|
+
uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.12"
|
|
20
|
+
|
|
21
|
+
- name: Install build tools
|
|
22
|
+
run: pip install build
|
|
23
|
+
|
|
24
|
+
- name: Build package
|
|
25
|
+
run: python -m build
|
|
26
|
+
|
|
27
|
+
- name: Publish to PyPI
|
|
28
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
*.egg
|
|
21
|
+
|
|
22
|
+
# Virtual environments
|
|
23
|
+
.env
|
|
24
|
+
.venv
|
|
25
|
+
env/
|
|
26
|
+
venv/
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.idea/
|
|
30
|
+
.vscode/
|
|
31
|
+
*.swp
|
|
32
|
+
*.swo
|
|
33
|
+
|
|
34
|
+
# OS
|
|
35
|
+
.DS_Store
|
|
36
|
+
Thumbs.db
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Benjamin Daniels
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: obsidian-mcp-server
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server giving Claude Code read/write access to Obsidian vaults
|
|
5
|
+
Project-URL: Homepage, https://github.com/bbdaniels/obsidian-mcp-server
|
|
6
|
+
Project-URL: Repository, https://github.com/bbdaniels/obsidian-mcp-server
|
|
7
|
+
Project-URL: Issues, https://github.com/bbdaniels/obsidian-mcp-server/issues
|
|
8
|
+
Author-email: Benjamin Daniels <bbdaniels@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,claude,mcp,notes,obsidian
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: mcp>=1.0.0
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# Obsidian MCP Server
|
|
25
|
+
|
|
26
|
+
An [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server that gives Claude Code read/write access to your Obsidian vault.
|
|
27
|
+
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
- **Read & write notes** - Create, edit, and append to markdown files
|
|
31
|
+
- **Search** - Full-text search across your vault
|
|
32
|
+
- **Daily notes** - Read or append to daily notes with configurable date format
|
|
33
|
+
- **Browse** - List files and folders in your vault
|
|
34
|
+
- **Secure** - Only accesses your configured vault directory
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
### Via pip
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install obsidian-mcp-server
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Via pipx (recommended for CLI tools)
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pipx install obsidian-mcp-server
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### From source
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/bbdaniels/obsidian-mcp-server.git
|
|
54
|
+
cd obsidian-mcp-server
|
|
55
|
+
pip install -e .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Configure Claude Code
|
|
59
|
+
|
|
60
|
+
Add the MCP server to Claude Code:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
claude mcp add obsidian -- python3 -m obsidian_mcp.server
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or if installed via pipx:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
claude mcp add obsidian -- obsidian-mcp
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Then restart Claude Code.
|
|
73
|
+
|
|
74
|
+
## First-Time Setup
|
|
75
|
+
|
|
76
|
+
Once configured, tell Claude:
|
|
77
|
+
|
|
78
|
+
> "Configure obsidian vault at /path/to/your/vault"
|
|
79
|
+
|
|
80
|
+
Claude will run `obsidian_configure` to set up the vault path. Your configuration is stored at `~/.config/obsidian-mcp/config.json`.
|
|
81
|
+
|
|
82
|
+
## Available Tools
|
|
83
|
+
|
|
84
|
+
| Tool | Description |
|
|
85
|
+
|------|-------------|
|
|
86
|
+
| `obsidian_configure` | Set vault path and daily notes settings |
|
|
87
|
+
| `obsidian_status` | Show current configuration and vault stats |
|
|
88
|
+
| `obsidian_read` | Read a note's contents |
|
|
89
|
+
| `obsidian_write` | Create or overwrite a note |
|
|
90
|
+
| `obsidian_append` | Append to a note (optionally under a heading) |
|
|
91
|
+
| `obsidian_search` | Search notes by content |
|
|
92
|
+
| `obsidian_list` | Browse vault structure |
|
|
93
|
+
| `obsidian_daily` | Read/append to daily notes |
|
|
94
|
+
|
|
95
|
+
## Example Usage
|
|
96
|
+
|
|
97
|
+
Once configured, you can ask Claude things like:
|
|
98
|
+
|
|
99
|
+
- "Search my notes for authentication patterns"
|
|
100
|
+
- "Read my project architecture note"
|
|
101
|
+
- "Append today's session summary to my daily note"
|
|
102
|
+
- "Create a new note at Projects/my-project/decisions.md"
|
|
103
|
+
- "List all notes in my Work folder"
|
|
104
|
+
|
|
105
|
+
## Configuration
|
|
106
|
+
|
|
107
|
+
Config is stored at `~/.config/obsidian-mcp/config.json`:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"vault_path": "/path/to/your/vault",
|
|
112
|
+
"daily_notes_folder": "Daily Notes",
|
|
113
|
+
"daily_notes_format": "%Y-%m-%d"
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Options
|
|
118
|
+
|
|
119
|
+
| Option | Default | Description |
|
|
120
|
+
|--------|---------|-------------|
|
|
121
|
+
| `vault_path` | (required) | Absolute path to your Obsidian vault |
|
|
122
|
+
| `daily_notes_folder` | `Daily Notes` | Folder for daily notes |
|
|
123
|
+
| `daily_notes_format` | `%Y-%m-%d` | Date format for daily note filenames |
|
|
124
|
+
|
|
125
|
+
## Recommended Claude Instructions
|
|
126
|
+
|
|
127
|
+
Add this to your `~/.claude/CLAUDE.md` to have Claude automatically take notes:
|
|
128
|
+
|
|
129
|
+
```markdown
|
|
130
|
+
## Obsidian Note-Taking
|
|
131
|
+
|
|
132
|
+
Use the obsidian MCP tools to document work sessions and project progress.
|
|
133
|
+
|
|
134
|
+
### Daily Notes
|
|
135
|
+
At the end of significant work sessions, append a summary to today's daily note using `obsidian_daily`:
|
|
136
|
+
- What was accomplished
|
|
137
|
+
- Key decisions made
|
|
138
|
+
- Any blockers or open questions
|
|
139
|
+
|
|
140
|
+
### Project Notes
|
|
141
|
+
When working on a project, check if a corresponding folder exists in Obsidian (use `obsidian_list`). If so:
|
|
142
|
+
- Document important decisions, architecture choices, or design rationale
|
|
143
|
+
- Note any non-obvious implementation details worth remembering
|
|
144
|
+
- Track open questions or future improvements
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Obsidian MCP Server
|
|
2
|
+
|
|
3
|
+
An [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server that gives Claude Code read/write access to your Obsidian vault.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Read & write notes** - Create, edit, and append to markdown files
|
|
8
|
+
- **Search** - Full-text search across your vault
|
|
9
|
+
- **Daily notes** - Read or append to daily notes with configurable date format
|
|
10
|
+
- **Browse** - List files and folders in your vault
|
|
11
|
+
- **Secure** - Only accesses your configured vault directory
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### Via pip
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install obsidian-mcp-server
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Via pipx (recommended for CLI tools)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pipx install obsidian-mcp-server
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### From source
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
git clone https://github.com/bbdaniels/obsidian-mcp-server.git
|
|
31
|
+
cd obsidian-mcp-server
|
|
32
|
+
pip install -e .
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configure Claude Code
|
|
36
|
+
|
|
37
|
+
Add the MCP server to Claude Code:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
claude mcp add obsidian -- python3 -m obsidian_mcp.server
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or if installed via pipx:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
claude mcp add obsidian -- obsidian-mcp
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Then restart Claude Code.
|
|
50
|
+
|
|
51
|
+
## First-Time Setup
|
|
52
|
+
|
|
53
|
+
Once configured, tell Claude:
|
|
54
|
+
|
|
55
|
+
> "Configure obsidian vault at /path/to/your/vault"
|
|
56
|
+
|
|
57
|
+
Claude will run `obsidian_configure` to set up the vault path. Your configuration is stored at `~/.config/obsidian-mcp/config.json`.
|
|
58
|
+
|
|
59
|
+
## Available Tools
|
|
60
|
+
|
|
61
|
+
| Tool | Description |
|
|
62
|
+
|------|-------------|
|
|
63
|
+
| `obsidian_configure` | Set vault path and daily notes settings |
|
|
64
|
+
| `obsidian_status` | Show current configuration and vault stats |
|
|
65
|
+
| `obsidian_read` | Read a note's contents |
|
|
66
|
+
| `obsidian_write` | Create or overwrite a note |
|
|
67
|
+
| `obsidian_append` | Append to a note (optionally under a heading) |
|
|
68
|
+
| `obsidian_search` | Search notes by content |
|
|
69
|
+
| `obsidian_list` | Browse vault structure |
|
|
70
|
+
| `obsidian_daily` | Read/append to daily notes |
|
|
71
|
+
|
|
72
|
+
## Example Usage
|
|
73
|
+
|
|
74
|
+
Once configured, you can ask Claude things like:
|
|
75
|
+
|
|
76
|
+
- "Search my notes for authentication patterns"
|
|
77
|
+
- "Read my project architecture note"
|
|
78
|
+
- "Append today's session summary to my daily note"
|
|
79
|
+
- "Create a new note at Projects/my-project/decisions.md"
|
|
80
|
+
- "List all notes in my Work folder"
|
|
81
|
+
|
|
82
|
+
## Configuration
|
|
83
|
+
|
|
84
|
+
Config is stored at `~/.config/obsidian-mcp/config.json`:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"vault_path": "/path/to/your/vault",
|
|
89
|
+
"daily_notes_folder": "Daily Notes",
|
|
90
|
+
"daily_notes_format": "%Y-%m-%d"
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Options
|
|
95
|
+
|
|
96
|
+
| Option | Default | Description |
|
|
97
|
+
|--------|---------|-------------|
|
|
98
|
+
| `vault_path` | (required) | Absolute path to your Obsidian vault |
|
|
99
|
+
| `daily_notes_folder` | `Daily Notes` | Folder for daily notes |
|
|
100
|
+
| `daily_notes_format` | `%Y-%m-%d` | Date format for daily note filenames |
|
|
101
|
+
|
|
102
|
+
## Recommended Claude Instructions
|
|
103
|
+
|
|
104
|
+
Add this to your `~/.claude/CLAUDE.md` to have Claude automatically take notes:
|
|
105
|
+
|
|
106
|
+
```markdown
|
|
107
|
+
## Obsidian Note-Taking
|
|
108
|
+
|
|
109
|
+
Use the obsidian MCP tools to document work sessions and project progress.
|
|
110
|
+
|
|
111
|
+
### Daily Notes
|
|
112
|
+
At the end of significant work sessions, append a summary to today's daily note using `obsidian_daily`:
|
|
113
|
+
- What was accomplished
|
|
114
|
+
- Key decisions made
|
|
115
|
+
- Any blockers or open questions
|
|
116
|
+
|
|
117
|
+
### Project Notes
|
|
118
|
+
When working on a project, check if a corresponding folder exists in Obsidian (use `obsidian_list`). If so:
|
|
119
|
+
- Document important decisions, architecture choices, or design rationale
|
|
120
|
+
- Note any non-obvious implementation details worth remembering
|
|
121
|
+
- Track open questions or future improvements
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Obsidian MCP Server
|
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Obsidian MCP Server - Provides Claude Code with read/write access to Obsidian vaults.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import json
|
|
8
|
+
import re
|
|
9
|
+
from datetime import datetime
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Optional
|
|
12
|
+
|
|
13
|
+
from mcp.server import Server
|
|
14
|
+
from mcp.server.stdio import stdio_server
|
|
15
|
+
from mcp.types import Tool, TextContent
|
|
16
|
+
|
|
17
|
+
# Initialize server
|
|
18
|
+
server = Server("obsidian-mcp")
|
|
19
|
+
|
|
20
|
+
# Configuration
|
|
21
|
+
def get_config_path() -> Path:
|
|
22
|
+
"""Get the config file path."""
|
|
23
|
+
return Path.home() / ".config" / "obsidian-mcp" / "config.json"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def load_config() -> dict:
|
|
27
|
+
"""Load configuration from file."""
|
|
28
|
+
config_path = get_config_path()
|
|
29
|
+
if config_path.exists():
|
|
30
|
+
with open(config_path) as f:
|
|
31
|
+
return json.load(f)
|
|
32
|
+
return {}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def save_config(config: dict):
|
|
36
|
+
"""Save configuration to file."""
|
|
37
|
+
config_path = get_config_path()
|
|
38
|
+
config_path.parent.mkdir(parents=True, exist_ok=True)
|
|
39
|
+
with open(config_path, "w") as f:
|
|
40
|
+
json.dump(config, f, indent=2)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def get_vault_path() -> Optional[Path]:
|
|
44
|
+
"""Get the configured vault path."""
|
|
45
|
+
config = load_config()
|
|
46
|
+
vault_path = config.get("vault_path")
|
|
47
|
+
if vault_path:
|
|
48
|
+
return Path(vault_path)
|
|
49
|
+
return None
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def get_daily_notes_folder() -> str:
|
|
53
|
+
"""Get the daily notes folder (default: 'Daily Notes')."""
|
|
54
|
+
config = load_config()
|
|
55
|
+
return config.get("daily_notes_folder", "Daily Notes")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def get_daily_notes_format() -> str:
|
|
59
|
+
"""Get the daily notes date format (default: YYYY-MM-DD)."""
|
|
60
|
+
config = load_config()
|
|
61
|
+
return config.get("daily_notes_format", "%Y-%m-%d")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def resolve_note_path(note_path: str) -> Optional[Path]:
|
|
65
|
+
"""Resolve a note path relative to the vault."""
|
|
66
|
+
vault = get_vault_path()
|
|
67
|
+
if not vault:
|
|
68
|
+
return None
|
|
69
|
+
|
|
70
|
+
# Add .md extension if not present
|
|
71
|
+
if not note_path.endswith(".md"):
|
|
72
|
+
note_path = note_path + ".md"
|
|
73
|
+
|
|
74
|
+
full_path = vault / note_path
|
|
75
|
+
|
|
76
|
+
# Security: ensure path is within vault
|
|
77
|
+
try:
|
|
78
|
+
full_path.resolve().relative_to(vault.resolve())
|
|
79
|
+
except ValueError:
|
|
80
|
+
return None
|
|
81
|
+
|
|
82
|
+
return full_path
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# Tool definitions
|
|
86
|
+
@server.list_tools()
|
|
87
|
+
async def list_tools():
|
|
88
|
+
"""List available tools."""
|
|
89
|
+
return [
|
|
90
|
+
Tool(
|
|
91
|
+
name="obsidian_configure",
|
|
92
|
+
description="Configure the Obsidian vault path and settings. Run this first to set up your vault.",
|
|
93
|
+
inputSchema={
|
|
94
|
+
"type": "object",
|
|
95
|
+
"properties": {
|
|
96
|
+
"vault_path": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"description": "Absolute path to your Obsidian vault folder"
|
|
99
|
+
},
|
|
100
|
+
"daily_notes_folder": {
|
|
101
|
+
"type": "string",
|
|
102
|
+
"description": "Folder for daily notes (default: 'Daily Notes')"
|
|
103
|
+
},
|
|
104
|
+
"daily_notes_format": {
|
|
105
|
+
"type": "string",
|
|
106
|
+
"description": "Date format for daily notes (default: '%Y-%m-%d')"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"required": ["vault_path"]
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
Tool(
|
|
113
|
+
name="obsidian_read",
|
|
114
|
+
description="Read the contents of a note from the Obsidian vault. Returns the full markdown content.",
|
|
115
|
+
inputSchema={
|
|
116
|
+
"type": "object",
|
|
117
|
+
"properties": {
|
|
118
|
+
"path": {
|
|
119
|
+
"type": "string",
|
|
120
|
+
"description": "Path to the note relative to vault root (e.g., 'Projects/my-project.md' or 'Projects/my-project')"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"required": ["path"]
|
|
124
|
+
}
|
|
125
|
+
),
|
|
126
|
+
Tool(
|
|
127
|
+
name="obsidian_write",
|
|
128
|
+
description="Create or overwrite a note in the Obsidian vault. Creates parent folders if needed.",
|
|
129
|
+
inputSchema={
|
|
130
|
+
"type": "object",
|
|
131
|
+
"properties": {
|
|
132
|
+
"path": {
|
|
133
|
+
"type": "string",
|
|
134
|
+
"description": "Path to the note relative to vault root"
|
|
135
|
+
},
|
|
136
|
+
"content": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"description": "Full markdown content for the note"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"required": ["path", "content"]
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
Tool(
|
|
145
|
+
name="obsidian_append",
|
|
146
|
+
description="Append content to an existing note, or create it if it doesn't exist.",
|
|
147
|
+
inputSchema={
|
|
148
|
+
"type": "object",
|
|
149
|
+
"properties": {
|
|
150
|
+
"path": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"description": "Path to the note relative to vault root"
|
|
153
|
+
},
|
|
154
|
+
"content": {
|
|
155
|
+
"type": "string",
|
|
156
|
+
"description": "Content to append to the note"
|
|
157
|
+
},
|
|
158
|
+
"heading": {
|
|
159
|
+
"type": "string",
|
|
160
|
+
"description": "Optional: append under this heading (creates if doesn't exist)"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"required": ["path", "content"]
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
Tool(
|
|
167
|
+
name="obsidian_search",
|
|
168
|
+
description="Search for notes containing specific text. Returns matching file paths and snippets.",
|
|
169
|
+
inputSchema={
|
|
170
|
+
"type": "object",
|
|
171
|
+
"properties": {
|
|
172
|
+
"query": {
|
|
173
|
+
"type": "string",
|
|
174
|
+
"description": "Text to search for (case-insensitive)"
|
|
175
|
+
},
|
|
176
|
+
"folder": {
|
|
177
|
+
"type": "string",
|
|
178
|
+
"description": "Optional: limit search to this folder"
|
|
179
|
+
},
|
|
180
|
+
"max_results": {
|
|
181
|
+
"type": "integer",
|
|
182
|
+
"description": "Maximum results to return (default: 10)"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"required": ["query"]
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
Tool(
|
|
189
|
+
name="obsidian_list",
|
|
190
|
+
description="List notes and folders in the vault. Use to browse vault structure.",
|
|
191
|
+
inputSchema={
|
|
192
|
+
"type": "object",
|
|
193
|
+
"properties": {
|
|
194
|
+
"folder": {
|
|
195
|
+
"type": "string",
|
|
196
|
+
"description": "Folder to list (default: vault root)"
|
|
197
|
+
},
|
|
198
|
+
"recursive": {
|
|
199
|
+
"type": "boolean",
|
|
200
|
+
"description": "Include subfolders recursively (default: false)"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
Tool(
|
|
206
|
+
name="obsidian_daily",
|
|
207
|
+
description="Read or append to today's daily note. Creates the note if it doesn't exist.",
|
|
208
|
+
inputSchema={
|
|
209
|
+
"type": "object",
|
|
210
|
+
"properties": {
|
|
211
|
+
"action": {
|
|
212
|
+
"type": "string",
|
|
213
|
+
"enum": ["read", "append"],
|
|
214
|
+
"description": "Whether to read or append to the daily note"
|
|
215
|
+
},
|
|
216
|
+
"content": {
|
|
217
|
+
"type": "string",
|
|
218
|
+
"description": "Content to append (required if action is 'append')"
|
|
219
|
+
},
|
|
220
|
+
"date": {
|
|
221
|
+
"type": "string",
|
|
222
|
+
"description": "Optional: specific date (YYYY-MM-DD format). Defaults to today."
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
"required": ["action"]
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
Tool(
|
|
229
|
+
name="obsidian_status",
|
|
230
|
+
description="Show current configuration and vault status.",
|
|
231
|
+
inputSchema={
|
|
232
|
+
"type": "object",
|
|
233
|
+
"properties": {}
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
]
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@server.call_tool()
|
|
240
|
+
async def call_tool(name: str, arguments: dict):
|
|
241
|
+
"""Handle tool calls."""
|
|
242
|
+
|
|
243
|
+
if name == "obsidian_configure":
|
|
244
|
+
vault_path = Path(arguments["vault_path"]).expanduser()
|
|
245
|
+
if not vault_path.exists():
|
|
246
|
+
return [TextContent(type="text", text=f"Error: Vault path does not exist: {vault_path}")]
|
|
247
|
+
if not vault_path.is_dir():
|
|
248
|
+
return [TextContent(type="text", text=f"Error: Vault path is not a directory: {vault_path}")]
|
|
249
|
+
|
|
250
|
+
config = load_config()
|
|
251
|
+
config["vault_path"] = str(vault_path)
|
|
252
|
+
|
|
253
|
+
if "daily_notes_folder" in arguments:
|
|
254
|
+
config["daily_notes_folder"] = arguments["daily_notes_folder"]
|
|
255
|
+
if "daily_notes_format" in arguments:
|
|
256
|
+
config["daily_notes_format"] = arguments["daily_notes_format"]
|
|
257
|
+
|
|
258
|
+
save_config(config)
|
|
259
|
+
return [TextContent(type="text", text=f"Configured vault: {vault_path}\nDaily notes folder: {config.get('daily_notes_folder', 'Daily Notes')}\nDaily notes format: {config.get('daily_notes_format', '%Y-%m-%d')}")]
|
|
260
|
+
|
|
261
|
+
elif name == "obsidian_status":
|
|
262
|
+
config = load_config()
|
|
263
|
+
vault = get_vault_path()
|
|
264
|
+
if not vault:
|
|
265
|
+
return [TextContent(type="text", text="No vault configured. Use obsidian_configure to set up your vault.")]
|
|
266
|
+
|
|
267
|
+
note_count = sum(1 for _ in vault.rglob("*.md"))
|
|
268
|
+
return [TextContent(type="text", text=f"Vault: {vault}\nDaily notes folder: {get_daily_notes_folder()}\nDaily notes format: {get_daily_notes_format()}\nTotal notes: {note_count}")]
|
|
269
|
+
|
|
270
|
+
elif name == "obsidian_read":
|
|
271
|
+
path = resolve_note_path(arguments["path"])
|
|
272
|
+
if not path:
|
|
273
|
+
return [TextContent(type="text", text="Error: No vault configured or invalid path.")]
|
|
274
|
+
if not path.exists():
|
|
275
|
+
return [TextContent(type="text", text=f"Note not found: {arguments['path']}")]
|
|
276
|
+
|
|
277
|
+
content = path.read_text(encoding="utf-8")
|
|
278
|
+
return [TextContent(type="text", text=content)]
|
|
279
|
+
|
|
280
|
+
elif name == "obsidian_write":
|
|
281
|
+
path = resolve_note_path(arguments["path"])
|
|
282
|
+
if not path:
|
|
283
|
+
return [TextContent(type="text", text="Error: No vault configured or invalid path.")]
|
|
284
|
+
|
|
285
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
286
|
+
path.write_text(arguments["content"], encoding="utf-8")
|
|
287
|
+
return [TextContent(type="text", text=f"Written: {arguments['path']}")]
|
|
288
|
+
|
|
289
|
+
elif name == "obsidian_append":
|
|
290
|
+
path = resolve_note_path(arguments["path"])
|
|
291
|
+
if not path:
|
|
292
|
+
return [TextContent(type="text", text="Error: No vault configured or invalid path.")]
|
|
293
|
+
|
|
294
|
+
content_to_add = arguments["content"]
|
|
295
|
+
heading = arguments.get("heading")
|
|
296
|
+
|
|
297
|
+
if path.exists():
|
|
298
|
+
existing = path.read_text(encoding="utf-8")
|
|
299
|
+
|
|
300
|
+
if heading:
|
|
301
|
+
# Find heading and append after it
|
|
302
|
+
heading_pattern = rf"(^#{1,6}\s+{re.escape(heading)}\s*$)"
|
|
303
|
+
match = re.search(heading_pattern, existing, re.MULTILINE)
|
|
304
|
+
|
|
305
|
+
if match:
|
|
306
|
+
# Find the end of the heading's section (next heading or EOF)
|
|
307
|
+
heading_level = existing[match.start():match.end()].count('#')
|
|
308
|
+
next_heading = re.search(rf"^#{{1,{heading_level}}}\s+", existing[match.end():], re.MULTILINE)
|
|
309
|
+
|
|
310
|
+
if next_heading:
|
|
311
|
+
insert_pos = match.end() + next_heading.start()
|
|
312
|
+
new_content = existing[:insert_pos] + "\n" + content_to_add + "\n" + existing[insert_pos:]
|
|
313
|
+
else:
|
|
314
|
+
new_content = existing + "\n" + content_to_add
|
|
315
|
+
else:
|
|
316
|
+
# Heading not found, add it
|
|
317
|
+
new_content = existing + f"\n\n## {heading}\n\n{content_to_add}"
|
|
318
|
+
else:
|
|
319
|
+
new_content = existing + "\n" + content_to_add
|
|
320
|
+
else:
|
|
321
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
322
|
+
if heading:
|
|
323
|
+
new_content = f"## {heading}\n\n{content_to_add}"
|
|
324
|
+
else:
|
|
325
|
+
new_content = content_to_add
|
|
326
|
+
|
|
327
|
+
path.write_text(new_content, encoding="utf-8")
|
|
328
|
+
return [TextContent(type="text", text=f"Appended to: {arguments['path']}")]
|
|
329
|
+
|
|
330
|
+
elif name == "obsidian_search":
|
|
331
|
+
vault = get_vault_path()
|
|
332
|
+
if not vault:
|
|
333
|
+
return [TextContent(type="text", text="Error: No vault configured.")]
|
|
334
|
+
|
|
335
|
+
query = arguments["query"].lower()
|
|
336
|
+
folder = arguments.get("folder", "")
|
|
337
|
+
max_results = arguments.get("max_results", 10)
|
|
338
|
+
|
|
339
|
+
search_path = vault / folder if folder else vault
|
|
340
|
+
if not search_path.exists():
|
|
341
|
+
return [TextContent(type="text", text=f"Folder not found: {folder}")]
|
|
342
|
+
|
|
343
|
+
results = []
|
|
344
|
+
for md_file in search_path.rglob("*.md"):
|
|
345
|
+
if md_file.name.startswith("."):
|
|
346
|
+
continue
|
|
347
|
+
try:
|
|
348
|
+
content = md_file.read_text(encoding="utf-8")
|
|
349
|
+
if query in content.lower():
|
|
350
|
+
rel_path = md_file.relative_to(vault)
|
|
351
|
+
# Extract snippet around match
|
|
352
|
+
idx = content.lower().find(query)
|
|
353
|
+
start = max(0, idx - 50)
|
|
354
|
+
end = min(len(content), idx + len(query) + 50)
|
|
355
|
+
snippet = content[start:end].replace("\n", " ").strip()
|
|
356
|
+
if start > 0:
|
|
357
|
+
snippet = "..." + snippet
|
|
358
|
+
if end < len(content):
|
|
359
|
+
snippet = snippet + "..."
|
|
360
|
+
results.append(f"**{rel_path}**\n {snippet}")
|
|
361
|
+
|
|
362
|
+
if len(results) >= max_results:
|
|
363
|
+
break
|
|
364
|
+
except Exception:
|
|
365
|
+
continue
|
|
366
|
+
|
|
367
|
+
if not results:
|
|
368
|
+
return [TextContent(type="text", text=f"No notes found matching: {query}")]
|
|
369
|
+
|
|
370
|
+
return [TextContent(type="text", text=f"Found {len(results)} results:\n\n" + "\n\n".join(results))]
|
|
371
|
+
|
|
372
|
+
elif name == "obsidian_list":
|
|
373
|
+
vault = get_vault_path()
|
|
374
|
+
if not vault:
|
|
375
|
+
return [TextContent(type="text", text="Error: No vault configured.")]
|
|
376
|
+
|
|
377
|
+
folder = arguments.get("folder", "")
|
|
378
|
+
recursive = arguments.get("recursive", False)
|
|
379
|
+
|
|
380
|
+
list_path = vault / folder if folder else vault
|
|
381
|
+
if not list_path.exists():
|
|
382
|
+
return [TextContent(type="text", text=f"Folder not found: {folder}")]
|
|
383
|
+
|
|
384
|
+
items = []
|
|
385
|
+
|
|
386
|
+
if recursive:
|
|
387
|
+
for item in sorted(list_path.rglob("*")):
|
|
388
|
+
if item.name.startswith("."):
|
|
389
|
+
continue
|
|
390
|
+
rel_path = item.relative_to(vault)
|
|
391
|
+
if item.is_dir():
|
|
392
|
+
items.append(f"📁 {rel_path}/")
|
|
393
|
+
elif item.suffix == ".md":
|
|
394
|
+
items.append(f"📄 {rel_path}")
|
|
395
|
+
else:
|
|
396
|
+
for item in sorted(list_path.iterdir()):
|
|
397
|
+
if item.name.startswith("."):
|
|
398
|
+
continue
|
|
399
|
+
if item.is_dir():
|
|
400
|
+
items.append(f"📁 {item.name}/")
|
|
401
|
+
elif item.suffix == ".md":
|
|
402
|
+
items.append(f"📄 {item.name}")
|
|
403
|
+
|
|
404
|
+
if not items:
|
|
405
|
+
return [TextContent(type="text", text="No notes or folders found.")]
|
|
406
|
+
|
|
407
|
+
return [TextContent(type="text", text="\n".join(items))]
|
|
408
|
+
|
|
409
|
+
elif name == "obsidian_daily":
|
|
410
|
+
vault = get_vault_path()
|
|
411
|
+
if not vault:
|
|
412
|
+
return [TextContent(type="text", text="Error: No vault configured.")]
|
|
413
|
+
|
|
414
|
+
action = arguments["action"]
|
|
415
|
+
date_str = arguments.get("date")
|
|
416
|
+
|
|
417
|
+
if date_str:
|
|
418
|
+
try:
|
|
419
|
+
date = datetime.strptime(date_str, "%Y-%m-%d")
|
|
420
|
+
except ValueError:
|
|
421
|
+
return [TextContent(type="text", text="Invalid date format. Use YYYY-MM-DD.")]
|
|
422
|
+
else:
|
|
423
|
+
date = datetime.now()
|
|
424
|
+
|
|
425
|
+
daily_folder = get_daily_notes_folder()
|
|
426
|
+
date_format = get_daily_notes_format()
|
|
427
|
+
filename = date.strftime(date_format) + ".md"
|
|
428
|
+
daily_path = vault / daily_folder / filename
|
|
429
|
+
|
|
430
|
+
if action == "read":
|
|
431
|
+
if not daily_path.exists():
|
|
432
|
+
return [TextContent(type="text", text=f"No daily note for {date.strftime('%Y-%m-%d')}. It will be created when you append to it.")]
|
|
433
|
+
content = daily_path.read_text(encoding="utf-8")
|
|
434
|
+
return [TextContent(type="text", text=content)]
|
|
435
|
+
|
|
436
|
+
elif action == "append":
|
|
437
|
+
content_to_add = arguments.get("content")
|
|
438
|
+
if not content_to_add:
|
|
439
|
+
return [TextContent(type="text", text="Error: content required for append action.")]
|
|
440
|
+
|
|
441
|
+
daily_path.parent.mkdir(parents=True, exist_ok=True)
|
|
442
|
+
|
|
443
|
+
if daily_path.exists():
|
|
444
|
+
existing = daily_path.read_text(encoding="utf-8")
|
|
445
|
+
new_content = existing + "\n" + content_to_add
|
|
446
|
+
else:
|
|
447
|
+
# Create with title
|
|
448
|
+
title = date.strftime("%A, %B %d, %Y")
|
|
449
|
+
new_content = f"# {title}\n\n{content_to_add}"
|
|
450
|
+
|
|
451
|
+
daily_path.write_text(new_content, encoding="utf-8")
|
|
452
|
+
return [TextContent(type="text", text=f"Appended to daily note: {daily_folder}/{filename}")]
|
|
453
|
+
|
|
454
|
+
return [TextContent(type="text", text=f"Unknown tool: {name}")]
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
async def run():
|
|
458
|
+
"""Run the server."""
|
|
459
|
+
async with stdio_server() as (read_stream, write_stream):
|
|
460
|
+
await server.run(read_stream, write_stream, server.create_initialization_options())
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def main():
|
|
464
|
+
"""Entry point."""
|
|
465
|
+
import asyncio
|
|
466
|
+
asyncio.run(run())
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
if __name__ == "__main__":
|
|
470
|
+
main()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "obsidian-mcp-server"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "MCP server giving Claude Code read/write access to Obsidian vaults"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = {text = "MIT"}
|
|
7
|
+
requires-python = ">=3.10"
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "Benjamin Daniels", email = "bbdaniels@gmail.com"}
|
|
10
|
+
]
|
|
11
|
+
keywords = ["mcp", "obsidian", "claude", "ai", "notes"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"mcp>=1.0.0",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/bbdaniels/obsidian-mcp-server"
|
|
28
|
+
Repository = "https://github.com/bbdaniels/obsidian-mcp-server"
|
|
29
|
+
Issues = "https://github.com/bbdaniels/obsidian-mcp-server/issues"
|
|
30
|
+
|
|
31
|
+
[build-system]
|
|
32
|
+
requires = ["hatchling"]
|
|
33
|
+
build-backend = "hatchling.build"
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel]
|
|
36
|
+
packages = ["obsidian_mcp"]
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
obsidian-mcp = "obsidian_mcp.server:main"
|