What is MCP?
QMD implements the Model Context Protocol (MCP) to expose search and document retrieval as tools that AI assistants can use directly. This allows language models to search your knowledge base and retrieve documents without manual copy-paste.Available Tools
QMD exposes four MCP tools:query
Multi-strategy search with lex/vec/hyde sub-queries
get
Retrieve a single document by path or docid
multi_get
Retrieve multiple documents by glob pattern
status
Check index status and collection health
How Tools Work
Discovery via Instructions
When the MCP server initializes, it sends dynamic instructions to the LLM in the system prompt. These instructions include:- Total document count
- Available collections with descriptions (from context metadata)
- Embedding status (whether vector search is available)
- Usage tips and examples
Search Strategy
The primary tool isquery, which accepts typed sub-queries:
- lex — BM25 keyword search (supports
"phrases",-negation) - vec — Semantic vector search (requires embeddings)
- hyde — Hypothetical document embeddings (write what the answer looks like)
Document Retrieval
Search results include docids (#abc123) and file paths. Use these with:
get— Retrieve a single documentmulti_get— Retrieve by glob (e.g.,journals/2025-05*.md) or comma-separated list
qmd:// URI scheme.
qmd:// Resources
Documents are exposed as MCP resources with URIs like:- URI — Unique identifier for the document
- Name — Display name (collection/path)
- Title — Document title (from frontmatter or first heading)
- MIME type —
text/markdown - Text — Full document content with optional line numbers
- Context — Metadata describing the content (from
qmd context)
Response Formats
All tools return both:- Text content — Human-readable summary for the LLM
- Structured content — Machine-readable JSON for parsing
query response:
Starting the MCP Server
Stdio Transport (Default)
For Claude Desktop and other MCP clients:HTTP Transport
For web applications and debugging:http://localhost:8181/mcp with a /health endpoint.
See qmd mcp --help for daemon mode and additional options.
Relationship to CLI Commands
Each MCP tool corresponds to a CLI command:| MCP Tool | CLI Command | Description |
|---|---|---|
query | qmd query | Multi-strategy search with reranking |
get | qmd get | Retrieve single document |
multi_get | qmd multi-get | Retrieve multiple documents |
status | qmd status | Index status |
Next Steps
query Tool
Learn the structured search query format
get Tool
Retrieve documents by path or docid
MCP Specification
Read the full MCP spec
CLI Reference
Compare with CLI commands