Skip to content

Add limit / activeOnly / completedOnly params to job_list#2

Open
johntrandall wants to merge 1 commit into
rclone-ui:mainfrom
johntrandall:fix/job-list-filtering
Open

Add limit / activeOnly / completedOnly params to job_list#2
johntrandall wants to merge 1 commit into
rclone-ui:mainfrom
johntrandall:fix/job-list-filtering

Conversation

@johntrandall

Copy link
Copy Markdown

What this changes

Three new optional, backward-compatible params on job_list:

Param Type Effect
limit int (positive) Return only the most recent N entries in each array
activeOnly bool Return only runningIds
completedOnly bool Return only finishedIds

Mechanism: a new src/tools/overrides.ts holds two tables keyed by OpenAPI operationIdINPUT_AUGMENTATIONS (extra Zod params merged into the OpenAPI-derived schema) and POST_PROCESSORS (transform response.data before serialization). registry.ts is minimally changed to merge augmented schemas, filter augmented params out of the query forwarded to rcd, and run any matching post-processor on the response.

The override pattern is reusable: any future per-tool special case (custom param, response transform) drops in without touching the registration loop.

Diff is +119 / -7 across 2 files (src/tools/registry.ts + new src/tools/overrides.ts).

Why

job/list returns three arrays: jobids (master set, = finishedIds ∪ runningIds), finishedIds, and runningIds. With --rc-job-expire-duration=168h and active rclone usage, the response can be thousands of entries. In one environment: 7,250 jobids / 7,248 finishedIds / 2 runningIds → 157 KB response → MCP client (Claude Code) aborts ingestion → tool unusable for agent use.

Closes #1.

Tests

No tests existed in the repo at the time of this PR (no test/ directory, no test runner in package.json). Verified end-to-end against a live rcd with 7,250 retained jobs:

  • {} (default) → all three arrays returned (back-compat)
  • { activeOnly: true }executeId + runningIds only
  • { completedOnly: true, limit: 3 }executeId + finishedIds (3 entries)
  • { limit: 2 } → all three arrays, each sliced to last 2 entries
  • tsc --noEmit
  • tsup build ✓
  • biome check src/tools/ clean

Happy to add a test framework + cases in a follow-up if you'd prefer that landed with the feature.

Generated with Claude Code

rclone's `job/list` returns three arrays — `jobids` (master set),
`finishedIds`, and `runningIds`. With `--rc-job-expire-duration=168h`
and active rclone usage, this can be thousands of entries and exceed
an MCP client's context limit (a Claude Code session aborted ingestion
at 157 KB / 7,250 jobids).

This adds three optional, backward-compatible MCP-layer params to
`job_list`:

  limit:         int   Return only the most recent N entries in each array
  activeOnly:    bool  Return only `runningIds`
  completedOnly: bool  Return only `finishedIds`

Default behavior unchanged when no params are supplied.

Mechanism: introduces `src/tools/overrides.ts` with two tables keyed
by OpenAPI operationId — INPUT_AUGMENTATIONS (extra Zod params merged
into the generated schema) and POST_PROCESSORS (transform the rcd
response before serialization). The augmented params are filtered out
of the query forwarded to rcd. `registry.ts` is minimally changed to
use both tables; the generic loop is otherwise untouched.

The override pattern is extensible: any future per-tool special case
(custom params, response transform) drops into the same tables
without touching the core registration loop.

Verified end-to-end against a live rcd with 7,250 retained jobs;
tsc, biome (on changed files), and tsup build all pass.

Closes rclone-ui#1

Claude-Session-Id: 17222b2f-3f4a-4599-a0fa-a986a1acabd8
Resume: claude --resume 17222b2f-3f4a-4599-a0fa-a986a1acabd8
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.

Add filtering params to job_list (limit / activeOnly / completedOnly)

1 participant