Describe the bug
The getJobs tool hangs indefinitely on Jenkins instances with many jobs, even when using small limit values like 10.
Root Cause
The current implementation in DefaultMcpServer.java materializes ALL jobs before applying pagination:
return parent.getItemsStream()
.sorted(Comparator.comparing(Item::getName))
.skip(skip)
.limit(limit)
.toList();
The .sorted() operation forces the entire stream to be loaded into memory before skip and limit can be applied. On large Jenkins instances, this causes:
- Excessive memory usage
- CPU spike during sorting
- Timeout before results can be returned
Expected behavior
The getJobs tool should return results within a reasonable time regardless of total job count, since the user only requested a small page of results.
Environment
- Jenkins version: 2.516.1
- MCP Server Plugin version: 0.149.ve5cd2f59de01
- Approximate number of jobs: thousands
- MCP Client: Claude Code CLI
Reproduction steps
- Have a Jenkins instance with thousands of jobs
- Call
getJobs with limit: 10
- Observe the call hangs/times out
Suggested fix
Use Jenkins API pagination - Jenkins REST API supports tree=jobs[name]{0,10} style queries that paginate server-side.
Workaround
Users can use parentFullName parameter to scope to a specific folder with fewer jobs, or use getJob with known job names directly.
Related issues
Describe the bug
The
getJobstool hangs indefinitely on Jenkins instances with many jobs, even when using smalllimitvalues like 10.Root Cause
The current implementation in
DefaultMcpServer.javamaterializes ALL jobs before applying pagination:The
.sorted()operation forces the entire stream to be loaded into memory beforeskipandlimitcan be applied. On large Jenkins instances, this causes:Expected behavior
The
getJobstool should return results within a reasonable time regardless of total job count, since the user only requested a small page of results.Environment
Reproduction steps
getJobswithlimit: 10Suggested fix
Use Jenkins API pagination - Jenkins REST API supports
tree=jobs[name]{0,10}style queries that paginate server-side.Workaround
Users can use
parentFullNameparameter to scope to a specific folder with fewer jobs, or usegetJobwith known job names directly.Related issues