Skip to content

Add dune query results for the MCP's getLatestQueryResult - #85

Merged
rahuldotiyer merged 2 commits into
mainfrom
query-latest-result
Nov 30, 2026
Merged

rahuldotiyer merged 2 commits into
mainfrom
query-latest-result

Conversation

@rahuldotiyer

Copy link
Copy Markdown
Contributor

Adds dune query results <query-id> [--limit] [--offset], matching the Dune MCP's getLatestQueryResult (duneanalytics/core#8349, kept in #8443, live in prod): the latest stored result of a saved query, without running it or using execution credits.

Impact map

Area Change Calls
query results new getLatestQueryResult

Review notes

  • Goes through the MCP rather than REST ResultsByQueryID, so licensed datasets stay withheld exactly as in the MCP; the tool's notice is printed instead of rows.
  • Text output shows Executed at and the run's parameters, since the result can be old or use non-default values. No stored result prints the tool's notice and the query link (exit 0). A failed stored run is an error.
  • Only --limit/--offset the user sets are sent, so server defaults (100 rows) apply.
  • Checked live on prod: query 1847 printed a stored result from 2026-11-10 (3 of 8091 rows); 3237721 printed the no-stored-result notice; 999999999 returned "Query not found".

Testing

go test ./... and go vet ./... pass.

No visual surface: CLI only.

core#8349/#8443 added getLatestQueryResult to the Dune MCP server: a saved
query's latest stored result, without running it. 'dune query results
<query-id>' calls it, shows when the run happened and its parameters, and
prints the tool's notice when no result is stored or rows are withheld for
licensed datasets. It goes through the MCP, not the REST results endpoint,
so the MCP's licensed-data withholding applies.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a2147b-3c2e-76b3-aeaf-0aafbe53d879

@norbertdurcansk norbertdurcansk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, with suggestions. The command is small and fits the existing pattern, and the tests check that only the flags the user sets are sent. Two non-blocking issues: a failed run returns exit code 0 with -o json, and withheld rows print a misleading 0 of 0 rows line. Plus one question about the withholding behavior.

Comment thread cmd/query/results.go Resolved
Comment thread cmd/query/results.go Resolved
Comment thread cmd/query/results.go Resolved
@rahuldotiyer
rahuldotiyer merged commit 5d3ec69 into main Nov 30, 2026
6 checks passed
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