Skip to content

tidyinfo/qmd-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

QMD Wrapper

License Rust Release

English | ็ฎ€ไฝ“ไธญๆ–‡

A Rust-based command-line wrapper for the QMD (Query Markup Documents) MCP server, enabling remote access to QMD search functionality via HTTP.

Features

  • ๐Ÿ”Œ Remote MCP Access - Connect to QMD servers over HTTP with full CLI parity
  • ๐Ÿ“ฆ Statically Linked - Single binary with zero runtime dependencies (musl)
  • ๐Ÿ’พ Session Persistence - Automatic session management across CLI invocations
  • ๐Ÿš€ Fast & Lightweight - ~3.6MB binary with LTO optimization
  • ๐Ÿ”’ Secure by Default - rustls TLS backend, no OpenSSL dependencies
  • ๐ŸŽฏ Interactive Setup - Guided configuration with health checks

Quick Start

1. Download

# From releases page
wget https://github.com/tidyinfo/qmd-wrapper/releases/latest/download/qmd

# Make executable
chmod +x qmd

2. Configure

# Connect to remote QMD server
./qmd connect --hostname <server-host> --port <server-port>

# Example
./qmd connect --hostname 192.168.1.100 --port 8181

3. Use

# Search documents
./qmd search "your query" --json

# Get status
./qmd status

# Retrieve document
./qmd get path/to/file.md

Installation

From Pre-built Binary

  1. Download the latest release from Releases
  2. Place in your PATH: sudo cp qmd /usr/local/bin/

From Source

Prerequisites:

  • Rust 1.92 or later
  • musl-tools (for static linking)
# Clone repository
git clone https://github.com/tidyinfo/qmd-wrapper.git
cd qmd-wrapper

# Install Rust (if needed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup default stable

# Add musl target
rustup target add x86_64-unknown-linux-musl

# Install musl tools (Debian/Ubuntu)
sudo apt-get install musl-tools musl-dev

# Build static binary
cargo build --release --target x86_64-unknown-linux-musl

# Binary location
ls -lh target/x86_64-unknown-linux-musl/release/qmd

Configuration

Server Connection

# Non-interactive mode
./qmd connect --hostname example.com --port 8181

# Interactive mode (with prompts)
./qmd connect

Config File Locations

The wrapper searches for configuration in the following order:

  1. ./qmd.toml (same directory as binary)
  2. ./config.toml (same directory as binary)
  3. /etc/qmd/config.toml
  4. ~/.config/qmd/config.toml
  5. ~/.qmd.toml

Configuration Format

[server]
host = "localhost"
port = 8181
session_id = "auto-generated-after-first-connect"

Commands

Search Commands

# Keyword search (BM25)
./qmd search "query" [options]

# Query expansion + reranking (if supported)
./qmd query "query" [options]

# Vector similarity search (if supported)
./qmd vsearch "query" [options]

Search Options:

Option Description Default
-n, --num <NUM> Number of results 5
--all Return all matches false
--min-score <SCORE> Minimum similarity score 0
--full Output full document false
--line-numbers Add line numbers false
--files Output docid,score,filepath,context false
--json JSON output false
--csv CSV output false
--md Markdown output false
--xml XML output false
-c, --collection <NAME> Filter by collection -
--index <NAME> Custom index name index

Document Retrieval

# Get single document
./qmd get <file>[:line] [-l N] [--from N]

# Get multiple documents by glob pattern
./qmd multi-get <pattern> [-l N] [--max-bytes N]

# List collections or files
./qmd ls [collection[/path]]

Index Management

# Show index status
./qmd status

# Re-index all collections
./qmd update [--pull]

# Create vector embeddings
./qmd embed [-f]

# Cleanup cache and orphaned data
./qmd cleanup

Collection Management

# List collections
./qmd collection list

# Add collection
./qmd collection add [path] --name <name> --mask <pattern>

# Remove collection
./qmd collection remove <name>

# Rename collection
./qmd collection rename <old> <new>

Context Management

# List contexts
./qmd context list

# Add context
./qmd context add [path] "text"

# Remove context
./qmd context rm <path>

Examples

Basic Search Workflow

# 1. Connect to server
./qmd connect --hostname qmd.example.com --port 8181

# 2. Check index status
./qmd status

# 3. Search for documents
./qmd search "machine learning" --json -n 10

# 4. Get full document
./qmd get docs/ml-basics.md --full

# 5. Search with filters
./qmd search "neural networks" --min-score 0.7 --collection research

Advanced Usage

# Export results as CSV
./qmd search "API design" --csv > results.csv

# Get document from specific line
./qmd get src/main.rs:100 -l 50

# Batch retrieve files
./qmd multi-get "docs/*.md" --max-bytes 50000

# Full-text search with line numbers
./qmd search "configuration" --full --line-numbers

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     HTTP POST      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   qmd wrapper   โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€> โ”‚  QMD MCP Server     โ”‚
โ”‚   (Rust CLI)    โ”‚    JSON-RPC        โ”‚  (Node.js + Bun)    โ”‚
โ”‚                 โ”‚ <โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚  http://host:port   โ”‚
โ”‚  - CLI parsing  โ”‚    MCP Response    โ”‚                     โ”‚
โ”‚  - Session mgmt โ”‚                    โ”‚  - Tool registry    โ”‚
โ”‚  - Config mgmt  โ”‚                    โ”‚  - Search engine    โ”‚
โ”‚                 โ”‚                    โ”‚  - Vector DB        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Session Management

The MCP HTTP transport requires session initialization:

  1. First Command: Automatically calls initialize endpoint
  2. Session ID: Extracted from Mcp-Session-Id response header
  3. Persistence: Saved to config file for reuse
  4. Subsequent Commands: Reuse cached session ID
  5. Server Restart: Automatically re-initializes on session mismatch

Troubleshooting

Connection Issues

# Test server health
curl http://host:port/health

# Expected response
{"status":"ok","uptime":N}

Session Problems

# Reset session (edit config file)
# Remove the session_id line from qmd.toml

Common Errors

Error Cause Solution
Failed to connect Server offline Check server status
Server already initialized Session mismatch Delete session_id from config
Tool not found Unsupported tool Check server capabilities

Development

Project Structure

qmd-wrapper/
โ”œโ”€โ”€ Cargo.toml           # Dependencies
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.rs          # Entry point
โ”‚   โ”œโ”€โ”€ cli.rs           # CLI definitions
โ”‚   โ”œโ”€โ”€ config.rs        # Configuration
โ”‚   โ””โ”€โ”€ mcp_client.rs    # MCP client
โ”œโ”€โ”€ dist/                # Built binaries
โ””โ”€โ”€ README.md            # This file

Build Commands

# Debug build
cargo build

# Release build (dynamic)
cargo build --release

# Static build (musl)
cargo build --release --target x86_64-unknown-linux-musl

# Run tests
cargo test

# Format code
cargo fmt

# Lint
cargo clippy

Dependencies

Crate Version Purpose
clap 4.5 CLI parsing
reqwest 0.12 HTTP client
tokio 1 Async runtime
serde 1.0 Serialization
toml 0.8 Config parsing
dialoguer 0.11 Interactive prompts

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Acknowledgments


็ฎ€ไฝ“ไธญๆ–‡

QMD Wrapper ๆ˜ฏไธ€ไธชๅŸบไบŽ Rust ็š„ๅ‘ฝไปค่กŒๅทฅๅ…ท๏ผŒ็”จไบŽ่ฟœ็จ‹่ฎฟ้—ฎ QMD (Query Markup Documents) MCP ๆœๅŠกๅ™จใ€‚

ไธป่ฆ็‰นๆ€ง

  • ๐Ÿ”Œ ่ฟœ็จ‹ MCP ่ฎฟ้—ฎ - ้€š่ฟ‡ HTTP ่ฟžๆŽฅ QMD ๆœๅŠกๅ™จ๏ผŒๆ”ฏๆŒๅฎŒๆ•ด CLI ๅŠŸ่ƒฝ
  • ๐Ÿ“ฆ ้™ๆ€้“พๆŽฅ - ๅ•ไธ€ไบŒ่ฟ›ๅˆถๆ–‡ไปถ๏ผŒ้›ถ่ฟ่กŒๆ—ถไพ่ต–
  • ๐Ÿ’พ ไผš่ฏๆŒไน…ๅŒ– - ่‡ชๅŠจ็ฎก็†ไผš่ฏ็Šถๆ€
  • ๐Ÿš€ ๅฟซ้€Ÿ่ฝป้‡ - ็บฆ 3.6MB๏ผŒLTO ไผ˜ๅŒ–
  • ๐Ÿ”’ ๅฎ‰ๅ…จ้ป˜่ฎค - rustls TLS๏ผŒๆ— ้œ€ OpenSSL
  • ๐ŸŽฏ ไบคไบ’้…็ฝฎ - ๅผ•ๅฏผๅผ้…็ฝฎๅ’Œๅฅๅบทๆฃ€ๆŸฅ

ๅฟซ้€Ÿๅผ€ๅง‹

# 1. ไธ‹่ฝฝ
wget https://github.com/tidyinfo/qmd-wrapper/releases/latest/download/qmd
chmod +x qmd

# 2. ้…็ฝฎ
./qmd connect --hostname 192.168.1.100 --port 8181

# 3. ไฝฟ็”จ
./qmd search "ๆŸฅ่ฏขๅ†…ๅฎน" --json

ๅฎŒๆ•ดๆ–‡ๆกฃ

่ฏฆ็ป†ไฝฟ็”จ่ฏดๆ˜Ž่ฏทๅ‚่€ƒไธŠๆ–น็š„่‹ฑๆ–‡ๆ–‡ๆกฃ้ƒจๅˆ†ใ€‚

ๅธธ่ง้—ฎ้ข˜

Q: ๅฆ‚ไฝ•้‡็ฝฎไผš่ฏ๏ผŸ
A: ็ผ–่พ‘ qmd.toml ๆ–‡ไปถ๏ผŒๅˆ ้™ค session_id ่กŒใ€‚

Q: ๆ”ฏๆŒๅ“ชไบ›ๆœ็ดข้€‰้กน๏ผŸ
A: ๆ”ฏๆŒ -n, --json, --csv, --full, --min-score ็ญ‰๏ผŒ่ฏฆ่งไธŠๆ–น Commands ้ƒจๅˆ†ใ€‚

Q: ๅฆ‚ไฝ•ๆž„ๅปบ้™ๆ€ไบŒ่ฟ›ๅˆถ๏ผŸ
A: ไฝฟ็”จๅ‘ฝไปค cargo build --release --target x86_64-unknown-linux-muslใ€‚

ๆŠ€ๆœฏๆ”ฏๆŒ

ๅฆ‚ๆœ‰้—ฎ้ข˜๏ผŒ่ฏทๆไบค GitHub Issueใ€‚

About

๐Ÿฆ€ Rust CLI wrapper for QMD MCP server. Remote HTTP access, zero dependencies. Static binary (~3.6MB), session persistence, full CLI parity. Perfect for server deployments without Node.js.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages