From qmd
When to use the query MCP tool and query documents to search indexed reference collections.
npx claudepluginhub ramonclaudio/skills --plugin qmdThis skill uses the workspace's default tool permissions.
- **Collections:** !`qmd status 2>/dev/null | grep -c '^ ' || echo "0"`
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Guides MCP server integration in Claude Code plugins via .mcp.json or plugin.json configs for stdio, SSE, HTTP types, enabling external services as tools.
qmd status 2>/dev/null | grep -c '^ ' || echo "0"qmd status 2>/dev/null | head -1 || echo "QMD not running"QMD searches indexed collections: external codebases, notes, docs you've added with qmd collection add. For files in the current working directory, use Grep and Glob instead. They're faster, cheaper on context, and more precise.
| Approach | When to use | How |
|---|---|---|
| Typed queries (MCP + CLI) | You know what you need. Exact terms, semantic concepts, or both. | MCP: searches: [{type: "lex", query: "handleAuth"}, {type: "vec", query: "how auth works"}]. CLI: qmd query $'lex: handleAuth\nvec: how auth works' |
| Auto-expand (CLI only) | Most CLI queries. Let the pipeline decide. | CLI: qmd query "auth middleware". Not available via MCP. |
Use query for everything. MCP accepts typed sub-queries (lex, vec, hyde). CLI also supports expand: and plain text (auto-expand).
query WorksHybrid pipeline with GRPO-optimized query expansion → BM25 + vector search → RRF fusion → LLM cross-encoder reranking → position-aware blending → dedup. For pipeline internals (sub-query types, blending weights, conditional expansion logic), see references/pipeline.md.
Documents are chunked into 900-token pieces with 15% overlap. Search matches point to the chunk, not the exact line. Use get with fromLine/maxLines to narrow down.
The query tool accepts an array of typed sub-queries. MCP uses structured JSON: searches: [{type: "lex", query: "term"}, ...] with types lex, vec, hyde only. CLI uses a text format: each line has an optional type prefix (lex: term). CLI also supports expand: and plain text (auto-expand).
MCP type enum: "lex" | "vec" | "hyde". CLI adds "expand" and implicit expand (plain text).
root ::= line ("\n" line)*
line ::= (type ":" SP)? content
type ::= "lex" | "vec" | "hyde" | "expand" # expand is CLI-only
content ::= [^\n]+
| Type | Routed to | Purpose | Availability |
|---|---|---|---|
lex: | BM25 only | Exact keywords, identifiers, error strings | MCP + CLI |
vec: | Vector only | Semantic rephrasing, concept search | MCP + CLI |
hyde: | Vector only | Hypothetical document. Describe what the answer looks like | MCP + CLI |
expand: | Full pipeline | Auto-expand into lex/vec/hyde sub-queries. Max one per query document. | CLI only |
| (plain text) | Full pipeline | Implicit expand:. Same as expand: but shorter to write. | CLI only |
The first query line gets 2x fusion weight in RRF. Put your strongest signal first.
Single line, auto-expands (CLI only):
auth middleware
Multi-line typed query:
lex:handleAuth JWT token
vec:how does request authentication work
hyde:The middleware validates the JWT token from the Authorization header and attaches the decoded user object to the request context
Mixed, typed + auto-expand (CLI only, expand: not available via MCP):
lex:"ECONNREFUSED" retry logic
expand:how connection errors are retried
Lex queries support phrase matching and exclusions:
| Syntax | Meaning | Example |
|---|---|---|
"exact phrase" | Verbatim match | lex:"error boundary" |
-term | Exclude term | lex:middleware -express |
-"phrase" | Exclude phrase | lex:router -"page router" |
| bare words | OR match (stemmed) | lex:handleAuth parse token |
| Tool | Purpose |
|---|---|
query | Search: typed sub-queries (lex, vec, hyde). CLI also supports expand: and plain text. |
get | Retrieve one document by path |
multi_get | Retrieve multiple documents |
status | List collections, document counts, pending embeds |
Search results consume your main conversation context. For broad research across multiple collections, delegate to a subagent:
Use a subagent to research how Next.js handles routing
by searching the next.js QMD collection.
The subagent runs searches in its own context and returns a summary. Your main conversation stays clean.
For targeted lookups (one query, one collection), search directly. The overhead is low.
After search returns results, retrieve full documents:
| Task | MCP Tool | Example |
|---|---|---|
| Get by path | get | file: "collection/path/to/doc.md" |
| Get by docid | get | file: "#abc123" |
| Get with line numbers | get | file: "docs/api.md", lineNumbers: true |
| Get from line offset | get | file: "docs/api.md", fromLine: 100, maxLines: 50 |
| Multiple by glob | multi_get | pattern: "docs/*.md" |
| Multiple by list | multi_get | pattern: "#abc123, #def456" |
| MCP Tool | CLI Equivalent | Key Parameters |
|---|---|---|
query | qmd query (alias: deep-search) | searches (array of {type, query} objects, types: lex/vec/hyde, min 1, max 10), limit (default 10), minScore (default 0), collections (array) |
get | qmd get | file (path or #docid), fromLine, maxLines, lineNumbers |
multi_get | qmd multi-get | pattern (glob or comma list), maxLines, maxBytes (default 10KB), lineNumbers |
status | qmd status | (none) |
CLI has additional search commands (qmd search, qmd vsearch) that map to BM25-only and vector-only searches. Use these in CLI fallback scenarios when you need a specific modality.
CLI defaults: 5 results in terminal mode, 20 for --json/--files. MCP defaults: 10.
CLI supports multiple collection filters: qmd search "query" -c react -c next.js. MCP collections parameter takes an array of collection names.
CLI output formats (not available via MCP): --files, --json, --csv, --md, --xml. MCP returns structured content via structuredContent field in addition to text.
| Score | Meaning | Action |
|---|---|---|
| 0.8 - 1.0 | Highly relevant | Show to user |
| 0.5 - 0.8 | Moderately relevant | Include if few results |
| 0.2 - 0.5 | Somewhat relevant | Only if user wants more |
| 0.0 - 0.2 | Low relevance | Usually skip |
statusquery with lex/vec/hyde sub-querieslex:"exact term" for identifiers, vec: for concepts, combine in one query documentget with path or #docidstatus first to see available collections and confirm zero pending embeddings.collections array parameter when you know which repos to search.lex: for exact identifiers, vec: for concepts, hyde: for "what would the answer look like".expand: per query document (CLI only). Multiple lex:/vec:/hyde: lines are fine.@<absolute-path> to pull the full file into context (the collection path is in qmd status)./qmd:status as a Bash fallback.multi_get pattern "docs/*.md" or comma list "#abc, #def"get file "docs/api.md:100" or use fromLine + maxLines paramsWhen MCP tools are unavailable (server disconnected, not installed), use CLI:
qmd search "exact term" -c collection -n 10 --json # BM25
qmd vsearch "concept" -c collection -n 10 --json # Vector
qmd query "question" -c collection -n 10 --json # Hybrid
qmd get path/to/file.md --line-numbers # Retrieve
qmd multi-get "docs/*.md" --json # Batch retrieve
CLI supports multiple -c flags: qmd search "query" -c react -c next.js
All 3 CLI search commands remain available. MCP has only query.
QMD supports separate indexes via --index <name>. Config at ~/.config/qmd/<name>.yml, DB at ~/.cache/qmd/<name>.sqlite. Useful for work/personal separation:
qmd --index work search "deployment"
qmd --index personal search "journal"
| Problem | Cause | Fix |
|---|---|---|
| MCP tools missing from tool list | Server disconnected mid-session | Run /qmd:status (Bash fallback) or /mcp to check connection |
| Zero results after successful embed | Mask excluded key files | Re-add with /qmd:add <repo> --mask "<broader-glob>" |
| Search hangs or times out | Index corruption or model loading | Run qmd cleanup then qmd embed -f to rebuild |
| Low-quality results | Query too vague or wrong approach | Use typed queries: lex: for exact terms, vec: for concepts, combine both |
| "Collection not found" error | Typo or collection was removed | Run status to list available collections |
minScore: 0.5 filters too aggressively for broad queries. Use 0.3 for exploratory search.lex) is better for exact identifiers. Vec is better for concepts. Combine both for best recall.expand: and plain text auto-expand are CLI-only. MCP requires explicit typed queries.get with fromLine/maxLines to narrow down.