Repository navigation
refactor(api): look up MCP connections through one helper - #3776
Conversation
Add mcp/utils/connections.ts (getMcpConnections, getMcpConnection, validateMcpConnectionId) taking the full McpContext, and route every MCP tool and prompt connection lookup through it, including getMcpClickhouseClient. No behavior change.
|
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
2 finding(s): 🔴 0 P0/P1 · 🟡 0 P2 · 🔵 2 P3 No inline comments. 2 P3 folded at the bottom. 🔵 2 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 Review✅ No critical issues found. This is a pure mechanical refactor: three thin wrappers in
Team-scoping and tenant isolation are preserved — every helper keys off No P0/P1/P2 findings. Reviewers (6): ce-correctness-reviewer, ce-testing-reviewer, ce-maintainability-reviewer, ce-kieran-typescript-reviewer, ce-security-reviewer, ce-project-standards-reviewer Testing gaps: none — new helper behavior is fully covered; rewired call sites are unchanged existing code. |
E2E Test Results✅ All tests passed • 475 passed • 1 skipped • 1247s
Tests ran across 4 shards in parallel. |
Will adjust PromQL in a different PR |
Summary
MCP tools and prompts called the connection controller directly (
getConnectionsByTeam,getConnectionById,validateConnectionId) from five places. This addsmcp/utils/connections.tswith three helpers that take the fullMcpContext:getMcpConnections(context)getMcpConnection(context, connectionId, { selectPassword }?)validateMcpConnectionId(context, connectionId)Every MCP call site now uses them, including
getMcpClickhouseClient. The rules about which connections an MCP caller can use now live in one place, matching howmcp/utils/clickhouse.tsandmcp/utils/sources.tsalready work.No behavior change: same return values, null when a connection is not found, and the same validation messages and tool output.
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 newsrc/mcp/__tests__/mcpConnections.test.tsand the existing MCP unit tests, including the dashboard prompt tests.make dev-int FILE=src/mcp/__tests__runs the MCP integration suites (sources, dashboards, saved searches and more): 23 suites, 636 tests pass.How to test on Vercel preview
N/A, non-UI change.
References