Skip to content

Conversation

@lfnovo
Copy link

@lfnovo lfnovo commented Dec 16, 2025

Summary

This PR adds four new MCP tools for enhanced page and namespace management:

Namespace Tools

  • get_pages_from_namespace - Get all pages within a specific namespace

    • Returns flat list of pages matching the namespace prefix
    • Uses logseq.Editor.getPagesFromNamespace API
  • get_pages_tree_from_namespace - Get hierarchical tree of pages in a namespace

    • Returns nested structure showing parent-child relationships
    • Uses logseq.Editor.getPagesTreeFromNamespace API

Page Utility Tools

  • rename_page - Rename a page and automatically update all references throughout the graph

    • Pre-validates that source page exists and target name is available
    • Uses logseq.Editor.renamePage API
  • get_page_backlinks - Retrieve all pages and blocks that reference a specific page

    • Groups results by referencing page with reference counts
    • Optional include_content parameter to include/exclude block details
    • Uses logseq.Editor.getPageLinkedReferences API

Changes

  • Added 4 new API methods to logseq.py
  • Added 4 new tool handlers to tools.py
  • Registered handlers in server.py
  • Added comprehensive unit tests (77 total tests pass)
  • Total tools: 10 (up from 6)

Test plan

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

Add two new MCP tools for page management:

- rename_page: Rename a page and update all references throughout the graph
  - Pre-validates source exists and target doesn't exist
  - Uses logseq.Editor.renamePage API

- get_page_backlinks: Get all pages/blocks that reference a page
  - Groups results by referencing page
  - Optional include_content parameter for block details
  - Uses logseq.Editor.getPageLinkedReferences API

Includes comprehensive unit tests for both tools (15 new tests).
Total tools now: 10
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