Universal markdown querying tool with SQL-like syntax
Project description
mdquery
Universal markdown querying tool with SQL-like syntax for searching and analyzing markdown files across different note-taking systems and static site generators.
Table of Contents
- mdquery
๐ Quick Start
Command Line Usage
# Install
pip install -r requirements.txt
pip install -e .
# Index your notes
mdquery index /path/to/your/notes
# Query your notes
mdquery query "SELECT * FROM files WHERE tags LIKE '%research%'"
AI Assistant Integration (MCP)
Use mdquery with AI assistants like Claude Desktop:
Single Directory:
{
"mcpServers": {
"mdquery": {
"command": "python",
"args": ["-m", "mdquery.mcp_server"],
"env": {
"MDQUERY_NOTES_DIR": "/Users/username/Documents/Notes"
}
}
}
}
Multiple Directories:
{
"mcpServers": {
"mdquery-personal": {
"command": "python",
"args": ["-m", "mdquery.mcp_server"],
"env": {
"MDQUERY_NOTES_DIR": "/Users/username/PersonalNotes"
}
},
"mdquery-work": {
"command": "python",
"args": ["-m", "mdquery.mcp_server"],
"env": {
"MDQUERY_NOTES_DIR": "/Users/username/WorkDocs"
}
}
}
}
Then ask your AI assistant: "Analyze my markdown notes and find patterns in my research topics"
๐ Documentation
| Resource | Description |
|---|---|
| ๐ Complete Documentation | Full documentation hub with all guides |
| ๐ฏ User Guide | Getting started, installation, and usage |
| ๐ Query Syntax | Complete SQL syntax reference and examples |
| ๐ง API Reference | Developer API documentation |
| ๐ก Examples | Real-world usage examples and workflows |
| โก Best Practices | Performance tips and optimization |
Project Structure
mdquery/
โโโ __init__.py # Package initialization and exports
โโโ models.py # Core data models (QueryResult, FileMetadata, ParsedContent)
โโโ indexer.py # File indexing engine
โโโ query.py # SQL query engine
โโโ cache.py # Cache management system
โโโ cli.py # Command-line interface
โโโ mcp.py # MCP server interface
โโโ parsers/
โโโ __init__.py # Parsers package initialization
โโโ frontmatter.py # Frontmatter parser
โโโ markdown.py # Markdown content parser
โโโ tags.py # Tag extraction parser
โโโ links.py # Link extraction parser
Usage
Command Line Interface
# Query markdown files
mdquery query "SELECT * FROM files WHERE tags LIKE '%research%'"
# Index a directory
mdquery index /path/to/notes --recursive
# View schema
mdquery schema --table files
Python API
from mdquery import QueryResult, FileMetadata, ParsedContent
from mdquery.query import QueryEngine
from mdquery.indexer import Indexer
# Initialize components
indexer = Indexer()
query_engine = QueryEngine()
# Index files and query
indexer.index_directory("/path/to/notes")
result = query_engine.execute_query("SELECT * FROM files")
โจ Key Features
- Universal Compatibility: Works with Obsidian, Joplin, Jekyll, and generic markdown
- SQL-Like Queries: Familiar syntax for powerful searches and analysis
- Full-Text Search: Fast content search with SQLite FTS5
- Rich Metadata: Query frontmatter, tags, links, and content structure
- High Performance: Efficient indexing and caching for large collections
- Multiple Interfaces: CLI tool and MCP server for AI integration
๐ Quick Examples
Find Research Notes
SELECT filename, tags FROM files
WHERE tags LIKE '%research%'
ORDER BY modified_date DESC;
Content Analysis
SELECT tag, COUNT(*) as usage FROM tags
GROUP BY tag
ORDER BY usage DESC
LIMIT 10;
Cross-Reference Analysis
SELECT f.filename, COUNT(l.link_target) as outgoing_links
FROM files f
JOIN links l ON f.id = l.file_id
WHERE l.is_internal = 1
GROUP BY f.id
ORDER BY outgoing_links DESC;
๐ Supported Markdown Systems
| System | Wikilinks | Nested Tags | Frontmatter | Collections |
|---|---|---|---|---|
| Obsidian | โ
[[Page]] |
โ
#parent/child |
โ YAML | โ Folders |
| Joplin | โ | โ | โ Metadata | โ Notebooks |
| Jekyll | โ | โ | โ YAML | โ
_posts, _pages |
| Generic | โ | โ | โ YAML | โ Directories |
๐งช Development
This project follows a structured implementation plan. See .kiro/specs/mdquery/tasks.md for the complete task list and implementation order.
Running Tests
# Run all tests
python tests/run_comprehensive_tests.py
# Generate performance test data (1000+ files)
python tests/generate_performance_data.py
# Run specific test categories
python -m pytest tests/test_format_compatibility.py -v
Requirements
- Python 3.8+
- SQLite3 (included with Python)
- Dependencies listed in requirements.txt
Contributing
See the documentation for complete guides on:
- API Reference for developers
- Examples for usage patterns
- Best Practices for optimization
๐ Need Help?
| Question | Resource |
|---|---|
| How do I get started? | User Guide |
| What queries can I write? | Query Syntax Guide |
| How do I use the Python API? | API Reference |
| Can you show me real examples? | Examples Collection |
| How do I optimize performance? | Best Practices |
| Does it work with my markdown system? | Supported Systems |
๐ License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mdquery-0.4.0.tar.gz.
File metadata
- Download URL: mdquery-0.4.0.tar.gz
- Upload date:
- Size: 152.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c17b140a8a3d4c942112af7fb0221bae137412f28b356fb453c087a1b6e9685
|
|
| MD5 |
9c1d6d0b505bb3195f22e25c19ad44ca
|
|
| BLAKE2b-256 |
cb87906c400458ee0c6447dd4a2c6c2ecf641689ff003f6f5482a2f381c1758e
|
File details
Details for the file mdquery-0.4.0-py3-none-any.whl.
File metadata
- Download URL: mdquery-0.4.0-py3-none-any.whl
- Upload date:
- Size: 165.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e97d6e44571542eb31a693b764c0a7a72ba6cbcc83261329259ac941123ea05
|
|
| MD5 |
4e3d8af2f4caa9336b797751f221d70a
|
|
| BLAKE2b-256 |
9b34d9c0f296cb3b77f9ea0376512308e24b0d9afb6d781655fed9d4c21c3a48
|