Files
conversation-history/2026-04-15-obsidian-syncthing-mcp-tools.md

106 lines
4.9 KiB
Markdown

# Session: 2026-04-15 - Obsidian Syncthing & Hermes-MCP Obsidian Tools
## Participants
- **User**: Garfield (garfield@fetcherpay.com)
- **AI**: Claude Code (claude-sonnet-4-6)
## Session Overview
Continued from 2026-04-14. Fixed obsidian-sync.fetcherpay.com certificate issuance, fixed Syncthing auto-restart on GUI restart, and implemented 4 Obsidian MCP tools in hermes-mcp for reading/writing/searching vault notes.
---
## 1. Context/Problem Statement
- `obsidian-sync.fetcherpay.com` had READY: False — cert-manager challenge failing
- Syncthing service would stay down after clicking "Restart" in the GUI
- hermes-mcp needed Obsidian vault integration tools so Claude can read/write notes
---
## 2. Investigation/Work Done
### Fix 1: obsidian-sync.fetcherpay.com Certificate
- **Root cause**: CoreDNS was forwarding to node's `/etc/resolv.conf` → systemd-resolved → AT&T ISP DNS (68.94.156.1 / 68.94.157.1), which had not yet propagated the new `obsidian-sync.fetcherpay.com` record.
- Google DNS (8.8.8.8) and Cloudflare (1.1.1.1) resolved it fine; ISP servers returned NXDOMAIN.
- cert-manager's HTTP-01 self-check + Let's Encrypt's own validation both failed → challenge marked `invalid`.
- **Fix**: Patched CoreDNS configmap to forward to `8.8.8.8 1.1.1.1` instead of `/etc/resolv.conf`. Rolled out CoreDNS. Deleted the failed CertificateRequest and re-applied `syncthing-k8s.yaml`. New challenge passed immediately.
### Fix 2: Syncthing Stays Down After GUI Restart
- **Root cause**: `Restart=on-failure` in systemd unit + `SuccessExitStatus=3 4` — exit code 3 (GUI restart) was treated as a clean success, so systemd did not restart.
- **Fix**: Changed `Restart=on-failure` → `Restart=always` in `~/.config/systemd/user/syncthing.service`. Reloaded daemon.
### Feature: Obsidian MCP Tools in hermes-mcp
Implemented 4 new tools backed by direct filesystem access to the vault (mounted at `/vaults`):
| Tool | Implementation |
|---|---|
| `obsidian_search_notes` | Recursive `.md` scan, frontmatter tag parsing, text match with excerpt |
| `obsidian_read_note` | Read by path or title fallback, returns content + wiki links |
| `obsidian_append_to_note` | Append markdown with optional H2 header, creates file if missing |
| `obsidian_sync_status` | Syncthing REST API `/rest/db/status?folder=obsidian-vault` |
---
## 3. Results/Achievements
- `obsidian-sync.fetcherpay.com` — HTTPS with valid Let's Encrypt cert, Syncthing GUI accessible
- Syncthing auto-restarts on GUI "Restart" click (within 5s via systemd)
- hermes-mcp serves 10 tools: 6 email + 4 obsidian
- All 4 obsidian tools verified live: search, read, append (wrote to disk), sync status
---
## 4. Key Decisions Made
- **Direct filesystem** for vault access (not Obsidian REST API plugin) — simpler, no auth, works without GUI running
- **Read-write mount** (`/home/garfield/obsidian/vaults:/vaults`) so `obsidian_append_to_note` can write
- **`host.docker.internal`** alias (`extra_hosts: host-gateway`) for Syncthing API access from container
- **CoreDNS → 8.8.8.8** rather than waiting for ISP DNS propagation — better for production k8s anyway
---
## 5. Technical Details
### Files Modified/Created
- `~/.config/systemd/user/syncthing.service` — `Restart=always`
- `/home/garfield/hermes-mcp/src/clients/obsidian.ts` — new file, vault client
- `/home/garfield/hermes-mcp/src/tools.ts` — added 4 obsidian tools + switch cases
- `/home/garfield/hermes-mcp/docker-compose.yml` — added vault volume + `extra_hosts`
- `/home/garfield/hermes-mcp/.env` — added OBSIDIAN_* and SYNCTHING_* vars
- `/home/garfield/hermes-mcp/.env.example` — documented new vars
### Kubernetes
- CoreDNS configmap patched: `forward . 8.8.8.8 1.1.1.1`
- `syncthing-k8s.yaml` re-applied after deleting failed CertificateRequest
### Env Vars Added to hermes-mcp
```
OBSIDIAN_VAULT_PATH=/vaults
SYNCTHING_URL=http://host.docker.internal:8384
SYNCTHING_API_KEY=<from syncthing config.xml>
SYNCTHING_FOLDER_ID=obsidian-vault
```
### URLs
- `https://obsidian-sync.fetcherpay.com` — Syncthing GUI (user: garfield)
- `https://obsidian.fetcherpay.com` — Obsidian Remote browser UI
- `https://hermes.fetcherpay.com` — hermes-mcp MCP server
---
## 6. Issues Encountered & Solutions
| Issue | Solution |
|---|---|
| cert-manager challenge NXDOMAIN | Patched CoreDNS to use 8.8.8.8/1.1.1.1 |
| Let's Encrypt challenge `invalid` state | Deleted CertificateRequest, re-applied ingress YAML |
| Syncthing stays down after GUI restart | Changed systemd `Restart=on-failure` → `Restart=always` |
| Vault mount read-only, append failed (EROFS) | Removed `:ro` from docker-compose volume mount |
---
## 7. Next Steps / TODO
- [ ] Add notes to vault from real content (emails, agent history)
- [ ] Configure Syncthing device pairing with mobile/desktop for live sync
- [ ] Consider adding `obsidian_update_note` (full overwrite) tool
- [ ] Set up daily note auto-creation via cron or hermes-mcp
---
## Session Status: COMPLETE