Skip to content

Conversation

@lfnovo
Copy link

@lfnovo lfnovo commented Dec 16, 2025

Summary

This PR adds two new MCP tools for DSL-based searching, unlocking powerful metadata-based queries that were previously unavailable:

New Tools

query - Execute arbitrary Logseq DSL queries

  • Property queries: (page-property status active)
  • Task queries: (task todo)
  • Logical combinations: (and ...) (or ...) (not ...)
  • Tag queries: (page-tags [[tag-name]])
  • Date ranges: (between [[Dec 1st, 2024]] [[Dec 15th, 2024]])
  • Optional limit parameter (default: 100)
  • Optional result_type parameter to filter results (pages_only, blocks_only, all)
  • Type indicators in results (📄 page / 📝 block)

find_pages_by_property - Simplified interface for property searches

  • Search by property name only: find_pages_by_property(property_name="type")
  • Search with specific value: find_pages_by_property(property_name="type", property_value="customer")
  • Auto-escapes special characters in values
  • Shows property values in results
  • Optional limit parameter (default: 100)

Technical Details

  • Both tools use the logseq.DB.q API method
  • Added query_dsl() method to the LogSeq API client
  • Follows existing tool handler patterns

Changes

  • Added 1 new API method to logseq.py
  • Added 2 new tool handlers to tools.py
  • Registered handlers in server.py
  • Added 18 new unit tests (68 total tests pass)
  • Bumped version to 1.2.0
  • Total tools: 8 (up from 6)

Test plan

  • All 68 unit tests pass (uv run pytest)
  • Integration test verifies 8 tools registered
  • Manual testing with real LogSeq instance

Add two new MCP tools for DSL-based searching:

- query: Execute arbitrary Logseq DSL queries with support for:
  - Property queries: (page-property status active)
  - Task queries: (task todo)
  - Logical combinations: (and ...) (or ...) (not ...)
  - Optional limit and result_type (pages_only, blocks_only, all) parameters
  - Type indicators in results (📄 page / 📝 block)

- find_pages_by_property: Simplified interface for property searches
  - Search by property name only or with specific value
  - Auto-escapes special characters in values
  - Shows property values in results

Both tools use the logseq.DB.q API method.

Includes 18 new unit tests (68 total tests pass).
Total tools now: 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant