Add limit / activeOnly / completedOnly params to job_list#2
Open
johntrandall wants to merge 1 commit into
Open
Add limit / activeOnly / completedOnly params to job_list#2johntrandall wants to merge 1 commit into
johntrandall wants to merge 1 commit into
Conversation
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
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.
What this changes
Three new optional, backward-compatible params on
job_list:limitactiveOnlyrunningIdscompletedOnlyfinishedIdsMechanism: a new
src/tools/overrides.tsholds two tables keyed by OpenAPIoperationId—INPUT_AUGMENTATIONS(extra Zod params merged into the OpenAPI-derived schema) andPOST_PROCESSORS(transformresponse.databefore serialization).registry.tsis 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+ newsrc/tools/overrides.ts).Why
job/listreturns three arrays:jobids(master set, =finishedIds ∪ runningIds),finishedIds, andrunningIds. With--rc-job-expire-duration=168hand 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 inpackage.json). Verified end-to-end against a live rcd with 7,250 retained jobs:{}(default) → all three arrays returned (back-compat){ activeOnly: true }→executeId+runningIdsonly{ completedOnly: true, limit: 3 }→executeId+finishedIds(3 entries){ limit: 2 }→ all three arrays, each sliced to last 2 entriestsc --noEmit✓tsupbuild ✓biome check src/tools/cleanHappy to add a test framework + cases in a follow-up if you'd prefer that landed with the feature.
Generated with Claude Code