Skip to content

Support sorting in the directory listing API #1267

Description

@phernandez

Problem

The hosted MCP project and folder browser needs to render one exact directory with both its child folders and notes. The Core directory contract currently accepts directory, depth, glob, page, and page size, but no sort order.

For Title descending, Newest, or Oldest, Cloud must switch to a notes-only endpoint. That loses folder cards. Calling both endpoints would restore folders but duplicate the directory read and repeat work on every navigation.

Proposed contract

Add an explicit, closed sort option to the directory endpoint and DirectoryClient.list, covering:

  • title_asc (existing default behavior)
  • title_desc
  • updated_asc
  • updated_desc

The response should keep directories and files in one exact-depth listing with stable pagination and deterministic tie-breaking. Folder ordering should be defined explicitly, preferably folders first using the same selected direction within the folder group.

Acceptance criteria

  • The directory API and typed client accept the supported sort variants.
  • A single depth-1 request returns child folders and notes in the requested deterministic order.
  • Pagination remains stable across pages for equal titles or timestamps.
  • Existing callers retain the current default ordering when sort is omitted.
  • Endpoint, client, and pagination behavior have regression coverage.

Context

This unblocks removing the hosted MCP notes-only sorting fallback while preserving its one-directory-read navigation contract.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions