Skip to content

feat(desktop): filter outputs MCP listing by entry kind#258

Merged
Whiteks1 merged 6 commits intomainfrom
codex/mcp-outputs-entry-kind
Apr 4, 2026
Merged

feat(desktop): filter outputs MCP listing by entry kind#258
Whiteks1 merged 6 commits intomainfrom
codex/mcp-outputs-entry-kind

Conversation

@Whiteks1
Copy link
Copy Markdown
Owner

@Whiteks1 Whiteks1 commented Apr 4, 2026

Summary

Add an optional entry_kind parameter to quantlab_outputs_list so 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.mjs
  • desktop/README.md

Validation

  • node --check desktop/mcp-server.mjs
  • git diff --check

Notes

  • entry_kind defaults to all, preserving behavior for existing callers; responses include an explicit entry_kind field.
  • Documented the new parameter in desktop/README.md.
  • Intentionally omitted an AGENTS.md pointer to keep this slice narrow.

Closes #257

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 4, 2026

Reviewer's Guide

Add 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 filtering

sequenceDiagram
  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)
Loading

Flow diagram for listOutputs entry_kind filtering logic

graph 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]
Loading

File-Level Changes

Change Details Files
Add entry_kind filtering to the outputs listing implementation and response shape.
  • Extend listOutputs to accept an entryKind parameter with default 'all'.
  • Rename local readdir result to directoryEntries and build the existing detailed metadata list for all entries.
  • Compute filteredEntries based on entryKind ('directory', 'file', or all) using the existing kind metadata.
  • Include entry_kind in the returned payload and base entry_count and entries on the filtered set rather than the full list.
desktop/mcp-server.mjs
Expose entry_kind as an optional MCP tool input and update the tool description.
  • Update the quantlab_outputs_list tool description to mention the new entry_kind filter capability.
  • Extend the tool inputSchema with an optional entry_kind enum('all','directory','file') defaulting to 'all'.
  • Pass entry_kind from the MCP request through to listOutputs instead of always using the default.
desktop/mcp-server.mjs
Document the new entry_kind filter in the desktop MCP README.
  • Add a note under available tools describing that quantlab_outputs_list accepts optional relative_path and entry_kind filters with allowed values.
desktop/README.md

Possibly linked issues

  • #feat(desktop): filter outputs MCP listing by entry kind: PR implements the issue’s entry_kind filter in quantlab_outputs_list and updates MCP server and README accordingly.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Base automatically changed from codex/mcp-outputs-artifacts to main April 4, 2026 18:53
Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Whiteks1 Whiteks1 merged commit 00d4182 into main Apr 4, 2026
2 checks passed
@Whiteks1 Whiteks1 deleted the codex/mcp-outputs-entry-kind branch April 4, 2026 19:04
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.

feat(desktop): filter outputs MCP listing by entry kind

1 participant