# Semantic Search Over My Obsidian Vault with qmd

How I index 5,000+ Obsidian notes on a Mac mini with qmd, keep the index fresh with launchd, and serve it as an MCP server my agents reach over Tailscale.

I ask my agents about my own notes all the time. What did I decide about that plugin? Where did I write down that launchd gotcha? The answer is almost always somewhere in my Obsidian vault, but it rarely uses the words I search with.

Sometimes I know exactly what I'm looking for: a title, a command, a phrase I remember typing. Grep is great at that. Other times I only remember what the note was about, and grep comes back empty. An empty result looks exactly like "there's no note about this."

Think of my vault as a detective's corkboard and [qmd](https://github.com/tobi/qmd) as the detective. It notices the exact words on every card, but it also gets what each card is about, so notes that mean the same thing turn up together even when they're worded differently. That second skill is semantic search. `qmd query` uses both and weighs what it finds, so the best note rises to the top whether or not it uses my words.

So I set it up for my agents over the whole vault. It runs on a Mac mini that stays on: one index of 5,000+ notes, a reindex every 15 minutes, and an MCP server the rest of my agents reach over Tailscale. Everything stays on that Mac. No note leaves it to get embedded.

<!-- TODO: Screenshot of an agent answering a vault question, showing the qmd `query` and `get` tool calls. -->

## What qmd is

