Skip to content

mcp: add lab (runtime) queries - #311

Open
bhcopeland wants to merge 6 commits into
kernelci:mainfrom
bhcopeland:mcp-lab-queries
Open

mcp: add lab (runtime) queries#311
bhcopeland wants to merge 6 commits into
kernelci:mainfrom
bhcopeland:mcp-lab-queries

Conversation

@bhcopeland

Copy link
Copy Markdown
Member

This is also based on #310 so that needs to be merged first.

bhcopeland and others added 6 commits August 26, 2026 17:45
The MCP query tools take status as a free-form string and hand it to
StatusFilter, which only ever compares against lowercase 'pass', 'fail'
and 'inconclusive'. Anything else matched nothing and returned an empty
page with no error, so a caller could not tell a rejected value from a
genuine absence of results. That includes the uppercase 'FAIL' the
dashboard itself reports, which made echoing an observed status back as
a filter look like a clean "no failures" answer.

Normalise the value and reject anything outside the set the filter
understands. The CLI is unaffected, since click.Choice already
constrains it there.

Also list 'all' in the tool docstrings, which the filter accepts but
none of them mentioned.

Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
limit and offset reach a plain list slice, so Python's negative index
handling quietly reinterpreted them: a negative limit returned nearly
the whole result set, defeating the pagination that exists to keep
responses small, and a negative offset returned an empty page while
still reporting the full total. list_nodes passed both straight to the
Maestro API instead.

Reject negative values in both paths.

Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
Filters are split on '=' and passed to requests as query parameter
pairs. A filter string without '=' produced a one-element tuple that
failed deep in the request layer, where the generic handler turned it
into "Maestro nodes request failed" with no mention of the filter that
caused it.

Check the syntax before the request and name the offending filter.

Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
The issue fetchers interpolate the id into their endpoint, so an empty
id turns "issue/<id>" into "issue/", which is the collection endpoint
dashboard_fetch_issue_list already uses. The request then succeeded and
returned every known issue in place of the one that was asked for.

Over MCP that surfaced as a 150KB result reported as success. On the
command line, "kci-dev results issue --id ''" printed an issue with
every field None and a dashboard link to /issue/None, then exited 0.

Guard the three issue fetchers, which is the point the CLI and the
library client share. The builds and tests siblings requested
"issue//builds", which 404s, so those failed already but without
saying why.

Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
Add list_labs, backed by the dashboard /metrics/ endpoint, returning the
labs reporting to KernelCI with their build, boot and test counts for the
last N days. Those names feed a new lab filter on list_builds, list_boots
and list_tests, matching the top-level 'lab' field on boots and tests and
'misc.lab'/'misc.runtime' on builds.

The dashboard has no server-side lab filter, so the filter narrows the
fetched page rather than the request. Keep the 'labs' key in the compact
get_summary response, which already aggregates per lab, and document
data.runtime and data.platform in the list_nodes docstring.

Reported-by: Yogesh Lal <yogesh.lal@oss.qualcomm.com>
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
days was passed through unchecked to a metrics aggregation that gets
slower as its window grows. Measured against production: 3 days answers
in under 10s cold, 7 days takes around 56s, and 14 and 30 days always
exceed the 60s read timeout and come back as a bare "Dashboard metrics
request failed" after a full minute. Cap the window at 7 days, so a
caller cannot ask for one that cannot succeed.

An unknown lab returned matched=0, which is indistinguishable from a lab
that ran nothing on that commit. Return the labs the fetched entries
actually report, so a mistyped name shows up without a second call.
Validating up front is not possible: lab names are an open set and the
only source is the metrics call itself.

Drop 'maestro' as the example lab for builds. Every build from that
origin reports it as misc.lab, so filtering by it matches everything;
the runtime cluster is the value that discriminates.

Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
@bhcopeland bhcopeland changed the title Mcp lab queries mcp: add lab (runtime) queries Aug 27, 2026
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.

2 participants