feat(mcp): source & webhook CRUD tools#2702
Conversation
…e config Adds MCP tools so the ingest -> dashboard flow can be automated end to end: - clickstack_save_source / clickstack_delete_source - clickstack_save_webhook / clickstack_delete_webhook (save creates when id is omitted, updates when provided) Webhook create/update/delete logic is extracted into shared controllers (createWebhook/updateWebhook/deleteWebhook): createWebhook is used by the internal API, External API v2, and MCP; update/delete are shared by v2 + MCP (the internal API keeps its own masked-secret flow). clickstack_describe_source now returns a round-trippable `config` block — the exact flat shape clickstack_save_source accepts, including fields the curated summary previously omitted (correlation IDs, defaultTableSelectExpression, parent/span-kind expressions, materialized views). This closes the read/write asymmetry that made a faithful source clone impossible. Also fixes a pre-existing latent bug: a generic/incidentio webhook persisted without a body (body default is UI-only) crashed sendGenericWebhook on Handlebars.compile(undefined); it now falls back to the default body template. Also fixes updateSource dropping the team field on same-kind findOneAndReplace, which orphaned the source from team-scoped queries.
🦋 Changeset detectedLatest commit: f9d7a91 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds MCP CRUD support for sources and webhooks. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (4): Last reviewed commit: "Merge branch 'main' into brandon/brandon..." | Re-trigger Greptile |
E2E Test Results✅ All tests passed • 243 passed • 1 skipped • 990s
Tests ran across 4 shards in parallel. |
- Reduce comments to explain non-obvious "why" only (1-2 lines each), drop
restated-code and section-header narration.
- Webhook body fallback: only substitute the default template when body is
null/undefined, so an explicit empty body ("") is honored (Greptile #3).
- deleteWebhook guard: match alerts on channel.webhookId alone (drop the
channel.type filter) so a legacy/skewed alert still blocks deletion
(Greptile #2).
Greptile #1 (dangling source references on delete) is intentionally left as-is:
it matches the existing REST DELETE /sources/:id behavior and the tool
description already warns callers to check dependents; full dependency-graph
cleanup is out of scope for this PR.
|
Thanks @greptile-apps — addressed in 86b5688:
Also did a comment-reduction pass across the new files (explain non-obvious "why" only, 1-2 lines). |
|
All three fixes look correct after reviewing 86b5688. Issue 3 (empty body → default): The Issue 2 (skewed alert references): Issue 1 (dangling source references): The rationale holds — matching existing REST behavior and bounding scope for this PR is the right call. The tool description warning covers the caller contract. The comment reduction pass looks clean too; what remains explains non-obvious "why" rather than restating the code. LGTM — no further concerns from me. |
🔴 Tier 4 — CriticalTouches auth, data models, config, tasks, OTel pipeline, ClickHouse, or CI/CD. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
The query-focused eval scenarios don't exercise source/webhook mutation, so deny the four new write tools (save/delete source, save/delete webhook) alongside the existing dashboard/saved-search/alert write tools to keep the agent's tool count down for faster schema loading.
Deep Review
✅ No critical issues found. The new code is defensively written and consistently team-scoped; the 🟡 P2 -- recommended
🔵 P3 nitpicks (1)
Reviewers (1, degraded): the persona sub-agents could not be spawned (see banner). A single manual pass covered the correctness, security, API-contract, maintainability, and testing lenses over the PR-head sources: Testing gaps:
|
Why
The ClickStack MCP could read sources/webhooks but not create, update, or delete them, blocking any agent trying to automate setup (bring-your-own-shipper → ingest → build search/dashboards/alerts). This closes that gap. (Linear HDX-4740 / HDX-4742.)
What
clickstack_save_source/clickstack_delete_source,clickstack_save_webhook/clickstack_delete_webhook.save_*omitsidto create, providesidto update (matchessave_alert/save_dashboard).createWebhook/updateWebhook/deleteWebhookcontrollers, de-duplicating logic across the internal API, External API v2, and MCP. Preserves the v2 HTTP contract.clickstack_describe_sourcenow returns a round-trippableconfigblock — the exact flat shapesave_sourceaccepts — so an agent can clone a source faithfully: read config, dropid, pass back tosave_source.Bug fixes
Handlebars.compile(undefined)); now falls back to the default body template.updateSourcedropped theteamfield onfindOneAndReplace, orphaning the source from team-scoped queries; fixed + regression test.Testing
Unit (578 pass), tsc, lint all pass. Integration suites for
sources,webhooks, andcheckAlerts(incl. body-less-webhook regression) pass. MCP tools dogfooded end-to-end incl. a full source clone.