Repository navigation
Description
Summary
Automated MCP callers need deterministic, closed time windows, but the public input schemas for search_events and search_issues currently expose only the relative period parameter.
Please expose optional absolute start and end parameters for both tools.
Current behavior
search_events already has most of the absolute-time plumbing internally:
- its embedded-agent output accepts either
{ statsPeriod }or{ start, end } - the API client can forward
startandend - the result formatter can report the exact executed absolute range
However, the public tool schema exposes only period. In the structured-query path, an explicitly supplied period is also preferred over the agent's parsed absolute time range. This means a caller cannot make absolute bounds authoritative at the tool boundary.
A generic example is a scheduled checkpoint intended to cover exactly:
[2026-01-01T00:00:00Z, 2026-01-02T00:00:00Z)
The closest public invocation is currently something like:
{
"organizationSlug": "example-org",
"dataset": "errors",
"query": "environment:production timestamp:>=2026-01-01T00:00:00Z timestamp:<2026-01-02T00:00:00Z",
"fields": ["count()"],
"sort": "-count()",
"period": "24h"
}The embedded agent may extract the timestamp filters into its internal timeRange, but the handler can then retain the explicit relative period. The executed request is therefore relative to execution time rather than the requested fixed window.
search_issues similarly exposes only period and forwards it as statsPeriod. The underlying Sentry issues endpoint supports start and end, so the same fixed-window contract should be available through MCP:
https://docs.sentry.io/api/events/list-an-organizations-issues/
This is related to, but not fixed by, #726 / #1130: those changes exposed a relative period and corrected its default, while fixed absolute ranges remain unavailable.
Proposed behavior
For both tools:
- Add optional ISO-8601
startandendinputs. - Require
startandendas a pair. - Reject
periodtogether withstart/end. - Validate that
start < end. - Treat explicitly supplied absolute bounds as authoritative through agent translation and validation/repair.
- Keep the existing relative-period defaults only when neither absolute bound is supplied.
For search_events, the handler can pass the public values through the existing { start, end } time-parameter path.
For search_issues, extend listIssues to forward start and end instead of statsPeriod when absolute bounds are supplied.
Result provenance
Please also report the executed query, sort, and effective time range in search_issues output, including when the result set is empty. search_events already provides useful executed-search metadata. Without equivalent metadata, a zero-result response cannot prove that the requested fixed window was actually used.
Compatibility and security
- Existing
periodcalls and defaults remain compatible. - No additional OAuth/API scope should be required; these remain read-only
event:readoperations. - Relative periods remain useful for interactive exploration, while absolute bounds enable deterministic scheduled checks and reproducible incident analysis.
Suggested tests
- Existing
periodbehavior remains unchanged. - Paired
start/endare forwarded withoutstatsPeriod. - Partial, conflicting, or reversed ranges are rejected.
- Agent translation/repair cannot replace explicit absolute bounds.
search_issuesreports the effective range for both non-empty and empty results.
Activity
linear-code commentedon Jul 30, 2026
MCP-1010
genesiscz commentedon Aug 3, 2026
Adding a concrete data point that supports this request from a different direction: the embedded agent's relative time translation is not just imprecise, it frequently emits syntax the issues endpoint rejects outright with a 400. So today there is no reliable way to express a time window at all, relative or absolute.
This is not a self-hosted quirk. The grammar in
getsentry/sentrygives relative-date filters no operator slot at all, so an operator-prefixed relative duration cannot parse on any deployment (details at the end).Repro
@sentry/mcp-server0.36.0 and 0.37.0, self-hosted Sentry (--host=<internal-host>), embedded agent via--agent-provider=openaiagainst an OpenAI-compatible endpoint.Call (0.37.0 tool surface):
{ "name": "search_issues", "arguments": { "organizationSlug": "<org>", "query": "regressions from the last 3 days", "limit": 2 } }Result:
Other phrasings fail the same way. Cases where I captured the full error text:
queryargumenterrors seen in the last 24 hourslast_seen: Invalid date: >-24hcrashes in the last 24 hours affecting the most userslast_seen: Invalid date: >-24hregressions from the last 3 dayslast_seen: Invalid date: >-3dFeeding the same system prompt to the model directly, outside the server, reproduces the pattern on
firstSeentoo, for example{"query":"firstSeen:>-7d","sort":"new"}for "new issues from the past week" and{"query":"firstSeen:>-24h"}for "issues first seen since yesterday".The agent is prefixing a comparison operator onto a relative duration. Dropping the
>makes the identical query succeed, so the filter itself is fine and only the operator is the problem:{ "organizationSlug": "<org>", "query": "is:unresolved lastSeen:-24h", "limit": 2 }returns results normally.
It is stochastic, not model-specific
Ran the same six natural-language time queries end to end through the real server, several rounds per model:
No model was reliably clean, and the same query can pass and fail on consecutive runs, which is what you would expect from a prompt ambiguity rather than a defect in one model.
Likely source
In
packages/mcp-core/src/tools/support/search-issues/config.tstheSYNTAX:block puts these two rules on adjacent lines:Nothing states that the comparison operators apply to numeric fields such as
timesSeen/userCountand never to the date fields, so the model composes them. The eval suite has one case asserting/lastSeen:-24h/, but no case exercises phrasings like "older than N days" that pull the model toward a comparison operator, so this is not currently caught.Why the operator can never work, on any deployment
From
src/sentry/api/event_search.pyonmaster, the PEG productions for date-ish filters:rel_date_filterhas nooperatortoken, whileduration_filter(and the numeric and aggregate variants) carry an optionaloperator?. The+/-sign is part ofrel_date_formatitself, which is whylastSeen:-24hparses andlastSeen:>-24hcannot. It then falls through to the generic filter path and hits_handle_basic_filter, which raises the exact string above at L945.That production shape explains the failure mode precisely: an LLM that has seen
timesSeen:>100ortransaction.duration:>5sgeneralises>to any value type, and relative dates are one of the few places where that generalisation is invalid.Since parsing lives in core
sentryrather than in anything SaaS-gated, this reproduces on sentry.io as well, so it is not specific to my deployment.This exact pattern was guarded against once, in the sibling prompt
The
search_eventsprompt used to carry a line naming this bug explicitly. Visible as unchanged context in the diff of #419:Searching the repo today for
WITHOUT operatorsreturns nothing, so that guard is gone. It was dropped whensearch_eventsmoved to the structuredtimeRangeparameter, which removed the ambiguity by design rather than by warning, andsearch_eventsis correspondingly immune today since time never lives inside itsquerystring.search_issuesgot neither treatment. It still encodes time inline inquery, and its prompt has no equivalent guard, which is what leaves this failure open.Why this is relevant here
The
TOOL RESPONSE HANDLINGsection tells the agent it may retry after an error, but that is opportunistic rather than a guaranteed repair loop, so in practice the 400 surfaces to the caller and the call is simply lost.The absolute
start/endinputs proposed in this issue would let a caller skip agent time translation entirely, which fixes this failure mode as a side effect for automated callers. That said, this is arguably its own bug, since interactive callers passing natural language would still hit it. Happy to open a separate issue for the prompt or eval side if that is preferred.fix(alerts): create and edit issue alert rules via org-scoped /workfl…
fix(alerts): create and edit issue alert rules via org-scoped /workfl…
fix(alerts): create and edit issue alert rules via org-scoped /workfl…
sentry-junior commentedon Nov 10, 2026
Related path this issue and #1228 do not cover: the caller passes
periodand absolutetimestamp:>=/timestamp:<bounds in a structuredquery. The embedded agent can move those bounds into an absolutetimeRangeand drop them from the query, and then the explicitperiodwins over that range (search.ts:936-938). The search silently runs over the whole period. #2139 fixes that by putting droppedtimestamp:bounds back on the repaired query. Absolutestart/endinputs are still useful on top of it.