Skip to main content

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

๐Ÿš€ 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:

๐Ÿ†˜ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdquery-0.4.0.tar.gz (152.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mdquery-0.4.0-py3-none-any.whl (165.0 kB view details)

Uploaded Python 3

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

Hashes for mdquery-0.4.0.tar.gz
Algorithm Hash digest
SHA256 4c17b140a8a3d4c942112af7fb0221bae137412f28b356fb453c087a1b6e9685
MD5 9c1d6d0b505bb3195f22e25c19ad44ca
BLAKE2b-256 cb87906c400458ee0c6447dd4a2c6c2ecf641689ff003f6f5482a2f381c1758e

See more details on using hashes here.

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

Hashes for mdquery-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e97d6e44571542eb31a693b764c0a7a72ba6cbcc83261329259ac941123ea05
MD5 4e3d8af2f4caa9336b797751f221d70a
BLAKE2b-256 9b34d9c0f296cb3b77f9ea0376512308e24b0d9afb6d781655fed9d4c21c3a48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page