Skip to content

Add document layer-tree tool#50

Open
bbible3 wants to merge 2 commits intoloonghao:mainfrom
bbible3:feat/document-layer-tree
Open

Add document layer-tree tool#50
bbible3 wants to merge 2 commits intoloonghao:mainfrom
bbible3:feat/document-layer-tree

Conversation

@bbible3
Copy link
Copy Markdown

@bbible3 bbible3 commented Mar 25, 2026

This PR adds a dedicated MCP tool that returns the active document’s hierarchical layer structure and fixes root-layer coverage so ungrouped layers are not omitted.

What’s included

  1. Added new tool: photoshop_get_document_layer_tree
  2. Added ActionManager method to build a recursive tree of:
  • groups (type: group, children)
  • layers (type: layer)
  1. Added explicit ungrouped_layers in the response so document-level (non-grouped) layers are always visible.
  2. Kept existing photoshop_get_active_document_info behavior intact for backward compatibility.

Why

get_active_document_info returns flat lists, which does not preserve parent/child relationships.
A dedicated tree endpoint is needed to understand actual group membership.

Response shape (new tool)

  • success
  • document_name
  • layer_tree (recursive nodes)
  • ungrouped_layers (top-level non-grouped layers)

Validation

  1. Verified photoshop_get_document_layer_tree returns nested groups and child layers.
  2. Verified root layers now appear in both layer_tree (top-level layer nodes) and ungrouped_layers.
  3. Verified count alignment on test document:
  • flat layers count from photoshop_get_active_document_info: 13
  • ungrouped_layers count from photoshop_get_document_layer_tree: 13
  1. Verified photoshop_get_active_document_info remains unchanged and still returns expected flat layer/group lists.

Files changed

  • photoshop_mcp_server/ps_adapter/action_manager.py
  • photoshop_mcp_server/tools/session_tools.py

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