[qmd](https://github.com/tobi/qmd) is a small search engine for markdown, written by Tobi Lütke. You point it at a folder and it builds a local index.

`qmd search` is keyword search, for when I know a title or a phrase. `qmd vsearch` is semantic search on its own. `qmd query` runs both and reranks the results, and it's the one I use most. qmd also ships an MCP server, which is how my agents reach the index.

## Before you start

This setup assumes:

- An Apple Silicon Mac that stays on. Mine is a Mac mini.
- [Homebrew](https://brew.sh) and Node.js 22 or newer.
- [Tailscale](https://tailscale.com) installed and logged in on that Mac and on every device that will search it, with MagicDNS and HTTPS certificates turned on in your tailnet's DNS settings.
- About 2 GB of free disk space for qmd's local models.

launchd agents only run while you're logged in, so the Mac has to stay awake and logged in. Turn on "Prevent automatic sleeping when the display is off" in System Settings → Energy (or run `sudo pmset -a sleep 0`), and turn on automatic login in Users & Groups. Automatic login isn't available while FileVault is on, so after a reboot you'll have to log in once yourself.

## Install it

On macOS, qmd needs Homebrew's SQLite. Then install qmd with npm:

```sh
brew install sqlite
npm install -g @tobilu/qmd
which qmd
```

Note the directory `which qmd` prints. With Homebrew's Node it's `/opt/homebrew/bin`, and both launchd plists below need it.

## Point it at the vault

I have one collection, `second-brain`, for the whole vault. I write it straight into `~/.config/qmd/index.yml` instead of running `qmd collection add`, so the `ignore` list is in place before anything gets indexed:

```yaml title="~/.config/qmd/index.yml"
collections:
  second-brain:
    path: /Users/you/path/to/vault
    pattern: '**/*.md'
    ignore:
      - 'Private/**'
```

`path` has to be absolute, and `pattern` keeps the index to markdown. My `ignore` list excludes a couple of private folders. qmd never indexes them, so search can't surface them. There's no CLI command for `ignore`, so this file is the only place to set it.

<!-- TODO: Optional personal detail. Why you fence some folders off, in general terms only. -->

## Contexts

I label each top-level folder under the collection's `context:` key, so agents know what kind of note a result is. Here's the whole file:

```yaml title="~/.config/qmd/index.yml"
collections:
  second-brain:
    path: /Users/you/path/to/vault
    pattern: '**/*.md'
    ignore:
      - 'Private/**'
    context:
      '/Days': 'Daily notes and journaling, named YYYY-MM-DD.md.'
      '/Goals': 'Measurable personal objectives with timelines.'
      '/Events': 'Dated meetings, appointments, trips, shows, and other events.'
      '/Projects': 'Project notes organized by commitment status.'
      '/Projects/Active': 'Projects currently committed to and actively being worked on.'
      '/Projects/Waiting For': 'Delegated or dependent projects waiting on others or external input.'
      '/Projects/Someday Maybe': 'Potential future projects not currently committed to.'
      '/Areas': 'Ongoing life domains and responsibilities.'
      '/Resources': 'Reference materials, tools, templates, and skills.'
      '/Relationships': 'People and organization profiles.'
      '/Inbox': 'Unsorted captures awaiting processing.'
      '/Archives': 'Completed projects and historical documents.'
      '/Assets': 'Supporting files and plain-text source material.'
      '/Brain': 'Persistent personal knowledge and synthesized notes.'
```

The longest matching path wins, so a note in `/Projects/Active` gets that label instead of the one for `/Projects`.

## Build the index

```sh
qmd update
qmd embed
qmd status
```

`qmd update` indexes the files, and `qmd embed` creates the vectors for semantic search. The first `embed` downloads the embedding model and the first `qmd query` downloads the other two. All three come to about 2 GB, cached in `~/.cache/qmd/models/`. Embedding thousands of notes takes a while the first time.

`qmd status` should list `second-brain` with your note count. If something looks wrong, `qmd doctor` checks the install.

## Keep the index fresh with launchd

I never run `qmd update` or `qmd embed` by hand. A launchd agent on the Mac mini runs both every 15 minutes. Save this script as `~/bin/reindex-qmd.sh` and make it executable with `chmod +x ~/bin/reindex-qmd.sh`:

```sh title="~/bin/reindex-qmd.sh"
#!/bin/sh
log="$HOME/.cache/qmd/vault-reindex.log"
mkdir -p "$(dirname "$log")"
{
  echo "----- $(date)"
  qmd update
  qmd embed
} >> "$log" 2>&1
```

Then save this plist as `~/Library/LaunchAgents/com.yourname.qmd-watch.plist`. launchd doesn't expand `~` or `$HOME`, so it uses absolute paths. It also doesn't load your shell's `PATH`, so put the directory from `which qmd` first. That's where npm put both `qmd` and `node`.

```xml title="~/Library/LaunchAgents/com.yourname.qmd-watch.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.yourname.qmd-watch</string>
  <key>ProgramArguments</key>
  <array>
    <string>/Users/you/bin/reindex-qmd.sh</string>
  </array>
  <key>EnvironmentVariables</key>
  <dict>
    <key>PATH</key>
    <string>/opt/homebrew/bin:/usr/bin:/bin</string>
  </dict>
  <key>RunAtLoad</key>
  <true/>
  <key>StartInterval</key>
  <integer>900</integer>
  <key>Nice</key>
  <integer>10</integer>
  <key>LowPriorityIO</key>
  <true/>
</dict>
</plist>
```

Load it and check the log:

```sh
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.yourname.qmd-watch.plist
tail ~/.cache/qmd/vault-reindex.log
```

`RunAtLoad` runs it once right away, so the log should already have an entry. After that, saving a note doesn't refresh the index on its own. The job picks it up within about 15 minutes.

## Serve it as an MCP server

My agents don't have a shell on the Mac mini, so they can't run `qmd query` themselves. qmd can serve HTTP, and one long-running process keeps the models loaded:

```sh
qmd mcp --http --port 8181
```

It binds to localhost only. A second launchd agent keeps it running. Save it as `~/Library/LaunchAgents/com.yourname.qmd-mcp.plist`, and replace `your-mac.your-tailnet.ts.net` with the Mac's full MagicDNS name, listed under Machines in the Tailscale admin console:

```xml title="~/Library/LaunchAgents/com.yourname.qmd-mcp.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.yourname.qmd-mcp</string>
  <key>ProgramArguments</key>
  <array>
    <string>/opt/homebrew/bin/qmd</string>
    <string>mcp</string>
    <string>--http</string>
    <string>--port</string>
    <string>8181</string>
  </array>
  <key>EnvironmentVariables</key>
  <dict>
    <key>PATH</key>
    <string>/opt/homebrew/bin:/usr/bin:/bin</string>
    <key>QMD_ALLOWED_HOSTS</key>
    <string>your-mac.your-tailnet.ts.net</string>
  </dict>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
  <key>StandardOutPath</key>
  <string>/Users/you/.cache/qmd/mcp.log</string>
  <key>StandardErrorPath</key>
  <string>/Users/you/.cache/qmd/mcp.log</string>
</dict>
</plist>
```

`RunAtLoad` starts it at login, and `KeepAlive` restarts it if it dies. Use the full path from `which qmd` in `ProgramArguments`, and the same directory in `PATH`.

Load it and check that it answers:

```sh
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.yourname.qmd-mcp.plist
curl http://localhost:8181/health
```

If you edit the plist later, unload it with `launchctl bootout gui/$(id -u)/com.yourname.qmd-mcp` and run the `bootstrap` line again.

## Reach it over Tailscale

The MCP server only listens on localhost. Tailscale Serve puts it on my tailnet with HTTPS, which only works once HTTPS certificates are turned on for the tailnet:

```sh
tailscale serve --bg --https=443 http://localhost:8181
tailscale serve status
```

`--bg` keeps the config across reboots, so it doesn't need its own launchd job. To turn it off later, run `tailscale serve --https=443 off`.

Set `QMD_ALLOWED_HOSTS` in the plist to your tailnet hostname, or requests through Tailscale come back as a 403.

Then check it from another device on your tailnet:

```sh
curl https://your-mac.your-tailnet.ts.net/health
```

## Connect your agents

Any MCP client that supports HTTP can use the `/mcp` endpoint. My laptop, Grok Bot, and Claude Code all point at that URL, so they search the Mac mini as long as it's awake.

<!-- TODO: Screenshot of the qmd custom connector in Grok Bot's settings. -->

A client that reads a JSON config, such as Claude Code's `.mcp.json`, looks like this:

```json title=".mcp.json"
{
  "mcpServers": {
    "qmd": {
      "type": "http",
      "url": "https://your-mac.your-tailnet.ts.net/mcp"
    }
  }
}
```

I tell my agents to search with `query` before creating a new note, and to read the full note with `get` before answering from a result.

## Check that it all works

- `qmd status` lists `second-brain` with your note count.
- `~/.cache/qmd/vault-reindex.log` gets a new entry every 15 minutes.
- `curl http://localhost:8181/health` answers on the Mac.
- `curl https://your-mac.your-tailnet.ts.net/health` answers from another device on your tailnet.
- An agent connected to the `/mcp` URL can run `query` and get notes back.

## A few things I learned

- Stick to markdown. Other file types bloat the index, so I convert a PDF to markdown before I index it.
- Add a short context label to each folder so agents can tell what a result is.
- Set `QMD_ALLOWED_HOSTS` to your tailnet hostname, or Tailscale requests come back as a 403.
- Don't expose the MCP server to the public internet. It has no login.

## Wrapping up

qmd reads my notes for their words and their meaning, then weighs both, so my agents get the exact matches and the bigger picture. It runs on the Mac mini, a launchd job keeps the index within about 15 minutes of my latest edit, and Tailscale Serve lets every agent I use reach that one server.

If you keep your notes in markdown, try `qmd query` on your own vault this week. Start with the CLI, and add the MCP server once you want other agents to search it too.

And if you want agents to read your published writing as easily as your private notes, check out [How to Make Your Site LLM-Friendly](/posts/how-to-make-your-site-llm-friendly).