feat(desktop): filter outputs MCP listing by entry kind#258
Merged
Conversation
Reviewer's GuideAdd an optional entry_kind filter to the quantlab_outputs_list MCP tool so callers can list all outputs, only directories, or only files, and document the new behavior in the desktop README. Sequence diagram for quantlab_outputs_list entry_kind filteringsequenceDiagram
actor MCPClient
participant MCPServer
participant listOutputs
participant FileSystem
MCPClient->>MCPServer: quantlab_outputs_list(relative_path, entry_kind)
MCPServer->>listOutputs: listOutputs(relative_path, entry_kind)
listOutputs->>FileSystem: resolveOutputsPath(relative_path)
listOutputs->>FileSystem: fs.stat(targetPath)
FileSystem-->>listOutputs: stat(targetPath)
listOutputs->>FileSystem: fs.readdir(targetPath, withFileTypes)
FileSystem-->>listOutputs: directoryEntries
loop build_detailed_entries
listOutputs->>FileSystem: fs.stat(entryPath)
FileSystem-->>listOutputs: entryStat
listOutputs-->>listOutputs: push to detailed
end
listOutputs-->>listOutputs: sort detailed by name
alt entry_kind is directory
listOutputs-->>listOutputs: filteredEntries = detailed kind directory
else entry_kind is file
listOutputs-->>listOutputs: filteredEntries = detailed kind file
else entry_kind is all
listOutputs-->>listOutputs: filteredEntries = detailed
end
listOutputs-->>MCPServer: payload(root, requested_path, absolute_path, entry_kind, entry_count, entries)
MCPServer-->>MCPClient: tool_response(payload)
Flow diagram for listOutputs entry_kind filtering logicgraph TD
A_start[listOutputs called with relativePath and entryKind]
A_start --> B_resolve[Resolve outputs path from relativePath]
B_resolve --> C_stat[fs.stat on targetPath]
C_stat --> D_is_dir{Is targetPath a directory?}
D_is_dir -- No --> E_error[Throw not a directory error]
D_is_dir -- Yes --> F_read[fs.readdir withFileTypes on targetPath]
F_read --> G_build_detailed[Build detailed entries with kind, size, mtime]
G_build_detailed --> H_sort[Sort detailed entries by name]
H_sort --> I_entry_kind{entryKind value}
I_entry_kind -- directory --> J_filter_dir[filteredEntries = detailed where kind is directory]
I_entry_kind -- file --> K_filter_file[filteredEntries = detailed where kind is file]
I_entry_kind -- all --> L_filter_all[filteredEntries = detailed]
J_filter_dir --> M_build_payload[Build payload with entry_kind, entry_count, entries]
K_filter_file --> M_build_payload
L_filter_all --> M_build_payload
M_build_payload --> N_return[Return payload to caller]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Changing
entry_countto reflect only the filtered entries instead of the total directory entries is a subtle behavioral change that may surprise existing MCP callers; consider adding a separatetotal_entry_countor preserving the original meaning ofentry_countfor backward compatibility. - The nested ternary used to compute
filteredEntriesmakes the filtering logic a bit hard to scan; consider switching to a smallswitch/ifblock or a lookup map keyed byentryKindfor improved readability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Changing `entry_count` to reflect only the filtered entries instead of the total directory entries is a subtle behavioral change that may surprise existing MCP callers; consider adding a separate `total_entry_count` or preserving the original meaning of `entry_count` for backward compatibility.
- The nested ternary used to compute `filteredEntries` makes the filtering logic a bit hard to scan; consider switching to a small `switch`/`if` block or a lookup map keyed by `entryKind` for improved readability.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an optional
entry_kindparameter toquantlab_outputs_listso MCP callers can list all entries, directories only, or files only.Scope
Read-only MCP tooling only. No trading, submit, signing, or broker execution changes.
Files:
desktop/mcp-server.mjsdesktop/README.mdValidation
node --check desktop/mcp-server.mjsgit diff --checkNotes
entry_kinddefaults toall, preserving behavior for existing callers; responses include an explicitentry_kindfield.desktop/README.md.AGENTS.mdpointer to keep this slice narrow.Closes #257