Repository navigation
refactor(api): route MCP PromQL connection lookups through the MCP helper - #3777
brandon-pereira wants to merge 3 commits into
Conversation
…lper resolvePromqlTarget and getPromqlLabelCatalog take an optional getConnection lookup that defaults to the team-scoped controller lookup, so the REST /prometheus router is unchanged. The MCP PromQL tile and describe_source paths pass getMcpConnection, so every MCP connection lookup now goes through mcp/utils/connections.ts.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
3 finding(s): 🔴 0 P0/P1 · 🟡 0 P2 · 🔵 3 P3 No inline comments. 3 P3 folded at the bottom. 🔵 3 P3 — no action needed before merge
Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
Deep ReviewInternal refactor in Independent verification confirms the refactor is behavior-preserving: all four REST ✅ No critical issues found. 🟡 P2 — recommended
🔵 P3 nitpicks (1)
Reviewers (2 returned): security, correctness. Testing gaps:
Coverage note: Of the dispatched review team, the two highest-stakes personas (security, correctness) returned clean before output was required; both corroborated the no-behavior-change claim. The prior-review points were independently confirmed addressed — No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
E2E Test Results❌ 1 test failed • 478 passed • 1 skipped • 1301s
Tests ran across 4 shards in parallel. |
|
Re the review's P3 findings:
|
…nection-lookup # Conflicts: # packages/api/src/mcp/tools/sources/describePromqlSource.ts # packages/api/src/mcp/tools/sources/describeSource.ts
Summary
Follow-up to #3776.
#3776 routed MCP connection lookups through
mcp/utils/connections.ts. Two PromQL paths still skipped it, because they get their connection inside the sharedcontrollers/promql.ts:runPromqlTile, viaresolvePromqlTarget)describe_source(describePromqlSource, viagetPromqlLabelCatalog)This PR gives both controller functions an optional
getConnectionlookup. It defaults to the existing team-scopedgetConnectionById, so the REST/prometheusrouter is unchanged. The MCP paths now take the fullMcpContextand passgetMcpConnection, so every MCP connection lookup goes through the helper. The comment inconnections.tsdrops the PromQL exception that #3776 added.No behavior change: the same connection is found, the password is selected the same way, and the "Connection not found" errors are unchanged.
No changeset: internal refactor with no user-facing change.
How to reproduce
Starting point: N/A, internal refactor with no user-visible change.
Testing:
cd packages/api && yarn ci:unitruns the newcontrollers/__tests__/promqlConnectionLookup.test.ts(default lookup, custom lookup, and not-found handling) and a newdescribeSourceTimeout.test.tscase that checks PromQLdescribe_sourcelooks up connections through the MCP helper.make dev-int FILE="promql prometheus"covers the MCP PromQL tools and tiles plus the REST/prometheusrouter: 5 suites, 189 tests pass. The full MCP integration suite (make dev-int FILE=src/mcp/__tests__) also passes: 23 suites, 636 tests.How to test on Vercel preview
N/A, non-UI change.
References