Repository navigation
feat(uptime): Create uptime monitors through the detectors endpoint - #1837
Draft
sentry-junior[bot] wants to merge 1 commit into
Draft
sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
The legacy POST /projects/{org}/{project}/uptime/ endpoint does not record
who created the monitor, so MCP-created monitors show up with no creator.
Create them through the project detectors endpoint the Sentry UI uses, which
records the acting user, then return the monitor in the existing uptime shape.
Co-Authored-By: Matt Duncan <14761+mrduncan@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
Author
|
Related: #1846 adds |
Contributor
Author
This was referenced Nov 3, 2026
dcramer
pushed a commit
that referenced
this pull request
Nov 3, 2026
Fixes #1845. This supersedes #1846: it keeps @Chipagosfinest's commits for the `create_monitor` tool and adds a fix on top, applied from that PR's review. `create_monitor` lets agents create cron monitors instead of sending users to the UI. It's catalog-only, gated by the `project-management` skill, and takes the same schedule, timezone, margin, runtime and threshold inputs as in #1846. What changed from #1846: - **It creates through the detectors endpoint.** It now calls `POST /organizations/{org}/projects/{project}/detectors/` with `type: monitor_check_in_failure`, the same payload the cron UI sends (`cronFormDataToEndpointPayload`). The legacy `POST /organizations/{org}/monitors/` path creates the detector through `ensure_cron_detector`, which never sets `created_by_id`, so monitors created through MCP would have had no creator. This is the same gap #1837 fixes for uptime monitors. The detector path also matches `create_metric_monitor`, so the tool now accepts optional `workflowIds` to connect existing Alerts. - **The output shape stays the same.** Sentry serializes the created Monitor as `dataSources[0].queryObj`, so the tool returns the same summary with no second request. The only addition is the connected `workflowIds`. The owner is sent on both the detector and the monitor, which matches what the legacy path copied over. - **Agents are told about seat-disabled monitors.** When the org has no monitor seat available, Sentry still returns success but disables the monitor. The description now tells the agent to report an unrequested `disabled` status to the user. I checked the request and response shapes against getsentry/sentry@e39c07b (`MonitorIncidentDetectorValidator`, `MonitorDataSourceValidator`, and the base detector `create`). Nothing has been run against a live org yet. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC08J1NSPU6S%3A1793724602.686199 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AC08J1NSPU6S%3A1793724602.686199) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC08J1NSPU6S%3A1793724602.686199/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
create_uptime_monitorposted to the legacyPOST /projects/{org}/{project}/uptime/endpoint. That endpoint goes throughcreate_uptime_detector, which never setsDetector.created_by_id. As a result, every uptime monitor an agent creates through the MCP has no creator. The Sentry UI usesPOST /organizations/{org}/projects/{project}/detectors/(UptimeDomainCheckFailureValidator). That path setscreated_by_id=acting_user_id(request.user).This switches the create call to the detectors endpoint and sends the same payload shape the UI sends (
type: uptime_domain_failure, with check settings indataSources[0]andenvironmentand the thresholds inconfig). Monitors created this way record the OAuth user as their creator, so warehouse data can tell MCP-created monitors apart from monitors with no creator. Right now those make up most of the recent rise in manual uptime monitor creation.The tool's input and output don't change. After the create, the client fetches the monitor from the existing uptime details endpoint (detector id == uptime monitor id), so the response keeps the same
UptimeMonitorshape that the find, get and update tools use.Two behavior differences on the server side, worth a look from the uptime/ACI owners:
UptimeDomainCheckFailureValidator.createalways callsenable_uptime_detector(..., ensure_assignment=True), and the base validator doesn't passenabledthrough on create. A requestedstatus: "disabled"is therefore applied with a follow-up legacyPUT … {status: "disabled"}.create_uptime_detectorpath turns off org uptime autodetection and deletes onboarding monitors when a manual monitor is created. I didn't find that logic in the detector validator path. That would match what the UI does today, but someone who owns this code should confirm it's intended.Not verified against a live org yet. The tests use MSW mocks shaped from the Sentry source.
via @mrduncan.
--
View Session [Sentry]