@sentry/mcp-server 0.39.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/auth/constants.cjs +1 -1
  2. package/dist/auth/constants.js +1 -1
  3. package/dist/auth/device-code-flow.cjs +3 -3
  4. package/dist/auth/device-code-flow.js +3 -3
  5. package/dist/auth/resolve-token.cjs +4 -4
  6. package/dist/auth/resolve-token.js +4 -4
  7. package/dist/{auth-CMwoYDhh.cjs → auth-CmmVlYDi.cjs} +4 -4
  8. package/dist/{auth-CMwoYDhh.cjs.map → auth-CmmVlYDi.cjs.map} +1 -1
  9. package/dist/{auth-BmLsTuwM.js → auth-CpyUfxVa.js} +4 -4
  10. package/dist/{auth-BmLsTuwM.js.map → auth-CpyUfxVa.js.map} +1 -1
  11. package/dist/blob-utils-CJyQkdm-.js +3 -0
  12. package/dist/blob-utils-DGsI5_gF.cjs +3 -0
  13. package/dist/{blob-utils-CdbE_jsd-zazUDulT.cjs → blob-utils-DgVug_Di-B5c8BuPf.cjs} +17 -2
  14. package/dist/{blob-utils-CdbE_jsd-zazUDulT.cjs.map → blob-utils-DgVug_Di-B5c8BuPf.cjs.map} +1 -1
  15. package/dist/{blob-utils-CdbE_jsd-9sHzy4nK.js → blob-utils-DgVug_Di-DaP7N_l-.js} +12 -3
  16. package/dist/{blob-utils-CdbE_jsd-9sHzy4nK.js.map → blob-utils-DgVug_Di-DaP7N_l-.js.map} +1 -1
  17. package/dist/cli/commands/auth.cjs +5 -5
  18. package/dist/cli/commands/auth.js +5 -5
  19. package/dist/cli/resolve.cjs +2 -2
  20. package/dist/cli/resolve.js +2 -2
  21. package/dist/{config-BqCCImAX-CqsS5Qiu.cjs → config-B-l88mOS-DNM_M--P.cjs} +8 -6
  22. package/dist/config-B-l88mOS-DNM_M--P.cjs.map +1 -0
  23. package/dist/{config-BqCCImAX-C9xxoOuk.js → config-B-l88mOS-v5IBYyQU.js} +8 -6
  24. package/dist/config-B-l88mOS-v5IBYyQU.js.map +1 -0
  25. package/dist/config-DRWtJff1.cjs +7 -0
  26. package/dist/{config-BUwpc74z.js → config-_di9BWJ0.js} +1 -1
  27. package/dist/{constants-BZbaI-zR.js → constants-CS0iQGX_.js} +3 -3
  28. package/dist/{constants-BZbaI-zR.js.map → constants-CS0iQGX_.js.map} +1 -1
  29. package/dist/{constants-BF1H5JLS.cjs → constants-DyDxXiYc.cjs} +3 -3
  30. package/dist/{constants-BF1H5JLS.cjs.map → constants-DyDxXiYc.cjs.map} +1 -1
  31. package/dist/{device-code-flow-BRSc_1Sh.js → device-code-flow-CARIuIzP.js} +3 -3
  32. package/dist/{device-code-flow-BRSc_1Sh.js.map → device-code-flow-CARIuIzP.js.map} +1 -1
  33. package/dist/{device-code-flow-Btx7zPjy.cjs → device-code-flow-D1UFW6dK.cjs} +3 -3
  34. package/dist/{device-code-flow-Btx7zPjy.cjs.map → device-code-flow-D1UFW6dK.cjs.map} +1 -1
  35. package/dist/index.cjs +1785 -748
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.js +1779 -742
  38. package/dist/index.js.map +1 -1
  39. package/dist/{resolve-CS-Bms6W.js → resolve-C9Uf3wka.js} +2 -2
  40. package/dist/{resolve-CS-Bms6W.js.map → resolve-C9Uf3wka.js.map} +1 -1
  41. package/dist/{resolve-BsYckCew.cjs → resolve-D3vntNua.cjs} +2 -2
  42. package/dist/{resolve-BsYckCew.cjs.map → resolve-D3vntNua.cjs.map} +1 -1
  43. package/dist/{resolve-token-D8oZbjtT.js → resolve-token-CYqj4HQ5.js} +3 -3
  44. package/dist/{resolve-token-D8oZbjtT.js.map → resolve-token-CYqj4HQ5.js.map} +1 -1
  45. package/dist/{resolve-token-TOq9-TtB.cjs → resolve-token-DKvK-YrS.cjs} +3 -3
  46. package/dist/{resolve-token-TOq9-TtB.cjs.map → resolve-token-DKvK-YrS.cjs.map} +1 -1
  47. package/dist/{stdio-DFPpP3Gf.cjs → stdio-BhYLPDOA.cjs} +2 -2
  48. package/dist/{stdio-DFPpP3Gf.cjs.map → stdio-BhYLPDOA.cjs.map} +1 -1
  49. package/dist/{stdio-DrtNVy01.js → stdio-iZJ0t3f6.js} +2 -2
  50. package/dist/{stdio-DrtNVy01.js.map → stdio-iZJ0t3f6.js.map} +1 -1
  51. package/dist/transports/stdio.cjs +2 -2
  52. package/dist/transports/stdio.js +2 -2
  53. package/dist/{version-BHLBRM5t.cjs → version-CDZpvmqM.cjs} +3 -3
  54. package/dist/version-CDZpvmqM.cjs.map +1 -0
  55. package/dist/version-a8th87fY.js +7 -0
  56. package/dist/version-a8th87fY.js.map +1 -0
  57. package/package.json +7 -7
  58. package/dist/blob-utils-ByQZ_jqM.cjs +0 -3
  59. package/dist/blob-utils-KYOyFu79.js +0 -3
  60. package/dist/config-BqCCImAX-C9xxoOuk.js.map +0 -1
  61. package/dist/config-BqCCImAX-CqsS5Qiu.cjs.map +0 -1
  62. package/dist/config-Md3ohhLy.cjs +0 -7
  63. package/dist/version-BHLBRM5t.cjs.map +0 -1
  64. package/dist/version-BWR2MRdi.js +0 -7
  65. package/dist/version-BWR2MRdi.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,27 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
  import { __commonJS, __export, __toDynamicImportESM, __toESM } from "./chunk-CunrlGP7.js";
3
- import { ALL_SKILLS, SKILLS, finalize, isEnabledBySkills } from "./resolve-CS-Bms6W.js";
4
- import { PUBLIC_EVENTS_DATASETS, extractConversationIdFromSearchQuery, getAIConversationUrl, getAIConversationsUrl, getContinuousProfileUrl, getDashboardUrl, getIssueUrl, getIssuesSearchUrl, getMonitorUrl, getPreprodSnapshotUrl, getProfileUrl, getProfilingExplorerUrl, getReleaseUrl, getReplayUrl, getReplaysSearchUrl, getTraceMetricsExploreUrl, getTraceUrl, getUptimeMonitorUrl, isMetricsDataset, isProfilesDataset, isSentryHost, normalizeEventsDataset } from "./constants-BZbaI-zR.js";
5
- import { LIB_VERSION, USER_AGENT } from "./version-BWR2MRdi.js";
3
+ import { ALL_SKILLS, SKILLS, finalize, isEnabledBySkills } from "./resolve-C9Uf3wka.js";
4
+ import { PUBLIC_EVENTS_DATASETS, extractConversationIdFromSearchQuery, getAIConversationUrl, getAIConversationsUrl, getContinuousProfileUrl, getDashboardUrl, getIssueUrl, getIssuesSearchUrl, getMonitorUrl, getPreprodSnapshotUrl, getProfileUrl, getProfilingExplorerUrl, getReleaseUrl, getReplayUrl, getReplaysSearchUrl, getTraceMetricsExploreUrl, getTraceUrl, getUptimeMonitorUrl, isMetricsDataset, isProfilesDataset, isSentryHost, normalizeEventsDataset } from "./constants-CS0iQGX_.js";
5
+ import { LIB_VERSION, USER_AGENT } from "./version-a8th87fY.js";
6
6
  import { require_token_error } from "./token-error-CBmJNKLY.js";
7
- import { blobToBase64, createImagePreview } from "./blob-utils-CdbE_jsd-9sHzy4nK.js";
8
- import { RECOMMENDED_FIELDS, TRACE_METRICS_SAMPLE_IDENTITY_FIELDS, systemPrompt } from "./config-BqCCImAX-C9xxoOuk.js";
9
- import { startStdio } from "./stdio-DrtNVy01.js";
7
+ import { blobToBase64, bytesToBase64, createImagePreview } from "./blob-utils-DgVug_Di-DaP7N_l-.js";
8
+ import { RECOMMENDED_FIELDS, TRACE_METRICS_SAMPLE_IDENTITY_FIELDS, systemPrompt } from "./config-B-l88mOS-v5IBYyQU.js";
9
+ import { startStdio } from "./stdio-iZJ0t3f6.js";
10
10
  import { buildUsage } from "./usage-Con424Df.js";
11
11
  import { printCliLine } from "./output-A_-7o7gV.js";
12
12
  import { merge, parseArgv, parseEnv } from "./parse-Dd3OOgIq.js";
13
13
  import "./types-BCSxlxZI.js";
14
- import "./device-code-flow-BRSc_1Sh.js";
14
+ import "./device-code-flow-CARIuIzP.js";
15
15
  import "./token-cache-DbZp4rvg.js";
16
- import { resolveAccessToken } from "./resolve-token-D8oZbjtT.js";
17
- import { authCommand } from "./auth-BmLsTuwM.js";
16
+ import { resolveAccessToken } from "./resolve-token-CYqj4HQ5.js";
17
+ import { authCommand } from "./auth-CpyUfxVa.js";
18
18
  import { z } from "zod";
19
- import { captureException, captureMessage, getActiveSpan, logger, setTag, setUser, startSpan, withScope, wrapMcpServerWithSentry } from "@sentry/core";
19
+ import { captureException, captureMessage, getActiveSpan, logger, setAttribute, setTag, setUser, startSpan, withScope } from "@sentry/core";
20
20
  import util from "node:util";
21
21
  import * as z4 from "zod/v4";
22
22
  import { z as z$1 } from "zod/v4";
23
23
  import { ZodFirstPartyTypeKind } from "zod/v3";
24
24
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
25
+ import { wrapMcpServerWithSentry } from "@sentry/core/server";
25
26
  import * as Sentry from "@sentry/node";
26
27
 
27
28
  //#region ../mcp-core/dist/constants-CEZaLsGe.js
@@ -399,7 +400,7 @@ function validateSlugOrId(val, ctx) {
399
400
  }
400
401
 
401
402
  //#endregion
402
- //#region ../mcp-core/dist/schema-DKEjeVqP.js
403
+ //#region ../mcp-core/dist/schema-BPiG3cQY.js
403
404
  const ParamOrganizationSlug = z.string().trim().superRefine(validateSlug).describe("The organization's slug. You can find a existing list of organizations you have access to using the `find_organizations()` tool.");
404
405
  const ParamTeamSlug = z.string().trim().superRefine(validateSlug).describe("The team's slug. You can find a list of existing teams in an organization with the Sentry tool `find_teams`.");
405
406
  const ParamProjectSlug = z.string().trim().superRefine(validateSlug).describe("The project's slug. You can find a list of existing projects in an organization using the `find_projects()` tool.");
@@ -446,7 +447,7 @@ const ParamIssueIgnoreMode = z.enum([
446
447
  "untilOccurrenceCount",
447
448
  "untilUserCount"
448
449
  ]).describe("How ignored issues should behave. Use 'untilEscalating' to match the Sentry UI default, 'forever' for a permanent ignore, 'forDuration' with ignoreDurationMinutes, 'untilOccurrenceCount' with ignoreCount and optional ignoreWindowMinutes, or 'untilUserCount' with ignoreUserCount and optional ignoreUserWindowMinutes.");
449
- const ParamAssignedTo = z.string().trim().describe("The assignee in format 'user:ID' or 'team:ID_OR_SLUG' where ID is numeric. Example: 'user:123456', 'team:789', or 'team:my-team-slug'. Use `execute_sentry_tool(name='whoami', arguments={})` to find your user ID.");
450
+ const ParamAssignedTo = z.string().trim().min(1).nullable().describe("The assignee in format 'user:ID' or 'team:ID_OR_SLUG' where ID is numeric. Pass null to unassign the issue. Example: 'user:123456', 'team:789', or 'team:my-team-slug'. Use `execute_sentry_tool(name='whoami', arguments={})` to find your user ID.");
450
451
  const ParamIgnoreDurationMinutes = z.number().int().positive().describe("How many minutes to ignore the issue when ignoreMode is 'forDuration'.");
451
452
  const ParamIgnoreCount = z.number().int().positive().describe("How many times the issue must occur before it stops being ignored when ignoreMode is 'untilOccurrenceCount'.");
452
453
  const ParamIgnoreWindowMinutes = z.number().int().positive().max(7 * 24 * 60).describe("Optional time window in minutes for ignoreCount. If omitted, Sentry counts all future occurrences.");
@@ -462,6 +463,56 @@ const ParamEventId = z.string().trim().regex(/^[0-9a-fA-F]{32}$/, "Event ID must
462
463
  const ParamEventIdOrLatest = z.union([z.literal("latest"), ParamEventId]).default("latest").describe("The event ID for the issue, or `latest`. Defaults to `latest`.");
463
464
  const ParamAttachmentId = z.string().trim().superRefine(validateResourceId).describe("The ID of the attachment to download.");
464
465
 
466
+ //#endregion
467
+ //#region ../mcp-core/dist/fetch-utils-CowPZ6ZQ.js
468
+ /**
469
+ * Fetch with timeout using AbortController
470
+ * @param url - The URL to fetch
471
+ * @param options - Standard fetch options
472
+ * @param timeoutMs - Timeout in milliseconds (default: 30000)
473
+ * @returns Promise<Response>
474
+ * @throws Error if request times out
475
+ */
476
+ async function fetchWithTimeout(url, options = {}, timeoutMs = 3e4) {
477
+ const controller = new AbortController();
478
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
479
+ try {
480
+ const response = await fetch(url, {
481
+ ...options,
482
+ signal: controller.signal
483
+ });
484
+ return response;
485
+ } catch (error) {
486
+ if (error instanceof Error && error.name === "AbortError") throw new Error(`Request timeout after ${timeoutMs}ms`);
487
+ throw error;
488
+ } finally {
489
+ clearTimeout(timeoutId);
490
+ }
491
+ }
492
+ /**
493
+ * Retry a function with exponential backoff
494
+ * @param fn - The async function to retry
495
+ * @param options - Retry options
496
+ * @param options.maxRetries - Maximum number of retries (default: 3)
497
+ * @param options.initialDelay - Initial delay in milliseconds (default: 1000)
498
+ * @param options.shouldRetry - Predicate to determine if error should be retried (default: always retry)
499
+ * @returns Promise with the function result
500
+ * @throws The last error if all retries are exhausted
501
+ */
502
+ async function retryWithBackoff(fn, { maxRetries = 3, initialDelay = 1e3, shouldRetry = (error) => true } = {}) {
503
+ let lastError;
504
+ let delay$1 = initialDelay;
505
+ for (let attempt = 0; attempt <= maxRetries; attempt++) try {
506
+ return await fn();
507
+ } catch (error) {
508
+ lastError = error;
509
+ if (attempt === maxRetries || !shouldRetry(error)) throw error;
510
+ await new Promise((resolve$1) => setTimeout(resolve$1, delay$1));
511
+ delay$1 = Math.min(delay$1 * 2, 3e4);
512
+ }
513
+ throw lastError;
514
+ }
515
+
465
516
  //#endregion
466
517
  //#region ../../node_modules/.pnpm/@logtape+logtape@1.1.1/node_modules/@logtape/logtape/dist/filter.js
467
518
  /**
@@ -1627,7 +1678,7 @@ var ConfigError = class extends Error {
1627
1678
  };
1628
1679
 
1629
1680
  //#endregion
1630
- //#region ../mcp-core/dist/logging-B7X3yL0T.js
1681
+ //#region ../mcp-core/dist/logging-dXuBsQDs.js
1631
1682
  const ROOT_LOG_CATEGORY = ["sentry", "mcp"];
1632
1683
  const STDERR_CONSOLE_LEVEL_MAP = {
1633
1684
  trace: "error",
@@ -1850,7 +1901,7 @@ function logIssue(error, options = {}) {
1850
1901
  }
1851
1902
 
1852
1903
  //#endregion
1853
- //#region ../mcp-core/dist/api-path-BQDQ2sHi.js
1904
+ //#region ../mcp-core/dist/api-path-CjJMa7Rg.js
1854
1905
  /**
1855
1906
  * Builds an API request path, confining each interpolated value to one path segment.
1856
1907
  *
@@ -1877,7 +1928,7 @@ function apiPath(strings, ...values) {
1877
1928
  }
1878
1929
 
1879
1930
  //#endregion
1880
- //#region ../mcp-core/dist/errors-DG2FreDU.js
1931
+ //#region ../mcp-core/dist/errors-Dj_qmFqH.js
1881
1932
  /**
1882
1933
  * API Error Class Hierarchy
1883
1934
  *
@@ -2108,7 +2159,7 @@ function isApiAuthenticationErrorDeep(error) {
2108
2159
  }
2109
2160
 
2110
2161
  //#endregion
2111
- //#region ../mcp-core/dist/schema-BYZYkgA1.js
2162
+ //#region ../mcp-core/dist/schema-y99KGEDP.js
2112
2163
  /**
2113
2164
  * Schema for Sentry API error responses.
2114
2165
  *
@@ -2282,6 +2333,61 @@ const IssueAlertRuleSchema = z.object({
2282
2333
  lastTriggered: z.string().nullable().optional()
2283
2334
  }).passthrough();
2284
2335
  const IssueAlertRuleListSchema = z.array(IssueAlertRuleSchema);
2336
+ const AlertRuleProjectScopeSchema = z.object({
2337
+ projectIds: z.array(z.string()),
2338
+ includesAllProjects: z.boolean()
2339
+ });
2340
+ const AlertActionOptionSchema = z.object({
2341
+ type: z.string(),
2342
+ handlerGroup: z.string(),
2343
+ configSchema: z.record(z.string(), z.unknown()),
2344
+ dataSchema: z.record(z.string(), z.unknown()),
2345
+ integrations: z.array(z.object({
2346
+ id: z.string(),
2347
+ name: z.string(),
2348
+ services: z.array(z.object({
2349
+ id: z.string(),
2350
+ name: z.string()
2351
+ })).optional()
2352
+ })).optional(),
2353
+ services: z.array(z.object({
2354
+ slug: z.string(),
2355
+ name: z.string()
2356
+ })).optional(),
2357
+ sentryApp: z.object({
2358
+ id: z.string(),
2359
+ name: z.string(),
2360
+ installationId: z.string(),
2361
+ installationUuid: z.string(),
2362
+ status: z.number(),
2363
+ settings: z.record(z.string(), z.unknown()).optional(),
2364
+ title: z.string().optional()
2365
+ }).optional()
2366
+ });
2367
+ const AlertConditionOptionSchema = z.object({
2368
+ type: z.string(),
2369
+ handlerGroup: z.string(),
2370
+ handlerSubgroup: z.string().optional(),
2371
+ comparisonJsonSchema: z.record(z.string(), z.unknown())
2372
+ });
2373
+ const DetectorSchema = z.object({
2374
+ id: z.string(),
2375
+ projectId: z.string().nullable(),
2376
+ name: z.string(),
2377
+ type: z.string(),
2378
+ enabled: z.boolean(),
2379
+ config: z.record(z.string(), z.unknown()),
2380
+ conditionGroup: AlertRuleComponentSchema.nullable(),
2381
+ dataSources: z.array(AlertRuleComponentSchema).nullable(),
2382
+ workflowIds: z.array(z.string()).nullable(),
2383
+ description: z.string().nullable().optional(),
2384
+ owner: z.unknown().optional(),
2385
+ createdBy: z.string().nullable().optional(),
2386
+ dateCreated: z.string(),
2387
+ dateUpdated: z.string(),
2388
+ alertRuleId: z.number().nullable().optional(),
2389
+ ruleId: z.number().nullable().optional()
2390
+ }).passthrough();
2285
2391
  const MetricAlertRuleSchema = z.object({
2286
2392
  id: z.union([z.string(), z.number()]),
2287
2393
  name: z.string(),
@@ -2809,7 +2915,11 @@ const BaseEventSchema = z.object({
2809
2915
  geo: z.record(z.string(), z.union([z.string(), z.null()])).nullable().optional()
2810
2916
  }).passthrough().nullable().optional(),
2811
2917
  _meta: z.unknown().optional(),
2812
- dateReceived: z.string().datetime().nullish()
2918
+ dateReceived: z.string().datetime().nullish(),
2919
+ formatted: z.object({
2920
+ format: z.string(),
2921
+ content: z.string()
2922
+ }).optional()
2813
2923
  });
2814
2924
  const ErrorEventSchema = BaseEventSchema.omit({ type: true }).extend({
2815
2925
  type: z.literal("error"),
@@ -2951,15 +3061,21 @@ const AutofixBlockSchema = z.object({
2951
3061
  * - `src/sentry/seer/endpoints/group_ai_autofix.py`
2952
3062
  * - `src/sentry/seer/agent/client_models.py` (`SeerRunState`)
2953
3063
  */
2954
- const AutofixRunStateSchema = z.object({ autofix: z.object({
2955
- run_id: z.number(),
2956
- updated_at: z.string().nullable().optional(),
2957
- status: AutofixStatusSchema,
2958
- blocks: z.array(AutofixBlockSchema).default([]),
2959
- pending_user_input: z.unknown().nullable().optional(),
2960
- repo_pr_states: z.record(z.string(), z.object({ pr_url: z.string().nullable().optional() }).passthrough()).optional(),
2961
- coding_agents: z.record(z.string(), z.unknown()).optional()
2962
- }).passthrough().nullable() });
3064
+ const AutofixRunStateSchema = z.object({
3065
+ autofix: z.object({
3066
+ run_id: z.number(),
3067
+ updated_at: z.string().nullable().optional(),
3068
+ status: AutofixStatusSchema,
3069
+ blocks: z.array(AutofixBlockSchema).default([]),
3070
+ pending_user_input: z.unknown().nullable().optional(),
3071
+ repo_pr_states: z.record(z.string(), z.object({ pr_url: z.string().nullable().optional() }).passthrough()).optional(),
3072
+ coding_agents: z.record(z.string(), z.unknown()).optional()
3073
+ }).passthrough().nullable(),
3074
+ formatted: z.object({
3075
+ format: z.string(),
3076
+ content: z.string()
3077
+ }).optional()
3078
+ });
2963
3079
  const EventAttachmentSchema = z.object({
2964
3080
  id: z.string(),
2965
3081
  name: z.string(),
@@ -2970,6 +3086,11 @@ const EventAttachmentSchema = z.object({
2970
3086
  headers: z.record(z.string(), z.string()).optional()
2971
3087
  });
2972
3088
  const EventAttachmentListSchema = z.array(EventAttachmentSchema);
3089
+ const OrganizationEnvironmentSchema = z.object({
3090
+ id: z.string(),
3091
+ name: z.string()
3092
+ });
3093
+ const OrganizationEnvironmentListSchema = z.array(OrganizationEnvironmentSchema);
2973
3094
  /**
2974
3095
  * Schema for individual tag values within an issue's tag distribution.
2975
3096
  *
@@ -3595,9 +3716,19 @@ const AgenticOnboardingRunSchema = z.object({
3595
3716
  runStatus: AgenticOnboardingRunStatusSchema,
3596
3717
  stages: z.array(AgenticOnboardingStageStateSchema)
3597
3718
  });
3719
+ /**
3720
+ * Response from the events-stats (timeseries) endpoint for a single yAxis:
3721
+ * a series of `[unixTimestampSeconds, [{ count }]]` buckets. `count` holds the
3722
+ * yAxis value for that bucket regardless of the aggregate function.
3723
+ */
3724
+ const EventsStatsResponseSchema = z.object({
3725
+ data: z.array(z.tuple([z.number(), z.array(z.object({ count: z.number().nullish() }).passthrough())])),
3726
+ start: z.number().optional(),
3727
+ end: z.number().optional()
3728
+ }).passthrough();
3598
3729
 
3599
3730
  //#endregion
3600
- //#region ../mcp-core/dist/client-IUNQkit5.js
3731
+ //#region ../mcp-core/dist/client-BXJ5ud71.js
3601
3732
  const SENTRY_MCP_SEARCH_EVENTS_REFERRER = "api.mcp.search-events";
3602
3733
  /**
3603
3734
  * Mapping of common network error codes to user-friendly messages.
@@ -3618,9 +3749,6 @@ function formatWorkflowNameQuery(query) {
3618
3749
  const escapedQuery = query.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
3619
3750
  return `name:"*${escapedQuery}*"`;
3620
3751
  }
3621
- function filterAttachedIssueAlertRules(rules) {
3622
- return rules.filter((rule) => (rule.detectorIds ?? []).length > 0);
3623
- }
3624
3752
  function parseStatsPeriod(statsPeriod) {
3625
3753
  const match = /^(\d+)([smhdw])$/.exec(statsPeriod);
3626
3754
  if (!match) throw new ApiValidationError("statsPeriod must use a supported relative time format, such as `24h`, `7d`, or `2w`.");
@@ -3638,6 +3766,24 @@ function getNextCursor(linkHeader) {
3638
3766
  }
3639
3767
  return null;
3640
3768
  }
3769
+ /**
3770
+ * Automatic retry policy for transient upstream gateway failures (502/503/504).
3771
+ *
3772
+ * Sentry's edge intermittently returns short-lived gateway errors (e.g.
3773
+ * "upstream connect error or disconnect/reset before headers") that clear on a
3774
+ * retry. We retry only idempotent GET requests so an automatic retry can never
3775
+ * replay a mutation, and keep the budget small so a still-failing tool call
3776
+ * resolves quickly under the Cloudflare Workers request lifetime.
3777
+ */
3778
+ const RETRYABLE_REQUEST_MAX_RETRIES = 2;
3779
+ const RETRYABLE_REQUEST_INITIAL_DELAY_MS = 250;
3780
+ /**
3781
+ * Default cap for returning attachment bytes inline over the MCP transport.
3782
+ * A 30 MB attachment takes ~80 MB in memory once base64-encoded and serialized,
3783
+ * which fits the Cloudflare Worker's 128 MB isolate with room for the rest of the
3784
+ * request; above it, getEventAttachment returns a reference instead of the bytes.
3785
+ */
3786
+ const DEFAULT_MAX_INLINE_ATTACHMENT_BYTES = 30 * 1024 * 1024;
3641
3787
  const TraceItemAttributeTypeSchema = z.enum([
3642
3788
  "string",
3643
3789
  "number",
@@ -3871,6 +4017,32 @@ var SentryApiService = class {
3871
4017
  if (resolutionSeconds !== void 0) queryParams.set("resolution", `${resolutionSeconds}s`);
3872
4018
  }
3873
4019
  /**
4020
+ * Makes an authenticated request to the Sentry API, transparently retrying
4021
+ * transient upstream gateway failures (502/503/504).
4022
+ *
4023
+ * Retries are limited to idempotent GET requests so an automatic retry can
4024
+ * never replay a mutation, and are gated on `ApiServerError.isGatewayError()`
4025
+ * so persistent 500s, 4xx client errors, and network/configuration errors
4026
+ * fail fast without waiting. Callers that opt a 5xx into `allowStatuses`
4027
+ * receive the raw response from `requestOnce` and are never retried.
4028
+ *
4029
+ * @param path API endpoint path (without /api/0 prefix)
4030
+ * @param options Fetch options
4031
+ * @param requestOptions Additional request configuration
4032
+ * @returns Promise resolving to Response object
4033
+ * @throws {ApiError} Enhanced API errors with user-friendly messages
4034
+ * @throws {Error} Network or parsing errors
4035
+ */
4036
+ async request(path, options = {}, requestOptions = {}) {
4037
+ const method = (options.method ?? "GET").toUpperCase();
4038
+ const isIdempotent = method === "GET";
4039
+ return retryWithBackoff(() => this.requestOnce(path, options, requestOptions), {
4040
+ maxRetries: isIdempotent ? RETRYABLE_REQUEST_MAX_RETRIES : 0,
4041
+ initialDelay: RETRYABLE_REQUEST_INITIAL_DELAY_MS,
4042
+ shouldRetry: (error) => error instanceof ApiServerError && error.isGatewayError()
4043
+ });
4044
+ }
4045
+ /**
3874
4046
  * Internal method for making authenticated requests to Sentry API.
3875
4047
  *
3876
4048
  * Handles:
@@ -3886,7 +4058,7 @@ var SentryApiService = class {
3886
4058
  * @throws {ApiError} Enhanced API errors with user-friendly messages
3887
4059
  * @throws {Error} Network or parsing errors
3888
4060
  */
3889
- async request(path, options = {}, { host, allowStatuses } = {}) {
4061
+ async requestOnce(path, options = {}, { host, allowStatuses } = {}) {
3890
4062
  const url = host ? `${this.protocol}://${host}/api/0${path}` : `${this.apiPrefix}${path}`;
3891
4063
  const headers = {
3892
4064
  "Content-Type": "application/json",
@@ -4322,7 +4494,7 @@ var SentryApiService = class {
4322
4494
  const queryString = queryParams.toString();
4323
4495
  const path = `/organizations/?${queryString}`;
4324
4496
  let host = void 0;
4325
- if (this.isSaas()) host = "sentry.io";
4497
+ if (this.isSaas() && !this.host.endsWith(".my.sentry.io")) host = "sentry.io";
4326
4498
  const body = await this.requestJSON(path, void 0, { host });
4327
4499
  return OrganizationListSchema.parse(body);
4328
4500
  }
@@ -4511,45 +4683,77 @@ var SentryApiService = class {
4511
4683
  return page.rules;
4512
4684
  }
4513
4685
  async listIssueAlertRulesPage({ organizationSlug, projectSlug: projectSlug$1, query, cursor, limit }, opts) {
4514
- const rules = [];
4686
+ const searchQuery = new URLSearchParams({ sortBy: "-id" });
4687
+ if (projectSlug$1) searchQuery.set("projectSlug", projectSlug$1);
4688
+ if (query) searchQuery.set("query", formatWorkflowNameQuery(query));
4689
+ if (cursor) searchQuery.set("cursor", cursor);
4690
+ if (limit !== void 0) searchQuery.set("per_page", String(limit));
4691
+ const response = await this.request(apiPath`/organizations/${organizationSlug}/workflows/` + `?${searchQuery.toString()}`, void 0, opts);
4692
+ const rules = IssueAlertRuleListSchema.parse(await this.parseJsonResponse(response));
4515
4693
  const targetLimit = limit ?? 100;
4516
- let currentCursor = cursor;
4517
- let nextCursor = null;
4518
- do {
4519
- const searchQuery = new URLSearchParams();
4520
- searchQuery.append("projectSlug", projectSlug$1);
4521
- searchQuery.set("sortBy", "-id");
4522
- if (query) searchQuery.set("query", formatWorkflowNameQuery(query));
4523
- if (currentCursor) searchQuery.set("cursor", currentCursor);
4524
- if (limit !== void 0) searchQuery.set("per_page", String(targetLimit - rules.length));
4525
- const response = await this.request(apiPath`/organizations/${organizationSlug}/workflows/` + `?${searchQuery.toString()}`, void 0, opts);
4526
- const body = await this.parseJsonResponse(response);
4527
- const attachedRules = filterAttachedIssueAlertRules(IssueAlertRuleListSchema.parse(body));
4528
- const remaining = targetLimit - rules.length;
4529
- if (attachedRules.length > remaining) {
4530
- rules.push(...attachedRules.slice(0, remaining));
4531
- nextCursor = null;
4532
- break;
4533
- }
4534
- rules.push(...attachedRules);
4535
- nextCursor = getNextCursor(response.headers.get("link"));
4536
- currentCursor = nextCursor;
4537
- } while (rules.length < targetLimit && nextCursor);
4538
4694
  return {
4539
- rules,
4540
- nextCursor
4695
+ rules: rules.slice(0, targetLimit),
4696
+ nextCursor: rules.length > targetLimit ? null : getNextCursor(response.headers.get("link"))
4541
4697
  };
4542
4698
  }
4543
4699
  async getIssueAlertRule({ organizationSlug, projectSlug: projectSlug$1, ruleId }, opts) {
4544
- const searchQuery = new URLSearchParams();
4545
- searchQuery.append("projectSlug", projectSlug$1);
4546
- searchQuery.append("id", String(ruleId));
4547
- searchQuery.set("per_page", "1");
4548
- const response = await this.request(apiPath`/organizations/${organizationSlug}/workflows/` + `?${searchQuery.toString()}`, void 0, opts);
4549
- const rules = filterAttachedIssueAlertRules(IssueAlertRuleListSchema.parse(await this.parseJsonResponse(response)));
4550
- const rule = rules[0];
4551
- if (!rule) throw new ApiNotFoundError("Workflow not found", void 0, void 0, "workflow", String(ruleId));
4552
- return rule;
4700
+ if (projectSlug$1) {
4701
+ const [project, scope] = await Promise.all([this.getProject({
4702
+ organizationSlug,
4703
+ projectSlugOrId: projectSlug$1
4704
+ }, opts), this.getAlertRuleProjectScope({
4705
+ organizationSlug,
4706
+ ruleId
4707
+ }, opts)]);
4708
+ if (!scope.includesAllProjects && !scope.projectIds.includes(String(project.id))) throw new ApiNotFoundError("Workflow not found in this project", void 0, void 0, "workflow", String(ruleId));
4709
+ }
4710
+ const body = await this.requestJSON(apiPath`/organizations/${organizationSlug}/workflows/${ruleId}/`, void 0, opts);
4711
+ return IssueAlertRuleSchema.parse(body);
4712
+ }
4713
+ /** Private Sentry endpoint: keep the complete association check separate from filtered lists. */
4714
+ async getAlertRuleProjectScope({ organizationSlug, ruleId }, opts) {
4715
+ const body = await this.requestJSON(apiPath`/organizations/${organizationSlug}/workflows/${ruleId}/project-scope/`, void 0, opts);
4716
+ return AlertRuleProjectScopeSchema.parse(body);
4717
+ }
4718
+ async getDetector({ organizationSlug, detectorId }, opts) {
4719
+ const body = await this.requestJSON(apiPath`/organizations/${organizationSlug}/detectors/${detectorId}/`, void 0, opts);
4720
+ return DetectorSchema.parse(body);
4721
+ }
4722
+ async listDetectorsPage({ organizationSlug, projectId, types, query, cursor, limit = 25 }, opts) {
4723
+ const search = new URLSearchParams({
4724
+ project: projectId ?? "-1",
4725
+ per_page: String(limit)
4726
+ });
4727
+ for (const type of types ?? []) search.append("type", type);
4728
+ if (query) search.set("query", query);
4729
+ if (cursor) search.set("cursor", cursor);
4730
+ const response = await this.request(`${apiPath`/organizations/${organizationSlug}/detectors/`}?${search}`, void 0, opts);
4731
+ return {
4732
+ detectors: z.array(DetectorSchema).parse(await this.parseJsonResponse(response)),
4733
+ nextCursor: getNextCursor(response.headers.get("link"))
4734
+ };
4735
+ }
4736
+ async listAvailableAlertActionsPage({ organizationSlug, types, cursor, limit = 25 }, opts) {
4737
+ const search = new URLSearchParams({ per_page: String(limit) });
4738
+ for (const type of types ?? []) search.append("type", type);
4739
+ if (cursor) search.set("cursor", cursor);
4740
+ const response = await this.request(`${apiPath`/organizations/${organizationSlug}/available-actions/`}?${search}`, void 0, opts);
4741
+ return {
4742
+ actions: z.array(AlertActionOptionSchema).parse(await this.parseJsonResponse(response)),
4743
+ nextCursor: getNextCursor(response.headers.get("link"))
4744
+ };
4745
+ }
4746
+ async listAlertConditionsPage({ organizationSlug, group, cursor, limit = 25 }, opts) {
4747
+ const search = new URLSearchParams({
4748
+ group,
4749
+ per_page: String(limit)
4750
+ });
4751
+ if (cursor) search.set("cursor", cursor);
4752
+ const response = await this.request(`${apiPath`/organizations/${organizationSlug}/data-conditions/`}?${search}`, void 0, opts);
4753
+ return {
4754
+ conditions: z.array(AlertConditionOptionSchema).parse(await this.parseJsonResponse(response)),
4755
+ nextCursor: getNextCursor(response.headers.get("link"))
4756
+ };
4553
4757
  }
4554
4758
  async listMetricAlertRules(params, opts) {
4555
4759
  const page = await this.listMetricAlertRulesPage(params, opts);
@@ -5036,6 +5240,20 @@ var SentryApiService = class {
5036
5240
  const body = await this.parseJsonResponse(response);
5037
5241
  return EventsValidationResponseSchema.parse(body);
5038
5242
  }
5243
+ /**
5244
+ * List the organization's visible environments, optionally scoped to a
5245
+ * project. The endpoint (`GET /organizations/{org}/environments/`) already
5246
+ * filters to visible environments and excludes the empty-name "No Environment"
5247
+ * pseudo-env; passing `project` narrows the list (verified against
5248
+ * getsentry/sentry `OrganizationEnvironmentsEndpoint`).
5249
+ */
5250
+ async listEnvironments({ organizationSlug, projectId }, opts) {
5251
+ const queryParams = new URLSearchParams();
5252
+ if (projectId) queryParams.set("project", projectId);
5253
+ const suffix = queryParams.toString();
5254
+ const body = await this.requestJSON(apiPath`/organizations/${organizationSlug}/environments/` + (suffix ? `?${suffix}` : ""), void 0, opts);
5255
+ return OrganizationEnvironmentListSchema.parse(body);
5256
+ }
5039
5257
  async fetchTraceItemAttributes(organizationSlug, itemType, project, statsPeriod, start, end, substringMatch, query, opts) {
5040
5258
  const queryParams = new URLSearchParams();
5041
5259
  queryParams.set("itemType", itemType);
@@ -5158,7 +5376,7 @@ var SentryApiService = class {
5158
5376
  };
5159
5377
  }
5160
5378
  async getEventForIssue({ organizationSlug, issueId, eventId }, opts) {
5161
- const body = await this.requestJSON(apiPath`/organizations/${organizationSlug}/issues/${issueId}/events/${eventId}/`, void 0, opts);
5379
+ const body = await this.requestJSON(apiPath`/organizations/${organizationSlug}/issues/${issueId}/events/${eventId}/` + `?llmFormat=json`, void 0, opts);
5162
5380
  const parseResult = EventSchema.safeParse(body);
5163
5381
  if (parseResult.success) {
5164
5382
  const rawEvent = parseResult.data;
@@ -5231,22 +5449,52 @@ var SentryApiService = class {
5231
5449
  const body = await this.requestJSON(apiPath`/projects/${organizationSlug}/${projectSlug$1}/events/${eventId}/attachments/`, void 0, opts);
5232
5450
  return EventAttachmentListSchema.parse(body);
5233
5451
  }
5234
- async getEventAttachment({ organizationSlug, projectSlug: projectSlug$1, eventId, attachmentId }, opts) {
5452
+ async getEventAttachment({ organizationSlug, projectSlug: projectSlug$1, eventId, attachmentId, maxInlineBytes = DEFAULT_MAX_INLINE_ATTACHMENT_BYTES }, opts) {
5235
5453
  const attachmentsData = await this.requestJSON(apiPath`/projects/${organizationSlug}/${projectSlug$1}/events/${eventId}/attachments/`, void 0, opts);
5236
5454
  const attachments = EventAttachmentListSchema.parse(attachmentsData);
5237
5455
  const attachment = attachments.find((att) => att.id === attachmentId);
5238
5456
  if (!attachment) throw new ApiNotFoundError(`Attachment with ID ${attachmentId} not found for event ${eventId}`);
5239
- const downloadUrl = apiPath`/projects/${organizationSlug}/${projectSlug$1}/events/${eventId}/attachments/${attachmentId}/` + `?download=1`;
5240
- const downloadResponse = await this.request(downloadUrl, { method: "GET" }, opts);
5457
+ const downloadPath = apiPath`/projects/${organizationSlug}/${projectSlug$1}/events/${eventId}/attachments/${attachmentId}/` + `?download=1`;
5458
+ if (attachment.size > maxInlineBytes) {
5459
+ const directDownloadUrl = await this.resolveDirectDownloadUrl(downloadPath, opts);
5460
+ return {
5461
+ attachment,
5462
+ downloadUrl: `${this.apiPrefix}${downloadPath}`,
5463
+ directDownloadUrl,
5464
+ filename: attachment.name,
5465
+ bytes: null,
5466
+ contentType: attachment.mimetype || "application/octet-stream"
5467
+ };
5468
+ }
5469
+ const downloadResponse = await this.request(downloadPath, { method: "GET" }, opts);
5241
5470
  const contentType = downloadResponse.headers.get("content-type")?.split(";")[0].trim() || attachment.mimetype || "application/octet-stream";
5471
+ const bytes = new Uint8Array(await downloadResponse.arrayBuffer());
5242
5472
  return {
5243
5473
  attachment,
5244
5474
  downloadUrl: downloadResponse.url,
5475
+ directDownloadUrl: null,
5245
5476
  filename: attachment.name,
5246
- blob: await downloadResponse.blob(),
5477
+ bytes,
5247
5478
  contentType
5248
5479
  };
5249
5480
  }
5481
+ /**
5482
+ * Probe the download endpoint for a presigned URL without buffering the file.
5483
+ *
5484
+ * Objectstore attachments redirect to a presigned URL (returned here); legacy
5485
+ * ones stream a 200 with no redirect, so there is no direct URL. The body is
5486
+ * discarded either way — we only need the URL.
5487
+ */
5488
+ async resolveDirectDownloadUrl(downloadPath, opts) {
5489
+ try {
5490
+ const response = await this.request(downloadPath, { method: "GET" }, opts);
5491
+ const directUrl = response.redirected ? response.url : null;
5492
+ response.body?.cancel().catch(() => {});
5493
+ return directUrl;
5494
+ } catch {
5495
+ return null;
5496
+ }
5497
+ }
5250
5498
  async getReplayDetails({ organizationSlug, replayId }, opts) {
5251
5499
  const body = await this.requestJSON(apiPath`/organizations/${organizationSlug}/replays/${replayId}/`, void 0, opts);
5252
5500
  return z.object({ data: ReplayDetailsSchema }).parse(body).data;
@@ -5270,7 +5518,7 @@ var SentryApiService = class {
5270
5518
  async updateIssue({ organizationSlug, issueId, status, assignedTo, substatus, ignoreDuration, ignoreCount, ignoreWindow, ignoreUserCount, ignoreUserWindow }, opts) {
5271
5519
  const updateData = {};
5272
5520
  if (status !== void 0) updateData.status = status;
5273
- if (assignedTo !== void 0) updateData.assignedTo = assignedTo;
5521
+ if (assignedTo !== void 0) updateData.assignedTo = assignedTo ?? "";
5274
5522
  if (substatus !== void 0) updateData.substatus = substatus;
5275
5523
  if (ignoreDuration !== void 0) updateData.ignoreDuration = ignoreDuration;
5276
5524
  if (ignoreCount !== void 0) updateData.ignoreCount = ignoreCount;
@@ -5418,6 +5666,27 @@ var SentryApiService = class {
5418
5666
  const apiUrl = apiPath`/organizations/${organizationSlug}/events/` + `?${queryParams.toString()}`;
5419
5667
  return await this.requestJSON(apiUrl, void 0, opts);
5420
5668
  }
5669
+ /**
5670
+ * Fetch a timeseries (events-stats) for a single yAxis, bucketed over time.
5671
+ *
5672
+ * `interval` is optional: omit it to let Sentry pick a sensible bucket size
5673
+ * for the range (mirrors get_interval_from_range in the Sentry source).
5674
+ * Environment and other filters travel in `query`, same as searchEvents.
5675
+ */
5676
+ async getEventsTimeSeries({ organizationSlug, query, yAxis, interval, projectId, dataset = "errors", statsPeriod, start, end }, opts) {
5677
+ const queryParams = new URLSearchParams();
5678
+ queryParams.set("dataset", normalizeEventsDataset(dataset));
5679
+ queryParams.set("query", query);
5680
+ queryParams.set("yAxis", yAxis);
5681
+ if (interval) queryParams.set("interval", interval);
5682
+ this.applyTimeParams(queryParams, statsPeriod, start, end);
5683
+ if (projectId) queryParams.set("project", projectId);
5684
+ queryParams.set("partial", "1");
5685
+ queryParams.set("referrer", SENTRY_MCP_SEARCH_EVENTS_REFERRER);
5686
+ const apiUrl = apiPath`/organizations/${organizationSlug}/events-stats/` + `?${queryParams.toString()}`;
5687
+ const body = await this.requestJSON(apiUrl, void 0, opts);
5688
+ return EventsStatsResponseSchema.parse(body);
5689
+ }
5421
5690
  async startAutofix({ organizationSlug, issueId, eventId, instruction = "" }, opts) {
5422
5691
  const body = await this.requestJSON(apiPath`/organizations/${organizationSlug}/issues/${issueId}/autofix/`, {
5423
5692
  method: "POST",
@@ -5429,7 +5698,7 @@ var SentryApiService = class {
5429
5698
  return AutofixRunSchema.parse(body);
5430
5699
  }
5431
5700
  async getAutofixState({ organizationSlug, issueId }, opts) {
5432
- const body = await this.requestJSON(apiPath`/organizations/${organizationSlug}/issues/${issueId}/autofix/`, void 0, opts);
5701
+ const body = await this.requestJSON(apiPath`/organizations/${organizationSlug}/issues/${issueId}/autofix/` + `?llmFormat=markdown`, void 0, opts);
5433
5702
  return AutofixRunStateSchema.parse(body);
5434
5703
  }
5435
5704
  /**
@@ -5660,7 +5929,7 @@ var SentryApiService = class {
5660
5929
  const blob = await response.blob();
5661
5930
  let contentType = response.headers.get("content-type") ?? "";
5662
5931
  if (!contentType.startsWith("image/")) {
5663
- const { detectImageMimeType } = await import("./blob-utils-KYOyFu79.js");
5932
+ const { detectImageMimeType } = await import("./blob-utils-CJyQkdm-.js");
5664
5933
  contentType = await detectImageMimeType(blob) ?? contentType;
5665
5934
  }
5666
5935
  return {
@@ -13157,7 +13426,7 @@ var _a19;
13157
13426
  _a19 = symbol19;
13158
13427
 
13159
13428
  //#endregion
13160
- //#region ../mcp-core/dist/error-handling-BsZo3KBt.js
13429
+ //#region ../mcp-core/dist/error-handling-ChAIYsge.js
13161
13430
  /**
13162
13431
  * Type guard to identify user input validation errors.
13163
13432
  */
@@ -13359,9 +13628,19 @@ async function formatErrorForUser(error, options) {
13359
13628
  }
13360
13629
  return parts.join("\n\n");
13361
13630
  }
13631
+ /**
13632
+ * Invoke a tool's onError hook for failure telemetry, isolated so a misbehaving
13633
+ * hook can't disrupt the surrounding error handling. Call this at every point
13634
+ * where a tool handler is run and may throw.
13635
+ */
13636
+ function recordToolFailure(tool$1, error, params, context$1) {
13637
+ try {
13638
+ tool$1.onError?.(error, params, context$1);
13639
+ } catch {}
13640
+ }
13362
13641
 
13363
13642
  //#endregion
13364
- //#region ../mcp-core/dist/constraint-helpers-C-VlK4t-.js
13643
+ //#region ../mcp-core/dist/constraint-helpers-DQeAySy6.js
13365
13644
  /**
13366
13645
  * Determines which tool parameter keys should be filtered out of the schema
13367
13646
  * because they will be injected from constraints.
@@ -13423,7 +13702,7 @@ function getConstraintParametersToInject(constraints, toolInputSchema) {
13423
13702
  }
13424
13703
 
13425
13704
  //#endregion
13426
- //#region ../mcp-core/dist/surfaces-B1_F0pzt.js
13705
+ //#region ../mcp-core/dist/surfaces-DCc7zT-1.js
13427
13706
  /**
13428
13707
  * Central policy for direct MCP exposure.
13429
13708
  *
@@ -13458,7 +13737,7 @@ function isCatalogInfrastructureToolName(toolName) {
13458
13737
  }
13459
13738
 
13460
13739
  //#endregion
13461
- //#region ../mcp-core/dist/types-DGnYE-i7.js
13740
+ //#region ../mcp-core/dist/types-DzNDeR5X.js
13462
13741
  /**
13463
13742
  * Resolves a tool description to a string.
13464
13743
  * Handles both static strings and dynamic description functions.
@@ -13476,7 +13755,7 @@ function isToolVisibleInMode(tool$1, experimentalMode) {
13476
13755
  }
13477
13756
 
13478
13757
  //#endregion
13479
- //#region ../mcp-core/dist/availability-zLnbaxcD.js
13758
+ //#region ../mcp-core/dist/availability-KeZ7TRFd.js
13480
13759
  function getToolPlacement({ key, experimentalMode, useDefaultSurfacePolicy }) {
13481
13760
  if (useDefaultSurfacePolicy) return {
13482
13761
  isCatalogTool: !isOutsideCatalogToolName(key),
@@ -13574,13 +13853,13 @@ function resolveToolDescription(tool$1, context$1) {
13574
13853
  }
13575
13854
 
13576
13855
  //#endregion
13577
- //#region ../mcp-core/dist/define-SD6AQa4b.js
13856
+ //#region ../mcp-core/dist/define-CmkKwzq9.js
13578
13857
  function defineTool(config) {
13579
13858
  return config;
13580
13859
  }
13581
13860
 
13582
13861
  //#endregion
13583
- //#region ../mcp-core/dist/validate-region-url-C2aYIha9.js
13862
+ //#region ../mcp-core/dist/validate-region-url-DbvSZfG2.js
13584
13863
  /**
13585
13864
  * Validates that a regionUrl is valid.
13586
13865
  * Prevents SSRF attacks by only allowing the base host itself or domains from an allowlist.
@@ -13612,7 +13891,7 @@ function validateRegionUrl(regionUrl, baseHost) {
13612
13891
  }
13613
13892
 
13614
13893
  //#endregion
13615
- //#region ../mcp-core/dist/api-EaEPyKlQ.js
13894
+ //#region ../mcp-core/dist/api-D4GH5wp9.js
13616
13895
  /**
13617
13896
  * Create a Sentry API service from server context with optional region override
13618
13897
  * @param context - Server context containing host and access token
@@ -13638,17 +13917,35 @@ function apiServiceFromContext(context$1, opts = {}) {
13638
13917
  }
13639
13918
 
13640
13919
  //#endregion
13641
- //#region ../mcp-core/dist/results-NF1RJbDZ.js
13920
+ //#region ../mcp-core/dist/results-zMvHfnlV.js
13921
+ /**
13922
+ * Tool result packing policy
13923
+ *
13924
+ * - `structuredContent` is the source of truth when present.
13925
+ * - `content` text is a compatibility view of that same answer.
13926
+ * - Never put unique product data in only one side. If both fields are present,
13927
+ * they must be equivalent. Form-only differences (JSON vs pretty text of the
13928
+ * same payload) are fine; a second answer that exists in only one field is a
13929
+ * bug.
13930
+ * - Prefer `structuredResult(payload)` for data tools. The server generates
13931
+ * `content` as pretty JSON of the same payload.
13932
+ * - Markdown-only tools should return markdown and omit `structuredContent`
13933
+ * until they have a real structured payload. Do not attach sparse structured
13934
+ * side-channels (for example suggestedActions alone) on top of markdown.
13935
+ */
13642
13936
  /**
13643
13937
  * Marks a tool result as structured-only. The server generates compatibility
13644
13938
  * text for clients that do not read structuredContent yet.
13939
+ *
13940
+ * The returned payload is the full answer. Do not use this helper to ship a
13941
+ * partial hint while leaving the real answer only in handwritten markdown.
13645
13942
  */
13646
13943
  function structuredResult(structuredContent) {
13647
13944
  return { structuredContent };
13648
13945
  }
13649
13946
 
13650
13947
  //#endregion
13651
- //#region ../mcp-core/dist/whoami-Bz6QKirR.js
13948
+ //#region ../mcp-core/dist/whoami-DthGP5fH.js
13652
13949
  const whoamiOutputSchema = z.object({
13653
13950
  user: z.object({
13654
13951
  id: z.string(),
@@ -13699,7 +13996,33 @@ var whoami_default = defineTool({
13699
13996
  });
13700
13997
 
13701
13998
  //#endregion
13702
- //#region ../mcp-core/dist/find-organizations-CXTZEMsb.js
13999
+ //#region ../mcp-core/dist/get-sentry-mcp-info-Dg-_VZlQ.js
14000
+ const getSentryMcpInfoOutputSchema = z.object({ version: z.string().describe("The Sentry MCP server version.") });
14001
+ var get_sentry_mcp_info_default = defineTool({
14002
+ name: "get_sentry_mcp_info",
14003
+ description: [
14004
+ "Get information about the running Sentry MCP server.",
14005
+ "",
14006
+ "Use this tool when you need to:",
14007
+ "- Check the Sentry MCP server version",
14008
+ "- Verify compatibility with a Skill or integration"
14009
+ ].join("\n"),
14010
+ inputSchema: {},
14011
+ outputSchema: getSentryMcpInfoOutputSchema,
14012
+ skills: ALL_SKILLS,
14013
+ requiredScopes: [],
14014
+ annotations: {
14015
+ readOnlyHint: true,
14016
+ destructiveHint: false,
14017
+ openWorldHint: false
14018
+ },
14019
+ async handler() {
14020
+ return structuredResult({ version: LIB_VERSION });
14021
+ }
14022
+ });
14023
+
14024
+ //#endregion
14025
+ //#region ../mcp-core/dist/find-organizations-BjoY7_gy.js
13703
14026
  const RESULT_LIMIT$3 = 25;
13704
14027
  const findOrganizationsOutputSchema = z.object({
13705
14028
  organizations: z.array(z.object({
@@ -13751,7 +14074,14 @@ var find_organizations_default = defineTool({
13751
14074
  });
13752
14075
 
13753
14076
  //#endregion
13754
- //#region ../mcp-core/dist/find-teams-ZsyAWNb7.js
14077
+ //#region ../mcp-core/dist/organization-KfwiyEVH.js
14078
+ function setOrganizationContext(organizationSlug) {
14079
+ setAttribute("organization.slug", organizationSlug);
14080
+ setTag("organization.slug", organizationSlug);
14081
+ }
14082
+
14083
+ //#endregion
14084
+ //#region ../mcp-core/dist/find-teams-C5yde5nc.js
13755
14085
  const RESULT_LIMIT$2 = 25;
13756
14086
  const findTeamsOutputSchema = z.object({
13757
14087
  teams: z.array(z.object({
@@ -13793,7 +14123,7 @@ var find_teams_default = defineTool({
13793
14123
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
13794
14124
  const organizationSlug = params.organizationSlug;
13795
14125
  if (!organizationSlug) throw new UserInputError("Organization slug is required. Please provide an organizationSlug parameter.");
13796
- setTag("organization.slug", organizationSlug);
14126
+ setOrganizationContext(organizationSlug);
13797
14127
  const teams = await apiService.listTeams(organizationSlug, {
13798
14128
  query: params.query ?? void 0,
13799
14129
  limit: RESULT_LIMIT$2 + 1
@@ -13809,7 +14139,7 @@ var find_teams_default = defineTool({
13809
14139
  });
13810
14140
 
13811
14141
  //#endregion
13812
- //#region ../mcp-core/dist/find-projects-BYeZfQDF.js
14142
+ //#region ../mcp-core/dist/find-projects-DBOb3oe-.js
13813
14143
  const RESULT_LIMIT$1 = 25;
13814
14144
  const findProjectsOutputSchema = z.object({
13815
14145
  projects: z.array(z.object({ slug: z.string() })),
@@ -13844,7 +14174,7 @@ var find_projects_default = defineTool({
13844
14174
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
13845
14175
  const organizationSlug = params.organizationSlug;
13846
14176
  if (!organizationSlug) throw new UserInputError("Organization slug is required. Please provide an organizationSlug parameter.");
13847
- setTag("organization.slug", organizationSlug);
14177
+ setOrganizationContext(organizationSlug);
13848
14178
  const projects = await apiService.listProjects(organizationSlug, {
13849
14179
  query: params.query ?? void 0,
13850
14180
  limit: RESULT_LIMIT$1 + 1
@@ -13857,7 +14187,7 @@ var find_projects_default = defineTool({
13857
14187
  });
13858
14188
 
13859
14189
  //#endregion
13860
- //#region ../mcp-core/dist/find-releases-fkgr4qqZ.js
14190
+ //#region ../mcp-core/dist/find-releases-BF8-U7mW.js
13861
14191
  const RESULT_LIMIT = 25;
13862
14192
  const findReleasesOutputSchema = z.object({
13863
14193
  releases: z.array(z.object({
@@ -13930,7 +14260,7 @@ var find_releases_default = defineTool({
13930
14260
  async handler(params, context$1) {
13931
14261
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
13932
14262
  const organizationSlug = params.organizationSlug;
13933
- setTag("organization.slug", organizationSlug);
14263
+ setOrganizationContext(organizationSlug);
13934
14264
  const releases = await apiService.listReleases({
13935
14265
  organizationSlug,
13936
14266
  projectSlug: params.projectSlug ?? void 0,
@@ -13965,13 +14295,13 @@ var find_releases_default = defineTool({
13965
14295
  });
13966
14296
 
13967
14297
  //#endregion
13968
- //#region ../mcp-core/dist/type-guards-DHLAzjf2.js
14298
+ //#region ../mcp-core/dist/type-guards-CsRf3nQI.js
13969
14299
  function isPlainObject$3(value) {
13970
14300
  return typeof value === "object" && value !== null && !Array.isArray(value);
13971
14301
  }
13972
14302
 
13973
14303
  //#endregion
13974
- //#region ../mcp-core/dist/api-formatting-nIGXUFdx.js
14304
+ //#region ../mcp-core/dist/api-formatting-Czl92Wir.js
13975
14305
  function formatId(value) {
13976
14306
  return value === void 0 || value === null ? "unknown" : String(value);
13977
14307
  }
@@ -14008,7 +14338,7 @@ function compactLines(lines) {
14008
14338
  }
14009
14339
 
14010
14340
  //#endregion
14011
- //#region ../mcp-core/dist/project-constraints-DlfcU4mm.js
14341
+ //#region ../mcp-core/dist/project-constraints-B-KhJpNB.js
14012
14342
  function projectConstraintError(resourceLabel, projectSlug$1) {
14013
14343
  return new UserInputError(`${resourceLabel} is outside the active project constraint. Expected project "${projectSlug$1}".`);
14014
14344
  }
@@ -14026,7 +14356,7 @@ function assertProjectListContainsConstraint({ resourceLabel, scopedProjectSlug,
14026
14356
  }
14027
14357
 
14028
14358
  //#endregion
14029
- //#region ../mcp-core/dist/get-release-details-0bKoH-Gv.js
14359
+ //#region ../mcp-core/dist/get-release-details-DvY_TDet.js
14030
14360
  function formatProjects(release) {
14031
14361
  if (!release.projects || release.projects.length === 0) return null;
14032
14362
  return release.projects.map((project) => project.slug ?? project.name).join(", ");
@@ -14098,7 +14428,7 @@ var get_release_details_default = defineTool({
14098
14428
  async handler(params, context$1) {
14099
14429
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
14100
14430
  const organizationSlug = params.organizationSlug;
14101
- setTag("organization.slug", organizationSlug);
14431
+ setOrganizationContext(organizationSlug);
14102
14432
  setTag("release.version", params.releaseVersion);
14103
14433
  const scopedProjectSlug = context$1.constraints.projectSlug ?? void 0;
14104
14434
  const requestedProjectSlugOrId = params.projectSlugOrId ?? void 0;
@@ -14178,7 +14508,7 @@ var get_release_details_default = defineTool({
14178
14508
  });
14179
14509
 
14180
14510
  //#endregion
14181
- //#region ../mcp-core/dist/dashboards-BCwvH2V2.js
14511
+ //#region ../mcp-core/dist/dashboards-CHADwOiv.js
14182
14512
  function formatList(values) {
14183
14513
  if (!values || values.length === 0) return null;
14184
14514
  return values.map(String).join(", ");
@@ -14310,7 +14640,7 @@ async function resolveDashboardId({ apiService, organizationSlug, dashboardIdOrT
14310
14640
  }
14311
14641
 
14312
14642
  //#endregion
14313
- //#region ../mcp-core/dist/find-dashboards-DE0x5cIv.js
14643
+ //#region ../mcp-core/dist/find-dashboards-oyqvVv8a.js
14314
14644
  const PROJECT_DASHBOARD_CURSOR_PREFIX = "mcp-dashboard-project:";
14315
14645
  const dashboardSummarySchema = z.object({
14316
14646
  id: z.string(),
@@ -14469,7 +14799,7 @@ var find_dashboards_default = defineTool({
14469
14799
  async handler(params, context$1) {
14470
14800
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
14471
14801
  const organizationSlug = params.organizationSlug;
14472
- setTag("organization.slug", organizationSlug);
14802
+ setOrganizationContext(organizationSlug);
14473
14803
  const scopedProject = await resolveDashboardProjectConstraint({
14474
14804
  apiService,
14475
14805
  organizationSlug,
@@ -14521,7 +14851,7 @@ var find_dashboards_default = defineTool({
14521
14851
  });
14522
14852
 
14523
14853
  //#endregion
14524
- //#region ../mcp-core/dist/get-dashboard-details-7tf-4Q_F.js
14854
+ //#region ../mcp-core/dist/get-dashboard-details-D_U6hOFe.js
14525
14855
  var get_dashboard_details_default = defineTool({
14526
14856
  name: "get_dashboard_details",
14527
14857
  skills: ["inspect"],
@@ -14558,7 +14888,7 @@ var get_dashboard_details_default = defineTool({
14558
14888
  async handler(params, context$1) {
14559
14889
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
14560
14890
  const organizationSlug = params.organizationSlug;
14561
- setTag("organization.slug", organizationSlug);
14891
+ setOrganizationContext(organizationSlug);
14562
14892
  const scopedProject = await resolveDashboardProjectConstraint({
14563
14893
  apiService,
14564
14894
  organizationSlug,
@@ -14595,7 +14925,7 @@ var get_dashboard_details_default = defineTool({
14595
14925
  });
14596
14926
 
14597
14927
  //#endregion
14598
- //#region ../mcp-core/dist/find-monitors-DOaVdrCU.js
14928
+ //#region ../mcp-core/dist/find-monitors-CwXZsdiJ.js
14599
14929
  const ENVIRONMENT_LIMIT = 5;
14600
14930
  const monitorScheduleOutputSchema = z.object({
14601
14931
  type: z.string().nullable(),
@@ -14727,7 +15057,7 @@ var find_monitors_default = defineTool({
14727
15057
  async handler(params, context$1) {
14728
15058
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
14729
15059
  const organizationSlug = params.organizationSlug;
14730
- setTag("organization.slug", organizationSlug);
15060
+ setOrganizationContext(organizationSlug);
14731
15061
  const requestedProjectSlug = params.projectSlug && params.projectSlug !== "all" ? params.projectSlug : void 0;
14732
15062
  if (requestedProjectSlug) assertProjectRefWithinConstraint({
14733
15063
  resourceLabel: "Monitor list",
@@ -14773,7 +15103,7 @@ var find_monitors_default = defineTool({
14773
15103
  });
14774
15104
 
14775
15105
  //#endregion
14776
- //#region ../mcp-core/dist/get-monitor-details-CP_Cj6P3.js
15106
+ //#region ../mcp-core/dist/get-monitor-details-CDcHPW6x.js
14777
15107
  function formatProject(monitor) {
14778
15108
  if (!monitor.project) return null;
14779
15109
  return monitor.project.slug ?? monitor.project.name ?? null;
@@ -14838,7 +15168,7 @@ var get_monitor_details_default = defineTool({
14838
15168
  async handler(params, context$1) {
14839
15169
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
14840
15170
  const organizationSlug = params.organizationSlug;
14841
- setTag("organization.slug", organizationSlug);
15171
+ setOrganizationContext(organizationSlug);
14842
15172
  setTag("monitor.slug", params.monitorSlug);
14843
15173
  const requestedProjectSlugOrId = params.projectSlugOrId ?? void 0;
14844
15174
  const projectSlugOrId = requestedProjectSlugOrId ?? context$1.constraints.projectSlug ?? null;
@@ -14933,7 +15263,7 @@ var get_monitor_details_default = defineTool({
14933
15263
  });
14934
15264
 
14935
15265
  //#endregion
14936
- //#region ../mcp-core/dist/uptime-monitors-DdMrkrKy.js
15266
+ //#region ../mcp-core/dist/uptime-monitors-D7xvJsr1.js
14937
15267
  /** Verified against UptimeSubscription.IntervalSeconds in getsentry/sentry. */
14938
15268
  const UPTIME_INTERVAL_SECONDS = [
14939
15269
  60,
@@ -15066,7 +15396,7 @@ function toUptimeMonitorSummary(monitor, webUrl) {
15066
15396
  }
15067
15397
 
15068
15398
  //#endregion
15069
- //#region ../mcp-core/dist/find-uptime-monitors-NZjkNLjM.js
15399
+ //#region ../mcp-core/dist/find-uptime-monitors-B5dw0P9D.js
15070
15400
  const findUptimeMonitorsOutputSchema = z.object({
15071
15401
  monitors: z.array(uptimeMonitorListItemSchema),
15072
15402
  hasMore: z.boolean()
@@ -15109,7 +15439,7 @@ var find_uptime_monitors_default = defineTool({
15109
15439
  async handler(params, context$1) {
15110
15440
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
15111
15441
  const organizationSlug = params.organizationSlug;
15112
- setTag("organization.slug", organizationSlug);
15442
+ setOrganizationContext(organizationSlug);
15113
15443
  const requestedProjectSlug = params.projectSlug && params.projectSlug !== "all" ? params.projectSlug : void 0;
15114
15444
  if (requestedProjectSlug) assertProjectRefWithinConstraint({
15115
15445
  resourceLabel: "Uptime monitor list",
@@ -15134,7 +15464,7 @@ var find_uptime_monitors_default = defineTool({
15134
15464
  });
15135
15465
 
15136
15466
  //#endregion
15137
- //#region ../mcp-core/dist/get-uptime-monitor-details-DfFRiDqD.js
15467
+ //#region ../mcp-core/dist/get-uptime-monitor-details-B40FMp1m.js
15138
15468
  function formatCheck(check, monitorEnvironment) {
15139
15469
  const time = formatDate(check.timestamp) ?? formatDate(check.scheduledCheckTime) ?? "unknown time";
15140
15470
  const status = check.checkStatus ?? "unknown";
@@ -15187,7 +15517,7 @@ var get_uptime_monitor_details_default = defineTool({
15187
15517
  async handler(params, context$1) {
15188
15518
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
15189
15519
  const organizationSlug = params.organizationSlug;
15190
- setTag("organization.slug", organizationSlug);
15520
+ setOrganizationContext(organizationSlug);
15191
15521
  setTag("project.slug", params.projectSlug);
15192
15522
  setTag("uptime.monitor_id", params.uptimeMonitorId);
15193
15523
  assertProjectRefWithinConstraint({
@@ -15256,7 +15586,7 @@ var get_uptime_monitor_details_default = defineTool({
15256
15586
  });
15257
15587
 
15258
15588
  //#endregion
15259
- //#region ../mcp-core/dist/create-uptime-monitor-fo-rIhsm.js
15589
+ //#region ../mcp-core/dist/create-uptime-monitor-BarA-8c1.js
15260
15590
  const createUptimeMonitorOutputSchema = z.object({ monitor: uptimeMonitorSummarySchema });
15261
15591
  var create_uptime_monitor_default = defineTool({
15262
15592
  name: "create_uptime_monitor",
@@ -15307,7 +15637,7 @@ var create_uptime_monitor_default = defineTool({
15307
15637
  async handler(params, context$1) {
15308
15638
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
15309
15639
  const organizationSlug = params.organizationSlug;
15310
- setTag("organization.slug", organizationSlug);
15640
+ setOrganizationContext(organizationSlug);
15311
15641
  setTag("project.slug", params.projectSlug);
15312
15642
  assertProjectRefWithinConstraint({
15313
15643
  resourceLabel: "Uptime monitor",
@@ -15337,7 +15667,7 @@ var create_uptime_monitor_default = defineTool({
15337
15667
  });
15338
15668
 
15339
15669
  //#endregion
15340
- //#region ../mcp-core/dist/update-uptime-monitor-CXyi5lFD.js
15670
+ //#region ../mcp-core/dist/update-uptime-monitor-Borxg5io.js
15341
15671
  const updateUptimeMonitorOutputSchema = z.object({ monitor: uptimeMonitorSummarySchema });
15342
15672
  function hasDefinedUpdate(value) {
15343
15673
  return value !== void 0;
@@ -15394,7 +15724,7 @@ var update_uptime_monitor_default = defineTool({
15394
15724
  async handler(params, context$1) {
15395
15725
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
15396
15726
  const organizationSlug = params.organizationSlug;
15397
- setTag("organization.slug", organizationSlug);
15727
+ setOrganizationContext(organizationSlug);
15398
15728
  setTag("project.slug", params.projectSlug);
15399
15729
  setTag("uptime.monitor_id", params.uptimeMonitorId);
15400
15730
  assertProjectRefWithinConstraint({
@@ -15428,7 +15758,7 @@ var update_uptime_monitor_default = defineTool({
15428
15758
  });
15429
15759
 
15430
15760
  //#endregion
15431
- //#region ../mcp-core/dist/delete-uptime-monitor-CHj4Cluv.js
15761
+ //#region ../mcp-core/dist/delete-uptime-monitor-CpzZ4G3P.js
15432
15762
  const deleteUptimeMonitorOutputSchema = z.object({
15433
15763
  success: z.literal(true),
15434
15764
  uptimeMonitorId: z.string(),
@@ -15465,7 +15795,7 @@ var delete_uptime_monitor_default = defineTool({
15465
15795
  async handler(params, context$1) {
15466
15796
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
15467
15797
  const organizationSlug = params.organizationSlug;
15468
- setTag("organization.slug", organizationSlug);
15798
+ setOrganizationContext(organizationSlug);
15469
15799
  setTag("project.slug", params.projectSlug);
15470
15800
  setTag("uptime.monitor_id", params.uptimeMonitorId);
15471
15801
  assertProjectRefWithinConstraint({
@@ -15487,12 +15817,12 @@ var delete_uptime_monitor_default = defineTool({
15487
15817
  });
15488
15818
 
15489
15819
  //#endregion
15490
- //#region ../mcp-core/dist/find-alert-rules-Co9XjMKY.js
15820
+ //#region ../mcp-core/dist/find-alert-rules-Dc55EgzE.js
15491
15821
  const AlertRuleKind$1 = z.enum([
15492
15822
  "all",
15493
15823
  "issue",
15494
15824
  "metric"
15495
- ]).describe("Which alert rule family to search. Use `all` to include metric alerts, plus issue alerts when a project is available.");
15825
+ ]).describe("Which alert rule family to search. Use `all` to include Alerts (workflows) and legacy metric alerts.");
15496
15826
  const issueAlertRuleSummarySchema = z.object({
15497
15827
  id: z.string(),
15498
15828
  name: z.string(),
@@ -15528,9 +15858,10 @@ const findAlertRulesOutputSchema = z.object({
15528
15858
  pagination: z.object({
15529
15859
  issue: paginationStateSchema.nullable(),
15530
15860
  metric: paginationStateSchema.nullable()
15531
- })
15861
+ }),
15862
+ warnings: z.array(z.string()).optional()
15532
15863
  });
15533
- function getIssueAlertRuleFrequency$1(rule) {
15864
+ function getIssueAlertRuleFrequency(rule) {
15534
15865
  if (typeof rule.frequency === "number") return rule.frequency;
15535
15866
  const frequency = rule.config.frequency;
15536
15867
  return typeof frequency === "number" ? frequency : null;
@@ -15551,7 +15882,7 @@ var find_alert_rules_default = defineTool({
15551
15882
  "Find Sentry alert rules.",
15552
15883
  "",
15553
15884
  "Use this tool when you need to:",
15554
- "- List issue alert rules for a project",
15885
+ "- List Alerts (workflows) for an organization or project, including Alerts without connected sources",
15555
15886
  "- List metric alert rules for an organization or project",
15556
15887
  "- Find an alert rule ID by name before inspecting it",
15557
15888
  "- Check alert conditions, queries, triggers, actions, owner, or environment",
@@ -15563,8 +15894,8 @@ var find_alert_rules_default = defineTool({
15563
15894
  "</examples>",
15564
15895
  "",
15565
15896
  "<hints>",
15566
- "- Issue alert rules are project-scoped, so `projectSlug` is required when `kind` is `issue`.",
15567
- "- Metric alert rules can be listed organization-wide or project-scoped.",
15897
+ "- Omit `projectSlug` to search organization-wide. A project filter finds connected Alerts, which may also cover other projects.",
15898
+ "- With `kind='all'`, an unavailable legacy metric alert API is reported in `warnings`; the returned Alerts are still usable.",
15568
15899
  "- Issue and metric alert rules have independent pagination state. Reuse a nextCursor only with its matching kind.",
15569
15900
  "</hints>"
15570
15901
  ].join("\n"),
@@ -15591,15 +15922,14 @@ var find_alert_rules_default = defineTool({
15591
15922
  project: { slug: requestedProjectSlug }
15592
15923
  });
15593
15924
  const projectSlug$1 = context$1.constraints.projectSlug ?? requestedProjectSlug;
15594
- if (params.kind === "issue" && !projectSlug$1) throw new UserInputError("projectSlug is required when searching issue alert rules.");
15595
15925
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
15596
15926
  const organizationSlug = params.organizationSlug;
15597
- setTag("organization.slug", organizationSlug);
15927
+ setOrganizationContext(organizationSlug);
15598
15928
  if (projectSlug$1) setTag("project.slug", projectSlug$1);
15599
- const includeIssue = params.kind !== "metric" && Boolean(projectSlug$1);
15929
+ const includeIssue = params.kind !== "metric";
15600
15930
  const includeMetric = params.kind !== "issue";
15601
15931
  if (params.cursor && includeIssue && includeMetric) throw new UserInputError("cursor cannot be used with `kind='all'` when both issue and metric alert rules are included. Retry with `kind='issue'` or `kind='metric'` using a cursor from the same alert rule family.");
15602
- const issuePage = includeIssue && projectSlug$1 ? await apiService.listIssueAlertRulesPage({
15932
+ const issuePage = includeIssue ? await apiService.listIssueAlertRulesPage({
15603
15933
  organizationSlug,
15604
15934
  projectSlug: projectSlug$1,
15605
15935
  query: params.query ?? void 0,
@@ -15609,16 +15939,18 @@ var find_alert_rules_default = defineTool({
15609
15939
  rules: [],
15610
15940
  nextCursor: null
15611
15941
  };
15942
+ const warnings = [];
15612
15943
  const metricPage = includeMetric ? await apiService.listMetricAlertRulesPage({
15613
15944
  organizationSlug,
15614
15945
  projectSlug: projectSlug$1,
15615
15946
  query: params.query ?? void 0,
15616
15947
  cursor: params.cursor ?? void 0,
15617
15948
  limit: params.limit
15618
- }) : {
15619
- rules: [],
15620
- nextCursor: null
15621
- };
15949
+ }).catch((error) => {
15950
+ if (params.kind !== "all" || !(error instanceof ApiError) || error.status !== 410) throw error;
15951
+ warnings.push("Metric alerts could not be listed: Sentry's legacy metric alert API is no longer available for this organization.");
15952
+ return null;
15953
+ }) : null;
15622
15954
  return structuredResult({
15623
15955
  issueRules: issuePage.rules.map((rule) => ({
15624
15956
  id: String(rule.id),
@@ -15626,7 +15958,7 @@ var find_alert_rules_default = defineTool({
15626
15958
  status: getIssueAlertRuleStatus(rule),
15627
15959
  actionMatch: rule.actionMatch ?? null,
15628
15960
  filterMatch: rule.filterMatch ?? null,
15629
- frequencyMinutes: getIssueAlertRuleFrequency$1(rule),
15961
+ frequencyMinutes: getIssueAlertRuleFrequency(rule),
15630
15962
  environment: rule.environment ?? null,
15631
15963
  owner: getOwner(rule.owner),
15632
15964
  dateCreated: formatDate(rule.dateCreated),
@@ -15634,7 +15966,7 @@ var find_alert_rules_default = defineTool({
15634
15966
  lastTriggered: formatDate(rule.lastTriggered),
15635
15967
  webUrl: apiService.getIssueAlertRuleUrl(organizationSlug, rule.id)
15636
15968
  })),
15637
- metricRules: metricPage.rules.map((rule) => ({
15969
+ metricRules: (metricPage?.rules ?? []).map((rule) => ({
15638
15970
  id: String(rule.id),
15639
15971
  name: rule.name,
15640
15972
  status: rule.status ?? null,
@@ -15650,14 +15982,184 @@ var find_alert_rules_default = defineTool({
15650
15982
  })),
15651
15983
  pagination: {
15652
15984
  issue: includeIssue ? { nextCursor: issuePage.nextCursor } : null,
15653
- metric: includeMetric ? { nextCursor: metricPage.nextCursor } : null
15654
- }
15985
+ metric: metricPage ? { nextCursor: metricPage.nextCursor } : null
15986
+ },
15987
+ ...warnings.length > 0 ? { warnings } : {}
15655
15988
  });
15656
15989
  }
15657
15990
  });
15658
15991
 
15659
15992
  //#endregion
15660
- //#region ../mcp-core/dist/alerts-CVOIE5iC.js
15993
+ //#region ../mcp-core/dist/alert-rule-details-CJ-FfoC7.js
15994
+ const componentId = z.union([z.string(), z.number()]);
15995
+ const conditionSchema = z.object({
15996
+ id: componentId.optional(),
15997
+ type: z.string(),
15998
+ comparison: z.unknown(),
15999
+ conditionResult: z.unknown()
16000
+ });
16001
+ const conditionGroupSchema$1 = z.object({
16002
+ id: componentId.optional(),
16003
+ logicType: z.string(),
16004
+ conditions: z.array(conditionSchema)
16005
+ });
16006
+ const actionGroupSchema = conditionGroupSchema$1.extend({ actions: z.array(z.object({
16007
+ id: componentId.optional(),
16008
+ type: z.string(),
16009
+ integrationId: componentId.nullable().optional(),
16010
+ config: z.record(z.string(), z.unknown()),
16011
+ data: z.record(z.string(), z.unknown()),
16012
+ status: z.string().optional()
16013
+ })) });
16014
+ const metricQuerySchema = z.object({
16015
+ dataset: z.string(),
16016
+ query: z.string(),
16017
+ aggregate: z.string(),
16018
+ timeWindow: z.number(),
16019
+ environment: z.string().nullable(),
16020
+ eventTypes: z.array(z.string()),
16021
+ extrapolationMode: z.string().nullable().optional()
16022
+ });
16023
+ const uptimeQuerySchema = z.object({
16024
+ url: z.string(),
16025
+ method: z.string(),
16026
+ intervalSeconds: z.number(),
16027
+ timeoutMs: z.number(),
16028
+ assertion: z.unknown(),
16029
+ traceSampling: z.boolean().optional(),
16030
+ responseCaptureEnabled: z.boolean().optional()
16031
+ });
16032
+ const cronQuerySchema = z.object({
16033
+ id: z.string(),
16034
+ name: z.string(),
16035
+ slug: z.string(),
16036
+ status: z.string(),
16037
+ isMuted: z.boolean(),
16038
+ config: z.object({
16039
+ schedule_type: z.string(),
16040
+ schedule: z.union([z.string(), z.array(z.union([z.number(), z.string()]))]),
16041
+ checkin_margin: z.number().nullable().optional(),
16042
+ max_runtime: z.number().nullable().optional(),
16043
+ timezone: z.string().nullable().optional(),
16044
+ failure_issue_threshold: z.number().nullable().optional(),
16045
+ recovery_threshold: z.number().nullable().optional()
16046
+ }),
16047
+ environments: z.array(z.object({
16048
+ name: z.string(),
16049
+ status: z.string(),
16050
+ isMuted: z.boolean()
16051
+ }))
16052
+ });
16053
+ function sourceDetails(source) {
16054
+ const type = typeof source.type === "string" ? source.type : "unknown";
16055
+ const query = source.queryObj;
16056
+ const unavailable = {
16057
+ type,
16058
+ unavailableReason: "Source configuration is unavailable."
16059
+ };
16060
+ if (!isPlainObject$3(query)) return unavailable;
16061
+ if (type === "snuba_query_subscription") {
16062
+ const parsed = metricQuerySchema.safeParse(query.snubaQuery);
16063
+ if (!parsed.success) return unavailable;
16064
+ const { timeWindow,...config } = parsed.data;
16065
+ return {
16066
+ type,
16067
+ query: {
16068
+ ...config,
16069
+ timeWindowSeconds: timeWindow
16070
+ }
16071
+ };
16072
+ }
16073
+ if (type === "uptime_subscription") {
16074
+ const parsed = uptimeQuerySchema.safeParse(query);
16075
+ return parsed.success ? {
16076
+ type,
16077
+ query: parsed.data,
16078
+ omittedFields: ["headers", "body"]
16079
+ } : unavailable;
16080
+ }
16081
+ if (type === "cron_monitor") {
16082
+ const parsed = cronQuerySchema.safeParse(query);
16083
+ return parsed.success ? {
16084
+ type,
16085
+ query: parsed.data
16086
+ } : unavailable;
16087
+ }
16088
+ return {
16089
+ type,
16090
+ unavailableReason: "This source type is not supported for inspection."
16091
+ };
16092
+ }
16093
+ /** Project native configuration explicitly so backend metadata stays private. */
16094
+ async function getAlertRuleDetails(api, organizationSlug, rule, scopedProjectSlug) {
16095
+ const scope = await api.getAlertRuleProjectScope({
16096
+ organizationSlug,
16097
+ ruleId: rule.id
16098
+ });
16099
+ const project = scopedProjectSlug ? await api.getProject({
16100
+ organizationSlug,
16101
+ projectSlugOrId: scopedProjectSlug
16102
+ }) : void 0;
16103
+ const sources = [];
16104
+ for (const id of rule.detectorIds ?? []) try {
16105
+ const detector = await api.getDetector({
16106
+ organizationSlug,
16107
+ detectorId: id
16108
+ });
16109
+ if (project && detector.projectId !== null && String(detector.projectId) !== String(project.id)) {
16110
+ sources.push({
16111
+ id: String(id),
16112
+ status: "outside_project_constraint"
16113
+ });
16114
+ continue;
16115
+ }
16116
+ sources.push({
16117
+ id: String(detector.id),
16118
+ status: "available",
16119
+ name: detector.name,
16120
+ type: detector.type,
16121
+ projectId: detector.projectId === null ? null : String(detector.projectId),
16122
+ enabled: detector.enabled,
16123
+ config: detector.type === "issue_stream" ? {} : detector.config,
16124
+ conditionGroup: detector.conditionGroup ? conditionGroupSchema$1.parse(detector.conditionGroup) : null,
16125
+ dataSources: (detector.dataSources ?? []).map(sourceDetails)
16126
+ });
16127
+ } catch (error) {
16128
+ if (!(error instanceof ApiNotFoundError || error instanceof ApiPermissionError)) throw error;
16129
+ sources.push({
16130
+ id: String(id),
16131
+ status: "unavailable",
16132
+ reason: "Not found or not accessible."
16133
+ });
16134
+ }
16135
+ const projectIds = project ? scope.projectIds.filter((id) => id === String(project.id)) : scope.projectIds;
16136
+ return {
16137
+ id: String(rule.id),
16138
+ name: rule.name,
16139
+ enabled: rule.enabled,
16140
+ config: z.object({ frequency: z.number().optional() }).parse(rule.config),
16141
+ environment: rule.environment,
16142
+ owner: rule.owner ? formatActor(rule.owner) : null,
16143
+ dateCreated: formatDate(rule.dateCreated),
16144
+ dateUpdated: formatDate(rule.dateUpdated),
16145
+ lastTriggered: formatDate(rule.lastTriggered),
16146
+ triggers: rule.triggers ? conditionGroupSchema$1.parse(rule.triggers) : null,
16147
+ actionFilters: (rule.actionFilters ?? []).map((group) => actionGroupSchema.parse(group)),
16148
+ scope: {
16149
+ includesAllProjects: scope.includesAllProjects,
16150
+ projectIds,
16151
+ ...project ? {
16152
+ limitedToProject: scopedProjectSlug,
16153
+ ...!scope.includesAllProjects ? { outsideProjectCount: scope.projectIds.length - projectIds.length } : {}
16154
+ } : {}
16155
+ },
16156
+ sources,
16157
+ webUrl: api.getIssueAlertRuleUrl(organizationSlug, rule.id)
16158
+ };
16159
+ }
16160
+
16161
+ //#endregion
16162
+ //#region ../mcp-core/dist/alerts-Cv9MFDEC.js
15661
16163
  const NUMERIC_ID_PATTERN = /^\d+$/;
15662
16164
  const COMPONENT_DETAIL_SKIP_KEYS = new Set([
15663
16165
  "id",
@@ -15785,40 +16287,6 @@ function formatComponentSummary(label, components, headingLevel) {
15785
16287
  if (components.length > 5) lines.push(`- ...and ${components.length - 5} more`);
15786
16288
  return lines;
15787
16289
  }
15788
- function getIssueAlertRuleFrequency(rule) {
15789
- if (rule.frequency !== void 0 && rule.frequency !== null) return rule.frequency;
15790
- const frequency = rule.config.frequency;
15791
- return typeof frequency === "number" ? frequency : null;
15792
- }
15793
- function formatIssueAlertRule(rule, projectSlug$1, options = {}) {
15794
- const headingLevel = options.headingLevel ?? 2;
15795
- const includeComponents = options.includeComponents ?? true;
15796
- const heading = "#".repeat(Math.min(headingLevel, 6));
15797
- const owner = rule.owner ? formatActor(rule.owner) : null;
15798
- const frequency = getIssueAlertRuleFrequency(rule);
15799
- const lines = compactLines([
15800
- `${heading} ${rule.name}`,
15801
- "",
15802
- `**Kind**: Issue Alert`,
15803
- `**ID**: ${formatId(rule.id)}`,
15804
- `**Project**: ${projectSlug$1}`,
15805
- rule.status ? `**Status**: ${rule.status}` : rule.enabled !== void 0 ? `**Status**: ${rule.enabled ? "enabled" : "disabled"}` : null,
15806
- rule.actionMatch ? `**Action Match**: ${rule.actionMatch}` : null,
15807
- rule.filterMatch ? `**Filter Match**: ${rule.filterMatch}` : null,
15808
- frequency !== null ? `**Frequency**: ${frequency} minutes` : null,
15809
- rule.environment ? `**Environment**: ${rule.environment}` : null,
15810
- owner ? `**Owner**: ${owner}` : null,
15811
- formatDate(rule.dateCreated) ? `**Created**: ${formatDate(rule.dateCreated)}` : null,
15812
- formatDate(rule.dateUpdated) ? `**Updated**: ${formatDate(rule.dateUpdated)}` : null,
15813
- formatDate(rule.lastTriggered) ? `**Last Triggered**: ${formatDate(rule.lastTriggered)}` : null,
15814
- options.url ? `**URL**: ${options.url}` : null
15815
- ]);
15816
- if (includeComponents) {
15817
- const workflowTriggers = rule.triggers ? [rule.triggers] : [];
15818
- lines.push(...formatComponentSummary("Conditions", rule.conditions, headingLevel + 1), ...formatComponentSummary("Filters", rule.filters, headingLevel + 1), ...formatComponentSummary("Actions", rule.actions, headingLevel + 1), ...formatComponentSummary("Triggers", workflowTriggers, headingLevel + 1), ...formatComponentSummary("Action Filters", rule.actionFilters ?? [], headingLevel + 1));
15819
- }
15820
- return lines.join("\n");
15821
- }
15822
16290
  function formatMetricAlertRule(rule, options = {}) {
15823
16291
  const headingLevel = options.headingLevel ?? 2;
15824
16292
  const includeComponents = options.includeComponents ?? true;
@@ -15844,14 +16312,16 @@ function formatMetricAlertRule(rule, options = {}) {
15844
16312
  if (includeComponents) lines.push(...formatComponentSummary("Triggers", rule.triggers, headingLevel + 1));
15845
16313
  return lines.join("\n");
15846
16314
  }
16315
+ /** Resolve case-insensitive names only when the search results are complete. */
15847
16316
  async function findExactIssueAlertRuleMatches(apiService, params) {
15848
- const rules = await apiService.listIssueAlertRules({
16317
+ const page = await apiService.listIssueAlertRulesPage({
15849
16318
  organizationSlug: params.organizationSlug,
15850
16319
  projectSlug: params.projectSlug,
15851
16320
  query: params.ruleName,
15852
16321
  limit: 100
15853
16322
  });
15854
- return rules.filter((rule) => rule.name.toLowerCase() === params.ruleName.toLowerCase());
16323
+ if (page.nextCursor) throw new UserInputError("Alert name search is incomplete. Find the Alert with find_alert_rules and retry with its numeric ID and explicit kind.");
16324
+ return page.rules.filter((rule) => rule.name.toLowerCase() === params.ruleName.toLowerCase());
15855
16325
  }
15856
16326
  async function findExactMetricAlertRuleMatches(apiService, params) {
15857
16327
  const rules = await apiService.listMetricAlertRules({
@@ -15883,7 +16353,7 @@ async function resolveIssueAlertRule(apiService, params) {
15883
16353
  ruleId: matches[0].id
15884
16354
  });
15885
16355
  if (matches.length > 1) throw new UserInputError(`Multiple issue alert rules named "${params.ruleIdOrName}" were found. Retry with the numeric rule ID.`);
15886
- throw new UserInputError(`Issue alert rule "${params.ruleIdOrName}" was not found in project ${params.projectSlug}.`);
16356
+ throw new UserInputError(`Issue alert rule "${params.ruleIdOrName}" was not found${params.projectSlug ? ` in project ${params.projectSlug}` : ""}.`);
15887
16357
  }
15888
16358
  async function resolveMetricAlertRule(apiService, params) {
15889
16359
  if (isNumericAlertRuleId(params.ruleIdOrName)) try {
@@ -15908,7 +16378,7 @@ async function resolveMetricAlertRule(apiService, params) {
15908
16378
  }
15909
16379
 
15910
16380
  //#endregion
15911
- //#region ../mcp-core/dist/get-alert-rule-WfTdEa_v.js
16381
+ //#region ../mcp-core/dist/get-alert-rule-DOk7Olu5.js
15912
16382
  const AlertRuleKind = z.enum([
15913
16383
  "all",
15914
16384
  "issue",
@@ -15940,7 +16410,8 @@ var get_alert_rule_default = defineTool({
15940
16410
  "<hints>",
15941
16411
  "- Use `kind='issue'` or `kind='metric'` for numeric IDs because issue and metric alerts use separate endpoints.",
15942
16412
  "- With `kind='all'`, a digit-only `ruleIdOrName` is treated as an exact alert rule name.",
15943
- "- Issue alert rules are project-scoped, so `projectSlug` is required when `kind` is `issue`.",
16413
+ "- Issue Alerts are notification workflows and may cover multiple projects or have no connected sources. Omit projectSlug to inspect organization-wide.",
16414
+ "- Issue details include complete conditions, notification actions, connected monitors and project scope. Inaccessible or session-restricted sources are marked explicitly.",
15944
16415
  "</hints>"
15945
16416
  ].join("\n"),
15946
16417
  inputSchema: {
@@ -15963,22 +16434,22 @@ var get_alert_rule_default = defineTool({
15963
16434
  project: { slug: requestedProjectSlug }
15964
16435
  });
15965
16436
  const projectSlug$1 = context$1.constraints.projectSlug ?? requestedProjectSlug;
15966
- if (params.kind === "issue" && !projectSlug$1) throw new UserInputError("projectSlug is required when inspecting an issue alert rule.");
15967
16437
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
15968
16438
  const organizationSlug = params.organizationSlug;
15969
- setTag("organization.slug", organizationSlug);
16439
+ setOrganizationContext(organizationSlug);
15970
16440
  if (projectSlug$1) setTag("project.slug", projectSlug$1);
16441
+ const warnings = [];
15971
16442
  let match;
15972
16443
  if (params.kind === "issue") {
15973
16444
  const rule = await resolveIssueAlertRule(apiService, {
15974
16445
  organizationSlug,
15975
- projectSlug: projectSlug$1 ?? "",
16446
+ projectSlug: projectSlug$1,
15976
16447
  ruleIdOrName: params.ruleIdOrName
15977
16448
  });
15978
16449
  match = {
15979
16450
  kind: "issue",
15980
16451
  rule,
15981
- projectSlug: projectSlug$1 ?? ""
16452
+ projectSlug: projectSlug$1
15982
16453
  };
15983
16454
  } else if (params.kind === "metric") {
15984
16455
  const rule = await resolveMetricAlertRule(apiService, {
@@ -15994,31 +16465,34 @@ var get_alert_rule_default = defineTool({
15994
16465
  };
15995
16466
  } else {
15996
16467
  const matches = [];
15997
- if (projectSlug$1) {
15998
- const issueRules = await apiService.listIssueAlertRules({
16468
+ const issueRules = await findExactIssueAlertRuleMatches(apiService, {
16469
+ organizationSlug,
16470
+ projectSlug: projectSlug$1,
16471
+ ruleName: params.ruleIdOrName
16472
+ });
16473
+ matches.push(...issueRules.map((rule) => ({
16474
+ kind: "issue",
16475
+ rule,
16476
+ projectSlug: projectSlug$1
16477
+ })));
16478
+ try {
16479
+ const metricPage = await apiService.listMetricAlertRulesPage({
15999
16480
  organizationSlug,
16000
16481
  projectSlug: projectSlug$1,
16001
16482
  query: params.ruleIdOrName,
16002
16483
  limit: 100
16003
16484
  });
16004
- matches.push(...issueRules.filter((rule) => rule.name.toLowerCase() === params.ruleIdOrName.toLowerCase()).map((rule) => ({
16005
- kind: "issue",
16485
+ if (metricPage.nextCursor) throw new UserInputError("Alert name search is incomplete. Find the Alert with find_alert_rules and retry with its numeric ID and explicit kind.");
16486
+ matches.push(...metricPage.rules.filter((rule) => rule.name.toLowerCase() === params.ruleIdOrName.toLowerCase()).map((rule) => ({
16487
+ kind: "metric",
16006
16488
  rule,
16007
16489
  projectSlug: projectSlug$1
16008
16490
  })));
16491
+ } catch (error) {
16492
+ if (!(error instanceof ApiClientError) || error.status !== 410) throw error;
16493
+ warnings.push("Metric alert lookup is unavailable because the legacy API has been retired. Only issue Alerts were searched.");
16009
16494
  }
16010
- const metricRules = await apiService.listMetricAlertRules({
16011
- organizationSlug,
16012
- projectSlug: projectSlug$1,
16013
- query: params.ruleIdOrName,
16014
- limit: 100
16015
- });
16016
- matches.push(...metricRules.filter((rule) => rule.name.toLowerCase() === params.ruleIdOrName.toLowerCase()).map((rule) => ({
16017
- kind: "metric",
16018
- rule,
16019
- projectSlug: projectSlug$1
16020
- })));
16021
- if (matches.length === 0) throw new UserInputError(`Alert rule "${params.ruleIdOrName}" was not found.`);
16495
+ if (matches.length === 0) throw new UserInputError(`Alert rule "${params.ruleIdOrName}" was not found.${warnings.length ? ` ${warnings.join(" ")}` : ""}`);
16022
16496
  if (matches.length > 1) throw new UserInputError(`Multiple alert rules named "${params.ruleIdOrName}" were found: ${matches.map(describeMatch).join(", ")}. Retry with the numeric rule ID and explicit kind.`);
16023
16497
  const [found] = matches;
16024
16498
  match = found.kind === "issue" ? {
@@ -16037,9 +16511,13 @@ var get_alert_rule_default = defineTool({
16037
16511
  };
16038
16512
  if (match.kind === "metric") assertMetricAlertRuleWithinProject(match.rule, match.projectSlug);
16039
16513
  }
16514
+ if (match.kind === "issue") return structuredResult({
16515
+ alertRule: await getAlertRuleDetails(apiService, organizationSlug, match.rule, context$1.constraints.projectSlug),
16516
+ ...warnings.length ? { warnings } : {}
16517
+ });
16040
16518
  const scopeLabel = projectSlug$1 ? `${organizationSlug}/${projectSlug$1}` : organizationSlug;
16041
16519
  let output = `# Alert Rule in **${scopeLabel}**\n\n`;
16042
- output += match.kind === "issue" ? formatIssueAlertRule(match.rule, match.projectSlug, { url: apiService.getIssueAlertRuleUrl(organizationSlug, match.rule.id) }) : formatMetricAlertRule(match.rule, { url: apiService.getMetricAlertRuleUrl(organizationSlug, match.rule.id) });
16520
+ output += formatMetricAlertRule(match.rule, { url: apiService.getMetricAlertRuleUrl(organizationSlug, match.rule.id) });
16043
16521
  output += "\n\n## Response Notes\n\n";
16044
16522
  output += "- Use these details to inspect alert conditions, filters, routing, and notification actions before changing the rule in Sentry.\n";
16045
16523
  return output;
@@ -16047,7 +16525,203 @@ var get_alert_rule_default = defineTool({
16047
16525
  });
16048
16526
 
16049
16527
  //#endregion
16050
- //#region ../mcp-core/dist/tool-call-formatting-ALc98KqF.js
16528
+ //#region ../mcp-core/dist/get-alert-options-DaJVqiFn.js
16529
+ const sectionSchema = z.enum([
16530
+ "actions",
16531
+ "conditions",
16532
+ "sources"
16533
+ ]);
16534
+ const conditionGroupSchema = z.enum(["workflow_trigger", "action_filter"]);
16535
+ const getAlertOptionsOutputSchema = z.object({
16536
+ section: sectionSchema,
16537
+ actions: z.array(AlertActionOptionSchema).optional(),
16538
+ conditions: z.array(AlertConditionOptionSchema).optional(),
16539
+ conditionGroup: conditionGroupSchema.optional(),
16540
+ sources: z.array(z.object({
16541
+ id: z.string(),
16542
+ name: z.string(),
16543
+ type: z.string(),
16544
+ projectId: z.string().nullable(),
16545
+ enabled: z.boolean(),
16546
+ workflowIds: z.array(z.string())
16547
+ })).optional(),
16548
+ nextCursor: z.string().nullable(),
16549
+ inputGuide: z.object({
16550
+ schemaFormat: z.string(),
16551
+ fieldNames: z.record(z.string(), z.string()),
16552
+ targetTypes: z.record(z.string(), z.string()),
16553
+ notes: z.array(z.string())
16554
+ }).optional()
16555
+ });
16556
+ var get_alert_options_default = defineTool({
16557
+ name: "get_alert_options",
16558
+ skills: ["inspect"],
16559
+ requiredScopes: ["org:read", "project:read"],
16560
+ description: [
16561
+ "Discover available actions, conditions, or sources for a Sentry Alert (notification workflow).",
16562
+ "",
16563
+ "Choose one section per call; reuse its cursor with the same section and filters.",
16564
+ "- actions: installed integrations, notification services, native config/data schemas and Sentry App settings. These schemas use Sentry's internal field names and target enums; inputGuide explains the update format.",
16565
+ "- conditions: condition types and comparison schemas for workflow triggers or action filters.",
16566
+ "- sources: accessible monitors and project issue streams. Use an issue_stream source to connect all issues from its project; a source with projectId=null covers all projects.",
16567
+ "Slack and Teams accept channel names; Discord needs a channel ID or URL. Dynamic Sentry App fields require explicit values; this tool does not enumerate their external choices.",
16568
+ "",
16569
+ "<examples>",
16570
+ "get_alert_options(organizationSlug='my-org', section='actions', actionTypes=['slack', 'msteams'])",
16571
+ "get_alert_options(organizationSlug='my-org', section='conditions', conditionGroup='action_filter')",
16572
+ "get_alert_options(organizationSlug='my-org', section='sources', projectSlug='backend', sourceTypes=['issue_stream'])",
16573
+ "</examples>"
16574
+ ].join("\n"),
16575
+ inputSchema: {
16576
+ organizationSlug: ParamOrganizationSlug,
16577
+ regionUrl: ParamRegionUrl.nullable().default(null),
16578
+ section: sectionSchema.describe("The kind of Alert options to discover."),
16579
+ actionTypes: z.array(z.string().trim().min(1)).max(20).nullable().default(null).describe("Actions only: restrict to action types, such as slack, msteams, email, or pagerduty."),
16580
+ conditionGroup: conditionGroupSchema.nullable().default(null).describe("Required for conditions: workflow_trigger for Alert triggers, action_filter for action groups."),
16581
+ projectSlug: ParamProjectSlugOrAll.nullable().default(null),
16582
+ sourceTypes: z.array(z.string().trim().min(1)).max(20).nullable().default(null).describe("Sources only: restrict by monitor type, such as issue_stream or metric_issue."),
16583
+ query: z.string().trim().min(1).nullable().default(null).describe("Sources only: Sentry monitor search, such as name:latency or workflow:123."),
16584
+ cursor: z.string().nullable().default(null).describe("Next cursor from the same section and filters."),
16585
+ limit: z.number().int().min(1).max(100).default(25).describe("Maximum options to return in this page.")
16586
+ },
16587
+ outputSchema: getAlertOptionsOutputSchema,
16588
+ annotations: {
16589
+ readOnlyHint: true,
16590
+ destructiveHint: false,
16591
+ openWorldHint: true
16592
+ },
16593
+ async handler(params, context$1) {
16594
+ const { section, organizationSlug } = params;
16595
+ if (params.actionTypes !== null && section !== "actions") throw new UserInputError("actionTypes can only be used with section='actions'.");
16596
+ if (params.conditionGroup !== null && section !== "conditions") throw new UserInputError("conditionGroup can only be used with section='conditions'.");
16597
+ if ((params.sourceTypes !== null || params.query !== null) && section !== "sources") throw new UserInputError("sourceTypes and query can only be used with section='sources'.");
16598
+ const api = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
16599
+ setOrganizationContext(organizationSlug);
16600
+ const pageParams = {
16601
+ organizationSlug,
16602
+ cursor: params.cursor ?? void 0,
16603
+ limit: params.limit
16604
+ };
16605
+ if (section === "actions") {
16606
+ const page$1 = await api.listAvailableAlertActionsPage({
16607
+ ...pageParams,
16608
+ types: params.actionTypes ?? void 0
16609
+ });
16610
+ return structuredResult({
16611
+ section,
16612
+ ...page$1,
16613
+ inputGuide: {
16614
+ schemaFormat: "Sentry-native schemas; workflow action inputs use camelCase fields and string target types.",
16615
+ fieldNames: {
16616
+ target_identifier: "targetIdentifier",
16617
+ target_display: "targetDisplay",
16618
+ target_type: "targetType",
16619
+ fallthrough_type: "fallthroughType"
16620
+ },
16621
+ targetTypes: {
16622
+ "0": "specific",
16623
+ "1": "user",
16624
+ "2": "team",
16625
+ "3": "sentry_app",
16626
+ "4": "issue_owners"
16627
+ },
16628
+ notes: [
16629
+ "Integration actions also require integrationId; choose a returned integration and service ID when applicable.",
16630
+ "Email team IDs can be found with find_teams; member destinations require a user ID.",
16631
+ "Sentry App settings include static field choices. Dynamic fields require explicit values; preserve existing settings when editing unrelated fields."
16632
+ ]
16633
+ }
16634
+ });
16635
+ }
16636
+ if (section === "conditions") {
16637
+ if (!params.conditionGroup) throw new UserInputError("conditionGroup is required with section='conditions'.");
16638
+ return structuredResult({
16639
+ section,
16640
+ conditionGroup: params.conditionGroup,
16641
+ ...await api.listAlertConditionsPage({
16642
+ ...pageParams,
16643
+ group: params.conditionGroup
16644
+ })
16645
+ });
16646
+ }
16647
+ const requestedProjectSlug = params.projectSlug && params.projectSlug !== "all" ? params.projectSlug : void 0;
16648
+ if (requestedProjectSlug) assertProjectRefWithinConstraint({
16649
+ resourceLabel: "Alert source",
16650
+ scopedProjectSlug: context$1.constraints.projectSlug,
16651
+ project: { slug: requestedProjectSlug }
16652
+ });
16653
+ const projectSlug$1 = context$1.constraints.projectSlug ?? requestedProjectSlug;
16654
+ const project = projectSlug$1 ? await api.getProject({
16655
+ organizationSlug,
16656
+ projectSlugOrId: projectSlug$1
16657
+ }) : void 0;
16658
+ const page = await api.listDetectorsPage({
16659
+ ...pageParams,
16660
+ projectId: project ? String(project.id) : void 0,
16661
+ types: params.sourceTypes ?? void 0,
16662
+ query: params.query ?? void 0
16663
+ });
16664
+ return structuredResult({
16665
+ section,
16666
+ sources: page.detectors.filter((detector) => !project || detector.projectId === String(project.id)).map((detector) => ({
16667
+ id: detector.id,
16668
+ name: detector.name,
16669
+ type: detector.type,
16670
+ projectId: detector.projectId,
16671
+ enabled: detector.enabled,
16672
+ workflowIds: detector.workflowIds ?? []
16673
+ })),
16674
+ nextCursor: page.nextCursor
16675
+ });
16676
+ }
16677
+ });
16678
+
16679
+ //#endregion
16680
+ //#region ../mcp-core/dist/enhance-error-C-IasWwg.js
16681
+ /**
16682
+ * Enhances a 404 error with parameter context to help users understand what went wrong.
16683
+ * This is optional - tools can use this when they want to provide extra context.
16684
+ *
16685
+ * @example
16686
+ * ```typescript
16687
+ * try {
16688
+ * const issue = await apiService.getIssue({ organizationSlug, issueId });
16689
+ * } catch (error) {
16690
+ * if (error instanceof ApiNotFoundError) {
16691
+ * throw enhanceNotFoundError(error, { organizationSlug, issueId });
16692
+ * }
16693
+ * throw error;
16694
+ * }
16695
+ * ```
16696
+ */
16697
+ function enhanceNotFoundError(error, params) {
16698
+ const paramsList = [];
16699
+ for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null && value !== "") paramsList.push(`${key}: '${value}'`);
16700
+ if (paramsList.length > 0) {
16701
+ const enhancedMessage = `${error.message}\nPlease verify these parameters are correct:\n${paramsList.map((p) => ` - ${p}`).join("\n")}`;
16702
+ return new ApiNotFoundError(enhancedMessage, error.detail, error.responseBody);
16703
+ }
16704
+ return error;
16705
+ }
16706
+
16707
+ //#endregion
16708
+ //#region ../mcp-core/dist/code-location-B3p1xz3c.js
16709
+ /** Formats a verified source location for the issue-details response. */
16710
+ function formatCodeLocation(codeLocation) {
16711
+ const output = ["## Code Location", ""];
16712
+ if (codeLocation.repository) output.push(`**Repository**: ${codeLocation.repository}`);
16713
+ if (codeLocation.path) output.push(`**Path**: ${codeLocation.path}`);
16714
+ if (codeLocation.line !== void 0) output.push(`**Line**: ${codeLocation.line}`);
16715
+ output.push(`**Source**: ${codeLocation.url}`, "");
16716
+ return `${output.join("\n")}\n`;
16717
+ }
16718
+ /** Selects Sentry's most relevant application frame: the last in-app frame. */
16719
+ function findMostRelevantInAppFrame(frames) {
16720
+ return frames.findLast((frame) => frame.inApp === true);
16721
+ }
16722
+
16723
+ //#endregion
16724
+ //#region ../mcp-core/dist/tool-call-formatting-DQggqUN_.js
16051
16725
  function formatArgumentValue(value) {
16052
16726
  if (typeof value === "string") return `'${value.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}'`;
16053
16727
  if (Array.isArray(value) || typeof value === "object") return JSON.stringify(value);
@@ -16100,7 +16774,7 @@ function formatAvailableToolCallInstruction({ toolName, experimentalMode, purpos
16100
16774
  }
16101
16775
 
16102
16776
  //#endregion
16103
- //#region ../mcp-core/dist/ai-conversation-actions-rbKawWyG.js
16777
+ //#region ../mcp-core/dist/ai-conversation-actions-CLccuTm5.js
16104
16778
  const MAX_SUGGESTED_ACTIONS = 3;
16105
16779
  function formatInlineCode$1(value) {
16106
16780
  const backtickRuns = value.match(/`+/g) ?? [];
@@ -16152,179 +16826,9 @@ function formatAIConversationActionInstructions({ organizationSlug, aiConversati
16152
16826
  arguments: action.arguments
16153
16827
  }))} to fetch the full transcript.`);
16154
16828
  }
16155
- /**
16156
- * Adds concrete transcript follow-ups to otherwise markdown-first results.
16157
- * The markdown remains the compatibility path for clients that do not read
16158
- * structured content.
16159
- */
16160
- function addAIConversationSuggestedActions({ markdown, organizationSlug, aiConversations, experimentalMode, availableToolNames, directToolNames }) {
16161
- const suggestedActions = getAIConversationSuggestedActions({
16162
- organizationSlug,
16163
- aiConversations,
16164
- experimentalMode,
16165
- availableToolNames,
16166
- directToolNames
16167
- });
16168
- if (suggestedActions.length === 0) return markdown;
16169
- return {
16170
- content: [{
16171
- type: "text",
16172
- text: markdown
16173
- }],
16174
- structuredContent: { suggestedActions }
16175
- };
16176
- }
16177
16829
 
16178
16830
  //#endregion
16179
- //#region ../mcp-core/dist/enhance-error-BDXGhe5E.js
16180
- /**
16181
- * Enhances a 404 error with parameter context to help users understand what went wrong.
16182
- * This is optional - tools can use this when they want to provide extra context.
16183
- *
16184
- * @example
16185
- * ```typescript
16186
- * try {
16187
- * const issue = await apiService.getIssue({ organizationSlug, issueId });
16188
- * } catch (error) {
16189
- * if (error instanceof ApiNotFoundError) {
16190
- * throw enhanceNotFoundError(error, { organizationSlug, issueId });
16191
- * }
16192
- * throw error;
16193
- * }
16194
- * ```
16195
- */
16196
- function enhanceNotFoundError(error, params) {
16197
- const paramsList = [];
16198
- for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null && value !== "") paramsList.push(`${key}: '${value}'`);
16199
- if (paramsList.length > 0) {
16200
- const enhancedMessage = `${error.message}\nPlease verify these parameters are correct:\n${paramsList.map((p) => ` - ${p}`).join("\n")}`;
16201
- return new ApiNotFoundError(enhancedMessage, error.detail, error.responseBody);
16202
- }
16203
- return error;
16204
- }
16205
-
16206
- //#endregion
16207
- //#region ../mcp-core/dist/url-scope-CRM5sNo7.js
16208
- function resolveScopedOrganizationSlug({ resourceLabel, scopedOrganizationSlug, urlOrganizationSlug }) {
16209
- if (!scopedOrganizationSlug) return urlOrganizationSlug;
16210
- if (scopedOrganizationSlug !== urlOrganizationSlug) throw new UserInputError(`${resourceLabel} URL is outside the active organization constraint. Expected organization "${scopedOrganizationSlug}" but got "${urlOrganizationSlug}".`);
16211
- return scopedOrganizationSlug;
16212
- }
16213
- function resolveScopedProjectSlug({ resourceLabel, scopedProjectSlug, urlProjectSlug }) {
16214
- if (!scopedProjectSlug) return urlProjectSlug;
16215
- if (scopedProjectSlug !== urlProjectSlug) throw new UserInputError(`${resourceLabel} URL is outside the active project constraint. Expected project "${scopedProjectSlug}" but got "${urlProjectSlug}".`);
16216
- return scopedProjectSlug;
16217
- }
16218
- function assertScopedProjectSlug({ resourceLabel, scopedProjectSlug, actualProjectSlug }) {
16219
- if (!scopedProjectSlug) return actualProjectSlug;
16220
- if (scopedProjectSlug !== actualProjectSlug) throw new UserInputError(`${resourceLabel} is outside the active project constraint. Expected project "${scopedProjectSlug}".`);
16221
- return actualProjectSlug;
16222
- }
16223
- function resolveScopedProjectSlugOrId({ resourceLabel, scopedProjectSlugOrId, urlProjectSlug }) {
16224
- if (scopedProjectSlugOrId == null || typeof scopedProjectSlugOrId === "string" && scopedProjectSlugOrId.trim() === "") return urlProjectSlug;
16225
- if (typeof scopedProjectSlugOrId === "number" || isNumericId(String(scopedProjectSlugOrId))) return urlProjectSlug;
16226
- if (scopedProjectSlugOrId !== urlProjectSlug) throw new UserInputError(`${resourceLabel} URL is outside the active project constraint. Expected project "${scopedProjectSlugOrId}" but got "${urlProjectSlug}".`);
16227
- return scopedProjectSlugOrId;
16228
- }
16229
-
16230
- //#endregion
16231
- //#region ../mcp-core/dist/issue-helpers-0Dnme3Ym.js
16232
- /**
16233
- * Extracts the Sentry issue ID and organization slug from a full URL
16234
- *
16235
- * @param url - A full Sentry issue URL
16236
- * @returns Object containing the numeric issue ID and organization slug (if found)
16237
- * @throws Error if the input is invalid
16238
- */
16239
- function extractIssueId(url) {
16240
- if (!url || typeof url !== "string") throw new UserInputError("Invalid Sentry issue URL. URL must be a non-empty string.");
16241
- if (!url.startsWith("http://") && !url.startsWith("https://")) throw new UserInputError("Invalid Sentry issue URL. Must start with http:// or https://");
16242
- let parsedUrl;
16243
- try {
16244
- parsedUrl = new URL(url);
16245
- } catch (error) {
16246
- throw new UserInputError(`Invalid Sentry issue URL. Unable to parse URL: ${url}`);
16247
- }
16248
- const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
16249
- if (pathParts.length < 2 || !pathParts.includes("issues")) throw new UserInputError("Invalid Sentry issue URL. Path must contain '/issues/{issue_id}'");
16250
- const issueId = pathParts[pathParts.indexOf("issues") + 1];
16251
- if (!issueId) throw new UserInputError("Unable to determine issue ID from URL.");
16252
- let organizationSlug;
16253
- if (pathParts.includes("organizations")) organizationSlug = pathParts[pathParts.indexOf("organizations") + 1];
16254
- else if (pathParts.length > 1 && pathParts[0] !== "issues") organizationSlug = pathParts[0];
16255
- else {
16256
- const hostParts = parsedUrl.hostname.split(".");
16257
- if (hostParts.length > 2 && hostParts[0] !== "www") organizationSlug = hostParts[0];
16258
- }
16259
- if (!organizationSlug) throw new UserInputError("Invalid Sentry issue URL. Could not determine organization.");
16260
- return {
16261
- issueId,
16262
- organizationSlug
16263
- };
16264
- }
16265
- /**
16266
- * Sometimes the LLM will pass in a funky issue shortId. For example it might pass
16267
- * in "CLOUDFLARE-MCP-41." instead of "CLOUDFLARE-MCP-41". This function attempts to
16268
- * fix common issues.
16269
- *
16270
- * @param issueId - The issue ID to parse
16271
- * @returns The parsed issue ID
16272
- */
16273
- function parseIssueId(issueId) {
16274
- if (!issueId.trim()) throw new UserInputError("Issue ID cannot be empty");
16275
- let finalIssueId = issueId;
16276
- finalIssueId = finalIssueId.replace(/[^\w-]/g, "");
16277
- if (!finalIssueId) throw new UserInputError("Issue ID cannot be empty after removing special characters");
16278
- const validFormatRegex = /^(\d+|[A-Za-z0-9][\w-]*-[A-Za-z0-9]+)$/;
16279
- if (!validFormatRegex.test(finalIssueId)) throw new UserInputError(`Invalid issue ID format: "${finalIssueId}". Expected either a numeric ID or a project code followed by an alphanumeric identifier (e.g., "PROJECT-ABC123").`);
16280
- return finalIssueId;
16281
- }
16282
- /**
16283
- * Parses issue parameters from a variety of formats.
16284
- *
16285
- * @param params - Object containing issue URL, issue ID, and organization slug
16286
- * @returns Object containing the parsed organization slug and issue ID
16287
- * @throws Error if the input is invalid
16288
- */
16289
- function parseIssueParams({ issueUrl, issueId, organizationSlug }) {
16290
- if (issueUrl) {
16291
- const resolved = extractIssueId(issueUrl);
16292
- if (!resolved) throw new Error("Invalid Sentry issue URL. Path should contain '/issues/{issue_id}'");
16293
- return {
16294
- organizationSlug: resolveScopedOrganizationSlug({
16295
- resourceLabel: "Issue",
16296
- scopedOrganizationSlug: organizationSlug,
16297
- urlOrganizationSlug: resolved.organizationSlug
16298
- }),
16299
- issueId: parseIssueId(resolved.issueId)
16300
- };
16301
- }
16302
- if (!organizationSlug) throw new UserInputError("Organization slug is required");
16303
- if (issueId) return {
16304
- organizationSlug,
16305
- issueId: parseIssueId(issueId)
16306
- };
16307
- throw new UserInputError("Either issueId or issueUrl must be provided");
16308
- }
16309
-
16310
- //#endregion
16311
- //#region ../mcp-core/dist/code-location-DW_YNpMG.js
16312
- /** Formats a verified source location for the issue-details response. */
16313
- function formatCodeLocation(codeLocation) {
16314
- const output = ["## Code Location", ""];
16315
- if (codeLocation.repository) output.push(`**Repository**: ${codeLocation.repository}`);
16316
- if (codeLocation.path) output.push(`**Path**: ${codeLocation.path}`);
16317
- if (codeLocation.line !== void 0) output.push(`**Line**: ${codeLocation.line}`);
16318
- output.push(`**Source**: ${codeLocation.url}`, "");
16319
- return `${output.join("\n")}\n`;
16320
- }
16321
- /** Selects Sentry's most relevant application frame: the last in-app frame. */
16322
- function findMostRelevantInAppFrame(frames) {
16323
- return frames.findLast((frame) => frame.inApp === true);
16324
- }
16325
-
16326
- //#endregion
16327
- //#region ../mcp-core/dist/seer-BoTKAK7k.js
16831
+ //#region ../mcp-core/dist/seer-DqLgmvV9.js
16328
16832
  const SEER_POLLING_INTERVAL = 5e3;
16329
16833
  const SEER_TIMEOUT = 5 * 60 * 1e3;
16330
16834
  const SEER_MAX_RETRIES = 3;
@@ -16389,6 +16893,19 @@ function wrapSeerAnalysisOutput({ output, runId, step, includeProvenanceTags })
16389
16893
  const attrs = [runId === void 0 ? null : `run_id="${escapeXmlAttribute(runId)}"`, `step="${escapeXmlAttribute(step)}"`].filter(Boolean);
16390
16894
  return `<seer_analysis ${attrs.join(" ")}>\n${output.trimEnd()}\n</seer_analysis>\n`;
16391
16895
  }
16896
+ /**
16897
+ * Wraps shared-formatter Seer analysis content in the provenance boundary,
16898
+ * mirroring the tags getOutputForAutofixRun applies to MCP-rendered output.
16899
+ * Seer content is LLM-generated, so it must be marked as untrusted data.
16900
+ */
16901
+ function wrapSeerContent(content, runId) {
16902
+ return wrapSeerAnalysisOutput({
16903
+ output: content,
16904
+ runId,
16905
+ step: "analysis",
16906
+ includeProvenanceTags: true
16907
+ });
16908
+ }
16392
16909
  const RootCauseArtifactDataSchema = z.object({
16393
16910
  one_line_description: z.string().optional(),
16394
16911
  five_whys: z.array(z.string()).default([]),
@@ -16489,7 +17006,7 @@ function getActiveAutofixTodo(autofix) {
16489
17006
  }
16490
17007
 
16491
17008
  //#endregion
16492
- //#region ../mcp-core/dist/user-formatting-BrX0Xi05.js
17009
+ //#region ../mcp-core/dist/user-formatting-CTX3nhjo.js
16493
17010
  function formatUserGeoSummary(value) {
16494
17011
  if (!isPlainObject$3(value)) return null;
16495
17012
  const parts = [
@@ -16503,7 +17020,7 @@ function formatUserGeoSummary(value) {
16503
17020
  }
16504
17021
 
16505
17022
  //#endregion
16506
- //#region ../mcp-core/dist/formatting-Cviy8-dX.js
17023
+ //#region ../mcp-core/dist/formatting-31tlKXsb.js
16507
17024
  /**
16508
17025
  * Convert Seer fixability score to actionability label.
16509
17026
  * Thresholds match Sentry core: src/sentry/seer/autofix/constants.py
@@ -16597,6 +17114,29 @@ function formatFrameHeader(frame, frameIndex, platform) {
16597
17114
  }
16598
17115
  }
16599
17116
  /**
17117
+ * Whether the shared formatter covers this event type, and so whether its body should be used
17118
+ * instead of the local rendering.
17119
+ *
17120
+ * "default" is an error event without exception data, "generic" a performance regression or
17121
+ * metric issue, "csp" a Content Security Policy violation. Anything else (a transaction, most
17122
+ * notably) keeps the local path, which renders things the shared body does not carry such as
17123
+ * the fetched performance trace.
17124
+ */
17125
+ /**
17126
+ * Whether to read the issue's metadata instead of its top level fields. Performance issues can
17127
+ * have various categories such as 'db_query', but the issueType starts with 'performance_'.
17128
+ *
17129
+ * It matters which side of this an issue falls on: metadata.value is a query pattern for a
17130
+ * performance issue and the exception message for an error, so reading it unconditionally
17131
+ * misnames the error text.
17132
+ */
17133
+ function isPerformanceIssueType(issue) {
17134
+ return issue.issueType?.startsWith("performance_") === true || issue.issueCategory === "performance";
17135
+ }
17136
+ function usesSharedFormatterBody(event) {
17137
+ return event.type === "error" || event.type === "default" || event.type === "generic" || event.type === "csp";
17138
+ }
17139
+ /**
16600
17140
  * Formats a Sentry event into a structured markdown output.
16601
17141
  * Includes error messages, stack traces, request info, and contextual data.
16602
17142
  *
@@ -17538,14 +18078,17 @@ function formatSeerSummary(autofixState) {
17538
18078
  parts.push(`**Status:** ${getStatusDisplayName(autofix.status)}`);
17539
18079
  parts.push("");
17540
18080
  }
17541
- const { rootCause, solution } = getAutofixArtifactSummaries(autofix);
17542
- if (solution) {
17543
- parts.push("**Summary:**");
17544
- parts.push(solution);
17545
- } else if (rootCause) {
17546
- parts.push("**Root Cause Identified:**");
17547
- parts.push(rootCause);
17548
- } else if (!isTerminalStatus(autofix.status)) parts.push("Analysis has started but no results yet.");
18081
+ if (autofixState.formatted?.content) parts.push(wrapSeerContent(autofixState.formatted.content, autofix.run_id));
18082
+ else {
18083
+ const { rootCause, solution } = getAutofixArtifactSummaries(autofix);
18084
+ if (solution) {
18085
+ parts.push("**Summary:**");
18086
+ parts.push(solution);
18087
+ } else if (rootCause) {
18088
+ parts.push("**Root Cause Identified:**");
18089
+ parts.push(rootCause);
18090
+ } else if (!isTerminalStatus(autofix.status)) parts.push("Analysis has started but no results yet.");
18091
+ }
17549
18092
  if (autofix.status === "error") {
17550
18093
  parts.push("");
17551
18094
  parts.push("**Status:** Analysis failed.");
@@ -17564,7 +18107,7 @@ function formatSeerSummary(autofixState) {
17564
18107
  */
17565
18108
  function formatIssueOutput({ organizationSlug, issue, event, apiService, autofixState, performanceTrace, externalIssues, relatedReplayIds, aiConversations, codeLocation, experimentalMode, availableToolNames, directToolNames }) {
17566
18109
  let output = `# Issue ${issue.shortId} in **${organizationSlug}**\n\n`;
17567
- const isPerformanceIssue = issue.issueType?.startsWith("performance_") || issue.issueCategory === "performance";
18110
+ const isPerformanceIssue = isPerformanceIssueType(issue);
17568
18111
  if (isPerformanceIssue && issue.metadata) {
17569
18112
  const issueTitle = issue.metadata.title || issue.title;
17570
18113
  output += `**Description**: ${issueTitle}\n`;
@@ -17627,13 +18170,26 @@ function formatIssueOutput({ organizationSlug, issue, event, apiService, autofix
17627
18170
  }
17628
18171
  output += `**Event ID**: ${event.id}\n`;
17629
18172
  output += `**Type**: ${event.type}\n`;
17630
- if (event.type === "error" || event.type === "default" || event.type === "generic" || event.type === "csp") {
18173
+ const isSharedFormatterType = usesSharedFormatterBody(event);
18174
+ if (isSharedFormatterType) {
17631
18175
  const typedEvent = event;
17632
18176
  if (typedEvent.dateCreated) output += `**Occurred At**: ${new Date(typedEvent.dateCreated).toISOString()}\n`;
17633
18177
  }
17634
18178
  if (event.message) output += `**Message**:\n${event.message}\n`;
17635
18179
  output += "\n";
17636
- output += formatEventOutput(event, {
18180
+ if (isSharedFormatterType && event.formatted?.format === "markdown" && event.formatted.content) {
18181
+ output += formatIssueReplayOutput({
18182
+ apiService,
18183
+ organizationSlug,
18184
+ event,
18185
+ relatedReplayIds,
18186
+ experimentalMode: experimentalMode ?? false,
18187
+ availableToolNames,
18188
+ directToolNames
18189
+ });
18190
+ const formattedContent = event.formatted.content;
18191
+ output += formattedContent.endsWith("\n") ? formattedContent : `${formattedContent}\n`;
18192
+ } else output += formatEventOutput(event, {
17637
18193
  performanceTrace,
17638
18194
  replaySummary: {
17639
18195
  apiService,
@@ -17851,7 +18407,111 @@ function stripReplayMetadata(event) {
17851
18407
  }
17852
18408
 
17853
18409
  //#endregion
17854
- //#region ../mcp-core/dist/issue-D65xI0F7.js
18410
+ //#region ../mcp-core/dist/url-scope-V6MOdP9h.js
18411
+ function resolveScopedOrganizationSlug({ resourceLabel, scopedOrganizationSlug, urlOrganizationSlug }) {
18412
+ if (!scopedOrganizationSlug) return urlOrganizationSlug;
18413
+ if (scopedOrganizationSlug !== urlOrganizationSlug) throw new UserInputError(`${resourceLabel} URL is outside the active organization constraint. Expected organization "${scopedOrganizationSlug}" but got "${urlOrganizationSlug}".`);
18414
+ return scopedOrganizationSlug;
18415
+ }
18416
+ function resolveScopedProjectSlug({ resourceLabel, scopedProjectSlug, urlProjectSlug }) {
18417
+ if (!scopedProjectSlug) return urlProjectSlug;
18418
+ if (scopedProjectSlug !== urlProjectSlug) throw new UserInputError(`${resourceLabel} URL is outside the active project constraint. Expected project "${scopedProjectSlug}" but got "${urlProjectSlug}".`);
18419
+ return scopedProjectSlug;
18420
+ }
18421
+ function assertScopedProjectSlug({ resourceLabel, scopedProjectSlug, actualProjectSlug }) {
18422
+ if (!scopedProjectSlug) return actualProjectSlug;
18423
+ if (scopedProjectSlug !== actualProjectSlug) throw new UserInputError(`${resourceLabel} is outside the active project constraint. Expected project "${scopedProjectSlug}".`);
18424
+ return actualProjectSlug;
18425
+ }
18426
+ function resolveScopedProjectSlugOrId({ resourceLabel, scopedProjectSlugOrId, urlProjectSlug }) {
18427
+ if (scopedProjectSlugOrId == null || typeof scopedProjectSlugOrId === "string" && scopedProjectSlugOrId.trim() === "") return urlProjectSlug;
18428
+ if (typeof scopedProjectSlugOrId === "number" || isNumericId(String(scopedProjectSlugOrId))) return urlProjectSlug;
18429
+ if (scopedProjectSlugOrId !== urlProjectSlug) throw new UserInputError(`${resourceLabel} URL is outside the active project constraint. Expected project "${scopedProjectSlugOrId}" but got "${urlProjectSlug}".`);
18430
+ return scopedProjectSlugOrId;
18431
+ }
18432
+
18433
+ //#endregion
18434
+ //#region ../mcp-core/dist/issue-helpers-qGxiGeE5.js
18435
+ /**
18436
+ * Extracts the Sentry issue ID and organization slug from a full URL
18437
+ *
18438
+ * @param url - A full Sentry issue URL
18439
+ * @returns Object containing the numeric issue ID and organization slug (if found)
18440
+ * @throws Error if the input is invalid
18441
+ */
18442
+ function extractIssueId(url) {
18443
+ if (!url || typeof url !== "string") throw new UserInputError("Invalid Sentry issue URL. URL must be a non-empty string.");
18444
+ if (!url.startsWith("http://") && !url.startsWith("https://")) throw new UserInputError("Invalid Sentry issue URL. Must start with http:// or https://");
18445
+ let parsedUrl;
18446
+ try {
18447
+ parsedUrl = new URL(url);
18448
+ } catch (error) {
18449
+ throw new UserInputError(`Invalid Sentry issue URL. Unable to parse URL: ${url}`);
18450
+ }
18451
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
18452
+ if (pathParts.length < 2 || !pathParts.includes("issues")) throw new UserInputError("Invalid Sentry issue URL. Path must contain '/issues/{issue_id}'");
18453
+ const issueId = pathParts[pathParts.indexOf("issues") + 1];
18454
+ if (!issueId) throw new UserInputError("Unable to determine issue ID from URL.");
18455
+ let organizationSlug;
18456
+ if (pathParts.includes("organizations")) organizationSlug = pathParts[pathParts.indexOf("organizations") + 1];
18457
+ else if (pathParts.length > 1 && pathParts[0] !== "issues") organizationSlug = pathParts[0];
18458
+ else {
18459
+ const hostParts = parsedUrl.hostname.split(".");
18460
+ if (hostParts.length > 2 && hostParts[0] !== "www") organizationSlug = hostParts[0];
18461
+ }
18462
+ if (!organizationSlug) throw new UserInputError("Invalid Sentry issue URL. Could not determine organization.");
18463
+ return {
18464
+ issueId,
18465
+ organizationSlug
18466
+ };
18467
+ }
18468
+ /**
18469
+ * Sometimes the LLM will pass in a funky issue shortId. For example it might pass
18470
+ * in "CLOUDFLARE-MCP-41." instead of "CLOUDFLARE-MCP-41". This function attempts to
18471
+ * fix common issues.
18472
+ *
18473
+ * @param issueId - The issue ID to parse
18474
+ * @returns The parsed issue ID
18475
+ */
18476
+ function parseIssueId(issueId) {
18477
+ if (!issueId.trim()) throw new UserInputError("Issue ID cannot be empty");
18478
+ let finalIssueId = issueId;
18479
+ finalIssueId = finalIssueId.replace(/[^\w-]/g, "");
18480
+ if (!finalIssueId) throw new UserInputError("Issue ID cannot be empty after removing special characters");
18481
+ const validFormatRegex = /^(\d+|[A-Za-z0-9][\w-]*-[A-Za-z0-9]+)$/;
18482
+ if (!validFormatRegex.test(finalIssueId)) throw new UserInputError(`Invalid issue ID format: "${finalIssueId}". Expected either a numeric ID or a project code followed by an alphanumeric identifier (e.g., "PROJECT-ABC123").`);
18483
+ return finalIssueId;
18484
+ }
18485
+ /**
18486
+ * Parses issue parameters from a variety of formats.
18487
+ *
18488
+ * @param params - Object containing issue URL, issue ID, and organization slug
18489
+ * @returns Object containing the parsed organization slug and issue ID
18490
+ * @throws Error if the input is invalid
18491
+ */
18492
+ function parseIssueParams({ issueUrl, issueId, organizationSlug }) {
18493
+ if (issueUrl) {
18494
+ const resolved = extractIssueId(issueUrl);
18495
+ if (!resolved) throw new Error("Invalid Sentry issue URL. Path should contain '/issues/{issue_id}'");
18496
+ return {
18497
+ organizationSlug: resolveScopedOrganizationSlug({
18498
+ resourceLabel: "Issue",
18499
+ scopedOrganizationSlug: organizationSlug,
18500
+ urlOrganizationSlug: resolved.organizationSlug
18501
+ }),
18502
+ issueId: parseIssueId(resolved.issueId)
18503
+ };
18504
+ }
18505
+ if (!organizationSlug) throw new UserInputError("Organization slug is required");
18506
+ if (issueId) return {
18507
+ organizationSlug,
18508
+ issueId: parseIssueId(issueId)
18509
+ };
18510
+ throw new UserInputError("Either issueId or issueUrl must be provided");
18511
+ }
18512
+
18513
+ //#endregion
18514
+ //#region ../mcp-core/dist/issue-y4HGWyCn.js
17855
18515
  function assertIssueWithinProjectConstraint({ issue, projectSlug: projectSlug$1, resourceLabel = "Issue" }) {
17856
18516
  assertScopedProjectSlug({
17857
18517
  resourceLabel,
@@ -17873,7 +18533,7 @@ async function ensureIssueWithinProjectConstraint({ apiService, organizationSlug
17873
18533
  }
17874
18534
 
17875
18535
  //#endregion
17876
- //#region ../mcp-core/dist/code-location-C0fIXD0V.js
18536
+ //#region ../mcp-core/dist/code-location-Dh_XFzfu.js
17877
18537
  const CODE_LOCATION_TIMEOUT_MS = 3e3;
17878
18538
  /** Resolves a verified source location, omitting optional enrichment failures. */
17879
18539
  async function resolveCodeLocation({ apiService, organizationSlug, projectSlug: projectSlug$1, event }) {
@@ -17976,10 +18636,174 @@ function getString$1(value) {
17976
18636
  }
17977
18637
 
17978
18638
  //#endregion
17979
- //#region ../mcp-core/dist/get-issue-details-DHDUffp5.js
18639
+ //#region ../mcp-core/dist/get-issue-details-t289hNuc.js
18640
+ const MAX_RELATED_REPLAYS = 5;
17980
18641
  const MAX_AI_CONVERSATION_MATCHES = 3;
17981
18642
  const AI_CONVERSATION_LOOKUP_WINDOW_MS = 24 * 60 * 60 * 1e3;
17982
18643
  const TRACE_ID_PATTERN = /^[0-9a-fA-F]{32}$/;
18644
+ /**
18645
+ * The issue payload as `structuredContent`.
18646
+ *
18647
+ * Every field is mapped explicitly rather than spread from an api response, so a passthrough
18648
+ * upstream schema cannot leak backend-only fields into the public interface.
18649
+ *
18650
+ * `event.body` is the one open record: it is whatever Sentry's shared formatter emits
18651
+ * for `?llmFormat=json`, and its sections are decided there. Enumerating them here would make
18652
+ * this schema a second declaration of that contract, needing a bump every time a section is
18653
+ * added on the Sentry side.
18654
+ */
18655
+ const getIssueDetailsOutputSchema = z.object({
18656
+ issue: z.object({
18657
+ shortId: z.string(),
18658
+ title: z.string(),
18659
+ culprit: z.string().nullish(),
18660
+ firstSeen: z.string().nullish(),
18661
+ lastSeen: z.string().nullish(),
18662
+ occurrences: z.number().nullish(),
18663
+ usersImpacted: z.number().nullish(),
18664
+ status: z.string().nullish(),
18665
+ substatus: z.string().nullish(),
18666
+ assignedTo: z.string().nullish(),
18667
+ issueType: z.string().nullish(),
18668
+ issueCategory: z.string().nullish(),
18669
+ seerActionability: z.string().nullish(),
18670
+ platform: z.string().nullish(),
18671
+ project: z.string().nullish(),
18672
+ url: z.string(),
18673
+ location: z.string().nullish(),
18674
+ queryPattern: z.string().nullish()
18675
+ }),
18676
+ event: z.object({
18677
+ id: z.string(),
18678
+ type: z.string().nullish(),
18679
+ occurredAt: z.string().nullish(),
18680
+ body: z.record(z.string(), z.unknown())
18681
+ }),
18682
+ seer: z.object({
18683
+ status: z.string().nullish(),
18684
+ rootCause: z.string().nullish(),
18685
+ solution: z.string().nullish()
18686
+ }).nullish(),
18687
+ codeLocation: z.object({
18688
+ repository: z.string().nullish(),
18689
+ path: z.string().nullish(),
18690
+ line: z.number().nullish(),
18691
+ url: z.string()
18692
+ }).nullish(),
18693
+ replays: z.object({
18694
+ attached: z.string().nullish(),
18695
+ related: z.array(z.string()),
18696
+ relatedCount: z.number()
18697
+ }).nullish(),
18698
+ externalIssues: z.array(z.object({
18699
+ id: z.string(),
18700
+ issueId: z.string(),
18701
+ serviceType: z.string(),
18702
+ displayName: z.string(),
18703
+ webUrl: z.string()
18704
+ })).nullish(),
18705
+ aiConversations: z.array(z.object({
18706
+ conversationId: z.string(),
18707
+ spanId: z.string().nullish()
18708
+ })).nullish()
18709
+ });
18710
+ /**
18711
+ * Parses the shared formatter's json body. Returns undefined when the caller's org is not on
18712
+ * the rollout yet, which is the signal to keep returning markdown: a structured result has to
18713
+ * carry the whole answer, and without the body it would not.
18714
+ */
18715
+ function parseFormattedBody(event) {
18716
+ if (!usesSharedFormatterBody(event)) return void 0;
18717
+ const content = event.formatted?.content;
18718
+ if (!content) return void 0;
18719
+ try {
18720
+ const parsed = JSON.parse(content);
18721
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
18722
+ } catch {
18723
+ return void 0;
18724
+ }
18725
+ }
18726
+ /**
18727
+ * The attached replay plus the related ones, derived the way the markdown output derives them.
18728
+ * The attached id lives on the event rather than in the related list, so passing that list
18729
+ * through alone loses the replay for an issue whose only one is attached.
18730
+ */
18731
+ /**
18732
+ * ``dateCreated`` sits on the shared-formatter event types rather than the base union, and
18733
+ * the markdown path normalizes it to ISO. Read it the same way and tolerate a bad value.
18734
+ */
18735
+ function eventOccurredAt(event) {
18736
+ const raw = "dateCreated" in event ? event.dateCreated : null;
18737
+ if (typeof raw !== "string") return null;
18738
+ const parsed = new Date(raw);
18739
+ return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
18740
+ }
18741
+ function buildReplays(event, relatedReplayIds) {
18742
+ const attached = getReplayIdFromEvent(event);
18743
+ const related = dedupeReplayIds(relatedReplayIds ?? []).filter((replayId) => replayId !== attached);
18744
+ if (!attached && related.length === 0) return null;
18745
+ return {
18746
+ attached,
18747
+ related: related.slice(0, MAX_RELATED_REPLAYS),
18748
+ relatedCount: related.length
18749
+ };
18750
+ }
18751
+ function buildIssueDetailsPayload({ organizationSlug, issue, event, body, apiService, autofixState, externalIssues, relatedReplayIds, aiConversations, codeLocation }) {
18752
+ const autofix = autofixState?.autofix;
18753
+ const summaries = autofix ? getAutofixArtifactSummaries(autofix) : void 0;
18754
+ const isPerf = isPerformanceIssueType(issue) && !!issue.metadata;
18755
+ return {
18756
+ issue: {
18757
+ shortId: issue.shortId,
18758
+ title: (isPerf ? issue.metadata?.title : null) || issue.title,
18759
+ culprit: issue.culprit,
18760
+ firstSeen: issue.firstSeen,
18761
+ lastSeen: issue.lastSeen,
18762
+ occurrences: issue.count == null ? null : Number(issue.count),
18763
+ usersImpacted: issue.userCount == null ? null : Number(issue.userCount),
18764
+ status: issue.status,
18765
+ substatus: issue.substatus,
18766
+ assignedTo: typeof issue.assignedTo === "string" ? issue.assignedTo : issue.assignedTo?.name,
18767
+ issueType: issue.issueType,
18768
+ issueCategory: issue.issueCategory,
18769
+ seerActionability: issue.seerFixabilityScore == null ? null : getSeerActionabilityLabel(issue.seerFixabilityScore),
18770
+ platform: issue.platform,
18771
+ project: issue.project?.name,
18772
+ url: apiService.getIssueUrl(organizationSlug, issue.shortId),
18773
+ location: isPerf ? issue.metadata?.location : null,
18774
+ queryPattern: isPerf ? issue.metadata?.value : null
18775
+ },
18776
+ event: {
18777
+ id: event.id,
18778
+ type: typeof event.type === "string" ? event.type : null,
18779
+ occurredAt: eventOccurredAt(event),
18780
+ body
18781
+ },
18782
+ seer: autofix ? {
18783
+ status: getStatusDisplayName(autofix.status),
18784
+ rootCause: summaries?.rootCause,
18785
+ solution: summaries?.solution
18786
+ } : null,
18787
+ codeLocation: codeLocation ? {
18788
+ repository: codeLocation.repository,
18789
+ path: codeLocation.path,
18790
+ line: codeLocation.line,
18791
+ url: codeLocation.url
18792
+ } : null,
18793
+ replays: buildReplays(event, relatedReplayIds),
18794
+ externalIssues: externalIssues?.length ? externalIssues.map((issue$1) => ({
18795
+ id: String(issue$1.id),
18796
+ issueId: String(issue$1.issueId),
18797
+ serviceType: issue$1.serviceType,
18798
+ displayName: issue$1.displayName,
18799
+ webUrl: issue$1.webUrl
18800
+ })) : null,
18801
+ aiConversations: aiConversations?.length ? aiConversations.map((conversation) => ({
18802
+ conversationId: conversation.conversationId,
18803
+ spanId: conversation.spanId
18804
+ })) : null
18805
+ };
18806
+ }
17983
18807
  var get_issue_details_default = defineTool({
17984
18808
  name: "get_issue_details",
17985
18809
  skills: [
@@ -18046,7 +18870,7 @@ var get_issue_details_default = defineTool({
18046
18870
  const orgSlug$1 = params.organizationSlug;
18047
18871
  const eventId = params.eventId;
18048
18872
  if (!orgSlug$1) throw new UserInputError("`organizationSlug` is required when providing `eventId`");
18049
- setTag("organization.slug", orgSlug$1);
18873
+ setOrganizationContext(orgSlug$1);
18050
18874
  let issue$1;
18051
18875
  if (params.issueId) issue$1 = await apiService.getIssue({
18052
18876
  organizationSlug: orgSlug$1,
@@ -18057,7 +18881,7 @@ var get_issue_details_default = defineTool({
18057
18881
  organizationSlug: orgSlug$1,
18058
18882
  query: eventId
18059
18883
  });
18060
- if (!found) return `# Event Not Found\n\nNo issue found for Event ID: ${eventId}`;
18884
+ if (!found) throw new UserInputError(`No issue found for Event ID: ${eventId}`);
18061
18885
  issue$1 = found;
18062
18886
  }
18063
18887
  assertIssueWithinProjectConstraint({
@@ -18066,12 +18890,12 @@ var get_issue_details_default = defineTool({
18066
18890
  });
18067
18891
  const [{ event: event$1, performanceTrace: performanceTrace$1, aiConversations: aiConversations$1, codeLocation: codeLocation$1 }, { autofixState: autofixState$1, externalIssues: externalIssues$1, relatedReplayIds: relatedReplayIds$1 }] = await Promise.all([apiService.getEventForIssue({
18068
18892
  organizationSlug: orgSlug$1,
18069
- issueId: issue$1.shortId,
18893
+ issueId: String(issue$1.id),
18070
18894
  eventId
18071
18895
  }).catch((error) => {
18072
18896
  if (error instanceof ApiNotFoundError) throw enhanceNotFoundError(error, {
18073
18897
  organizationSlug: orgSlug$1,
18074
- issueId: issue$1.shortId,
18898
+ issueId: String(issue$1.id),
18075
18899
  eventId
18076
18900
  });
18077
18901
  throw error;
@@ -18089,25 +18913,31 @@ var get_issue_details_default = defineTool({
18089
18913
  issue: issue$1,
18090
18914
  seerEnabled: isSeerGranted(context$1)
18091
18915
  })]);
18092
- return addAIConversationSuggestedActions({
18093
- markdown: formatIssueOutput({
18094
- organizationSlug: orgSlug$1,
18095
- issue: issue$1,
18096
- event: event$1,
18097
- apiService,
18098
- autofixState: autofixState$1,
18099
- performanceTrace: performanceTrace$1,
18100
- externalIssues: externalIssues$1,
18101
- relatedReplayIds: relatedReplayIds$1,
18102
- aiConversations: aiConversations$1,
18103
- codeLocation: codeLocation$1,
18104
- experimentalMode: context$1.experimentalMode,
18105
- availableToolNames: context$1.availableToolNames,
18106
- directToolNames: context$1.directToolNames
18107
- }),
18916
+ const body$1 = parseFormattedBody(event$1);
18917
+ if (body$1) return structuredResult(buildIssueDetailsPayload({
18108
18918
  organizationSlug: orgSlug$1,
18919
+ issue: issue$1,
18920
+ event: event$1,
18921
+ body: body$1,
18922
+ apiService,
18923
+ autofixState: autofixState$1,
18924
+ externalIssues: externalIssues$1,
18925
+ relatedReplayIds: relatedReplayIds$1,
18109
18926
  aiConversations: aiConversations$1,
18110
- experimentalMode: context$1.experimentalMode ?? false,
18927
+ codeLocation: codeLocation$1
18928
+ }));
18929
+ return formatIssueOutput({
18930
+ organizationSlug: orgSlug$1,
18931
+ issue: issue$1,
18932
+ event: event$1,
18933
+ apiService,
18934
+ autofixState: autofixState$1,
18935
+ performanceTrace: performanceTrace$1,
18936
+ externalIssues: externalIssues$1,
18937
+ relatedReplayIds: relatedReplayIds$1,
18938
+ aiConversations: aiConversations$1,
18939
+ codeLocation: codeLocation$1,
18940
+ experimentalMode: context$1.experimentalMode,
18111
18941
  availableToolNames: context$1.availableToolNames,
18112
18942
  directToolNames: context$1.directToolNames
18113
18943
  });
@@ -18119,7 +18949,7 @@ var get_issue_details_default = defineTool({
18119
18949
  issueId: params.issueId,
18120
18950
  issueUrl: params.issueUrl
18121
18951
  });
18122
- setTag("organization.slug", orgSlug);
18952
+ setOrganizationContext(orgSlug);
18123
18953
  let issue;
18124
18954
  try {
18125
18955
  issue = await apiService.getIssue({
@@ -18139,7 +18969,7 @@ var get_issue_details_default = defineTool({
18139
18969
  });
18140
18970
  const [{ event, performanceTrace, aiConversations, codeLocation }, { autofixState, externalIssues, relatedReplayIds }] = await Promise.all([apiService.getLatestEventForIssue({
18141
18971
  organizationSlug: orgSlug,
18142
- issueId: issue.shortId
18972
+ issueId: String(issue.id)
18143
18973
  }).then(async (event$1) => ({
18144
18974
  event: event$1,
18145
18975
  ...await fetchEventEnrichment({
@@ -18154,25 +18984,31 @@ var get_issue_details_default = defineTool({
18154
18984
  issue,
18155
18985
  seerEnabled: isSeerGranted(context$1)
18156
18986
  })]);
18157
- return addAIConversationSuggestedActions({
18158
- markdown: formatIssueOutput({
18159
- organizationSlug: orgSlug,
18160
- issue,
18161
- event,
18162
- apiService,
18163
- autofixState,
18164
- performanceTrace,
18165
- externalIssues,
18166
- relatedReplayIds,
18167
- aiConversations,
18168
- codeLocation,
18169
- experimentalMode: context$1.experimentalMode,
18170
- availableToolNames: context$1.availableToolNames,
18171
- directToolNames: context$1.directToolNames
18172
- }),
18987
+ const body = parseFormattedBody(event);
18988
+ if (body) return structuredResult(buildIssueDetailsPayload({
18173
18989
  organizationSlug: orgSlug,
18990
+ issue,
18991
+ event,
18992
+ body,
18993
+ apiService,
18994
+ autofixState,
18995
+ externalIssues,
18996
+ relatedReplayIds,
18174
18997
  aiConversations,
18175
- experimentalMode: context$1.experimentalMode ?? false,
18998
+ codeLocation
18999
+ }));
19000
+ return formatIssueOutput({
19001
+ organizationSlug: orgSlug,
19002
+ issue,
19003
+ event,
19004
+ apiService,
19005
+ autofixState,
19006
+ performanceTrace,
19007
+ externalIssues,
19008
+ relatedReplayIds,
19009
+ aiConversations,
19010
+ codeLocation,
19011
+ experimentalMode: context$1.experimentalMode,
18176
19012
  availableToolNames: context$1.availableToolNames,
18177
19013
  directToolNames: context$1.directToolNames
18178
19014
  });
@@ -18220,7 +19056,7 @@ async function fetchIssueEnrichmentData({ apiService, organizationSlug, issue, s
18220
19056
  }),
18221
19057
  apiService.getIssueExternalLinks({
18222
19058
  organizationSlug,
18223
- issueId: issue.shortId
19059
+ issueId
18224
19060
  }).catch(() => void 0),
18225
19061
  apiService.listReplayIdsForIssue({
18226
19062
  organizationSlug,
@@ -18250,7 +19086,7 @@ async function maybeFetchAutofixState({ apiService, organizationSlug, issue, see
18250
19086
  if (!seerEnabled) return void 0;
18251
19087
  return apiService.getAutofixState({
18252
19088
  organizationSlug,
18253
- issueId: issue.shortId
19089
+ issueId: String(issue.id)
18254
19090
  }).catch(() => void 0);
18255
19091
  }
18256
19092
  async function maybeFetchPerformanceTrace({ apiService, organizationSlug, event }) {
@@ -18350,7 +19186,7 @@ function getReplayDataSource(issue) {
18350
19186
  }
18351
19187
 
18352
19188
  //#endregion
18353
- //#region ../mcp-core/dist/event-stacktrace-DNVGqkZt.js
19189
+ //#region ../mcp-core/dist/event-stacktrace-WES63IMe.js
18354
19190
  /**
18355
19191
  * Fetches an issue event and formats the selected thread stacktrace.
18356
19192
  */
@@ -18429,7 +19265,7 @@ function selectUnique(threads, predicate, notFoundMessage, ambiguousMessage) {
18429
19265
  }
18430
19266
 
18431
19267
  //#endregion
18432
- //#region ../mcp-core/dist/get-event-stacktrace-ODRk7GSR.js
19268
+ //#region ../mcp-core/dist/get-event-stacktrace-CDGRtbOg.js
18433
19269
  var get_event_stacktrace_default = defineTool({
18434
19270
  name: "get_event_stacktrace",
18435
19271
  skills: [
@@ -18472,7 +19308,7 @@ var get_event_stacktrace_default = defineTool({
18472
19308
  },
18473
19309
  async handler(params, context$1) {
18474
19310
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
18475
- setTag("organization.slug", params.organizationSlug);
19311
+ setOrganizationContext(params.organizationSlug);
18476
19312
  setTag("issue.id", params.issueId);
18477
19313
  try {
18478
19314
  await ensureIssueWithinProjectConstraint({
@@ -18500,7 +19336,7 @@ var get_event_stacktrace_default = defineTool({
18500
19336
  });
18501
19337
 
18502
19338
  //#endregion
18503
- //#region ../mcp-core/dist/get-issue-activity-CKhQWy99.js
19339
+ //#region ../mcp-core/dist/get-issue-activity-DA97QQfR.js
18504
19340
  function getActivityText(activity) {
18505
19341
  const data = activity.data;
18506
19342
  if (!data) return null;
@@ -18550,7 +19386,7 @@ var get_issue_activity_default = defineTool({
18550
19386
  organizationSlug: params.organizationSlug ?? context$1.constraints.organizationSlug
18551
19387
  });
18552
19388
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? context$1.constraints.regionUrl ?? void 0 });
18553
- setTag("organization.slug", parsed.organizationSlug);
19389
+ setOrganizationContext(parsed.organizationSlug);
18554
19390
  setTag("issue.id", parsed.issueId);
18555
19391
  await ensureIssueWithinProjectConstraint({
18556
19392
  apiService,
@@ -18593,7 +19429,7 @@ var get_issue_activity_default = defineTool({
18593
19429
  });
18594
19430
 
18595
19431
  //#endregion
18596
- //#region ../mcp-core/dist/breadcrumbs-BltIlpas.js
19432
+ //#region ../mcp-core/dist/breadcrumbs-uFW9kNaP.js
18597
19433
  /**
18598
19434
  * Fetches breadcrumbs from an issue event and formats them.
18599
19435
  * Defaults to the latest event when eventId is omitted.
@@ -18657,7 +19493,7 @@ function cleanAndTruncate(str, maxLen) {
18657
19493
  }
18658
19494
 
18659
19495
  //#endregion
18660
- //#region ../mcp-core/dist/get-issue-breadcrumbs-D5AeF8Vm.js
19496
+ //#region ../mcp-core/dist/get-issue-breadcrumbs-D-UCFqx1.js
18661
19497
  var get_issue_breadcrumbs_default = defineTool({
18662
19498
  name: "get_issue_breadcrumbs",
18663
19499
  skills: ["inspect", "triage"],
@@ -18697,7 +19533,7 @@ var get_issue_breadcrumbs_default = defineTool({
18697
19533
  organizationSlug: params.organizationSlug ?? context$1.constraints.organizationSlug
18698
19534
  });
18699
19535
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? context$1.constraints.regionUrl ?? void 0 });
18700
- setTag("organization.slug", parsed.organizationSlug);
19536
+ setOrganizationContext(parsed.organizationSlug);
18701
19537
  setTag("issue.id", parsed.issueId);
18702
19538
  try {
18703
19539
  await ensureIssueWithinProjectConstraint({
@@ -18719,7 +19555,7 @@ var get_issue_breadcrumbs_default = defineTool({
18719
19555
  });
18720
19556
 
18721
19557
  //#endregion
18722
- //#region ../mcp-core/dist/get-issue-tag-values-DtJZnl37.js
19558
+ //#region ../mcp-core/dist/get-issue-tag-values-CyHuVJ-4.js
18723
19559
  const getIssueTagValuesOutputSchema = z.object({ tag: z.object({
18724
19560
  key: z.string(),
18725
19561
  name: z.string(),
@@ -18800,7 +19636,7 @@ var get_issue_tag_values_default = defineTool({
18800
19636
  issueId: params.issueId,
18801
19637
  issueUrl: params.issueUrl
18802
19638
  });
18803
- setTag("organization.slug", orgSlug);
19639
+ setOrganizationContext(orgSlug);
18804
19640
  await ensureIssueWithinProjectConstraint({
18805
19641
  apiService,
18806
19642
  organizationSlug: orgSlug,
@@ -18837,7 +19673,7 @@ var get_issue_tag_values_default = defineTool({
18837
19673
  });
18838
19674
 
18839
19675
  //#endregion
18840
- //#region ../mcp-core/dist/get-issue-user-reports-D73TLuX2.js
19676
+ //#region ../mcp-core/dist/get-issue-user-reports-DhU4yW1i.js
18841
19677
  function getReporter(report) {
18842
19678
  const userId = report.user?.id?.trim();
18843
19679
  const userIdReporter = userId && !["none", "null"].includes(userId.toLowerCase()) ? `user:${userId}` : null;
@@ -18890,7 +19726,7 @@ var get_issue_user_reports_default = defineTool({
18890
19726
  organizationSlug: params.organizationSlug ?? context$1.constraints.organizationSlug
18891
19727
  });
18892
19728
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? context$1.constraints.regionUrl ?? void 0 });
18893
- setTag("organization.slug", parsed.organizationSlug);
19729
+ setOrganizationContext(parsed.organizationSlug);
18894
19730
  setTag("issue.id", parsed.issueId);
18895
19731
  await ensureIssueWithinProjectConstraint({
18896
19732
  apiService,
@@ -22425,7 +23261,7 @@ function createAnthropic(options = {}) {
22425
23261
  var anthropic = createAnthropic();
22426
23262
 
22427
23263
  //#endregion
22428
- //#region ../mcp-core/dist/anthropic-provider-CRd6GA4E.js
23264
+ //#region ../mcp-core/dist/anthropic-provider-NqnQSpoe.js
22429
23265
  const DEFAULT_ANTHROPIC_MODEL = "claude-sonnet-4-5";
22430
23266
  let configuredBaseUrl$2;
22431
23267
  /**
@@ -27078,7 +27914,7 @@ function createOpenAI(options = {}) {
27078
27914
  var openai = createOpenAI();
27079
27915
 
27080
27916
  //#endregion
27081
- //#region ../mcp-core/dist/azure-openai-provider-BNAjkBmg.js
27917
+ //#region ../mcp-core/dist/azure-openai-provider-BcsSfFBw.js
27082
27918
  const DEFAULT_OPENAI_MODEL$1 = "gpt-5";
27083
27919
  let configuredBaseUrl$1;
27084
27920
  function setAzureOpenAIBaseUrl(baseUrl) {
@@ -27136,7 +27972,7 @@ function getAzureOpenAIModel(model) {
27136
27972
  }
27137
27973
 
27138
27974
  //#endregion
27139
- //#region ../mcp-core/dist/openai-provider-DK3FdwQ_.js
27975
+ //#region ../mcp-core/dist/openai-provider-DNtIUzcM.js
27140
27976
  const DEFAULT_OPENAI_MODEL = "gpt-5";
27141
27977
  let configuredBaseUrl;
27142
27978
  /**
@@ -27176,7 +28012,7 @@ function getOpenAIModel(model) {
27176
28012
  }
27177
28013
 
27178
28014
  //#endregion
27179
- //#region ../mcp-core/dist/openrouter-provider-JT8w8qQ6.js
28015
+ //#region ../mcp-core/dist/openrouter-provider-Bq38hmFY.js
27180
28016
  const DEFAULT_OPENROUTER_MODEL = "openai/gpt-5.6-luna";
27181
28017
  const DEFAULT_OPENROUTER_REASONING_EFFORT = "high";
27182
28018
  const OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1";
@@ -27228,7 +28064,7 @@ function getOpenRouterProviderOptions() {
27228
28064
  }
27229
28065
 
27230
28066
  //#endregion
27231
- //#region ../mcp-core/dist/provider-factory-Cs_2DBhe.js
28067
+ //#region ../mcp-core/dist/provider-factory-BNDtCneN.js
27232
28068
  let configuredProvider;
27233
28069
  /**
27234
28070
  * Configure the embedded agent provider explicitly.
@@ -27373,7 +28209,7 @@ function getResolvedProviderType() {
27373
28209
  }
27374
28210
 
27375
28211
  //#endregion
27376
- //#region ../mcp-core/dist/resolve-region-url-DutLwiPb.js
28212
+ //#region ../mcp-core/dist/resolve-region-url-DgkcX4pA.js
27377
28213
  const regionUrlCache = /* @__PURE__ */ new WeakMap();
27378
28214
  function getRegionUrlCache(context$1) {
27379
28215
  let cache = regionUrlCache.get(context$1);
@@ -27412,7 +28248,7 @@ async function resolveRegionUrlForOrganization({ context: context$1, organizatio
27412
28248
  }
27413
28249
 
27414
28250
  //#endregion
27415
- //#region ../mcp-core/dist/semantic-display-Zyyjp_BY.js
28251
+ //#region ../mcp-core/dist/semantic-display-C9x4ir1O.js
27416
28252
  const SPAN_LABEL_MAX_LENGTH = 160;
27417
28253
  const SPAN_METADATA_MAX_LENGTH = 64;
27418
28254
  const SPAN_ATTRIBUTE_MAX_LENGTH = 2048;
@@ -27800,7 +28636,7 @@ function formatDisplayPart(value, maxLength) {
27800
28636
  }
27801
28637
 
27802
28638
  //#endregion
27803
- //#region ../mcp-core/dist/get-trace-details-D7U8b5_V.js
28639
+ //#region ../mcp-core/dist/get-trace-details-DIFsJzLU.js
27804
28640
  const MAX_TRACE_FETCH_LIMIT = 1e3;
27805
28641
  const MAX_FOCUSED_TRACE_FETCH_LIMIT = 1e4;
27806
28642
  const MIN_TRACE_FETCH_LIMIT = 50;
@@ -27874,7 +28710,7 @@ var get_trace_details_default = defineTool({
27874
28710
  regionUrl: params.regionUrl
27875
28711
  });
27876
28712
  const apiService = apiServiceFromContext(context$1, { regionUrl: regionUrl ?? void 0 });
27877
- setTag("organization.slug", params.organizationSlug);
28713
+ setOrganizationContext(params.organizationSlug);
27878
28714
  setTag("trace.id", params.traceId);
27879
28715
  if (params.spanId) setTag("trace.span_id", params.spanId);
27880
28716
  if (context$1.constraints.projectSlug) setTag("project.slug", context$1.constraints.projectSlug);
@@ -27914,14 +28750,7 @@ var get_trace_details_default = defineTool({
27914
28750
  directToolNames: context$1.directToolNames,
27915
28751
  aiConversations
27916
28752
  });
27917
- return addAIConversationSuggestedActions({
27918
- markdown,
27919
- organizationSlug: params.organizationSlug,
27920
- aiConversations,
27921
- experimentalMode: context$1.experimentalMode ?? false,
27922
- availableToolNames: context$1.availableToolNames,
27923
- directToolNames: context$1.directToolNames
27924
- });
28753
+ return markdown;
27925
28754
  }
27926
28755
  });
27927
28756
  function isTraceSpanNode(node) {
@@ -28560,7 +29389,7 @@ function buildTraceNextSteps({ organizationSlug, traceId, spanFocused = false, e
28560
29389
  }
28561
29390
 
28562
29391
  //#endregion
28563
- //#region ../mcp-core/dist/get-span-details-DfXIT1v_.js
29392
+ //#region ../mcp-core/dist/get-span-details-CC9cxfpa.js
28564
29393
  var get_span_details_default = defineTool({
28565
29394
  name: "get_span_details",
28566
29395
  skills: ["inspect"],
@@ -28601,7 +29430,7 @@ var get_span_details_default = defineTool({
28601
29430
  });
28602
29431
 
28603
29432
  //#endregion
28604
- //#region ../mcp-core/dist/url-helpers-CcAcmPuu.js
29433
+ //#region ../mcp-core/dist/url-helpers-DtpSKjOI.js
28605
29434
  /**
28606
29435
  * Parses a Sentry URL and extracts resource type and identifiers.
28607
29436
  *
@@ -28864,7 +29693,7 @@ function isProfileUrl(url) {
28864
29693
  }
28865
29694
 
28866
29695
  //#endregion
28867
- //#region ../mcp-core/dist/get-replay-details-BWeEKq_j.js
29696
+ //#region ../mcp-core/dist/get-replay-details-BM6gDmGp.js
28868
29697
  const MAX_ACTIVITY_EVENTS = 6;
28869
29698
  const MAX_RELATED_ERRORS = 3;
28870
29699
  const MAX_RELATED_TRACES = 2;
@@ -28916,7 +29745,7 @@ var get_replay_details_default = defineTool({
28916
29745
  regionUrl: params.regionUrl
28917
29746
  });
28918
29747
  const apiService = apiServiceFromContext(context$1, { regionUrl: regionUrl ?? void 0 });
28919
- setTag("organization.slug", resolved.organizationSlug);
29748
+ setOrganizationContext(resolved.organizationSlug);
28920
29749
  setTag("replay.id", resolved.replayId);
28921
29750
  const replay = await apiService.getReplayDetails({
28922
29751
  organizationSlug: resolved.organizationSlug,
@@ -29201,7 +30030,44 @@ function quoteDetail(value) {
29201
30030
  }
29202
30031
 
29203
30032
  //#endregion
29204
- //#region ../mcp-core/dist/get-event-attachment-h8oTTPZt.js
30033
+ //#region ../mcp-core/dist/get-event-attachment-LSEqrcub.js
30034
+ function formatMegabytes(bytes) {
30035
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
30036
+ }
30037
+ /**
30038
+ * Render the response for an attachment too large to inline: a presigned direct
30039
+ * link when available, otherwise authenticated-download instructions.
30040
+ */
30041
+ function formatOversizedAttachment(params, attachment) {
30042
+ const sizeBytes = attachment.attachment.size;
30043
+ const downloadApiPath = `projects/${params.organizationSlug}/${params.projectSlug}/events/${params.eventId}/attachments/${params.attachmentId}/?download=1`;
30044
+ const outputName = `attachment-${params.attachmentId}`;
30045
+ let output = "# Event Attachment — Too Large to Return Inline\n\n";
30046
+ output += `**Event ID:** ${params.eventId}\n`;
30047
+ output += `**Attachment ID:** ${params.attachmentId}\n`;
30048
+ output += `**Filename:** ${attachment.filename}\n`;
30049
+ output += `**Type:** ${attachment.attachment.type}\n`;
30050
+ output += `**Size:** ${sizeBytes} bytes (${formatMegabytes(sizeBytes)})\n`;
30051
+ output += `**MIME Type:** ${attachment.contentType}\n`;
30052
+ output += `**Created:** ${attachment.attachment.dateCreated}\n\n`;
30053
+ output += `This attachment (${formatMegabytes(sizeBytes)}) exceeds the ${formatMegabytes(DEFAULT_MAX_INLINE_ATTACHMENT_BYTES)} inline limit for MCP responses, so its contents were not downloaded.\n\n`;
30054
+ output += "## How to download it\n\n";
30055
+ if (attachment.directDownloadUrl) {
30056
+ output += "**Direct download** (a presigned link — no authentication needed; it expires shortly, so fetch it promptly):\n\n";
30057
+ output += `${attachment.directDownloadUrl}\n\n`;
30058
+ output += "If the link has expired, re-run this tool to get a fresh one, or use the authenticated API endpoint below.\n\n";
30059
+ output += "**Authenticated Sentry API endpoint** (requires Sentry credentials):\n";
30060
+ output += `- Sentry CLI: \`sentry api ${downloadApiPath} > ${outputName}\`\n`;
30061
+ output += `- Or an \`Authorization: Bearer <token>\` request to: ${attachment.downloadUrl}\n`;
30062
+ } else {
30063
+ output += "The download URL is an authenticated Sentry API endpoint — it is not a public link and requires your Sentry credentials (a bare fetch returns HTTP 401).\n\n";
30064
+ output += "- **Sentry CLI** (handles auth automatically):\n";
30065
+ output += ` \`sentry api ${downloadApiPath} > ${outputName}\`\n`;
30066
+ output += `- **Any HTTP client** with an \`Authorization: Bearer <token>\` header against: ${attachment.downloadUrl}\n`;
30067
+ output += "- **Sentry UI:** open the event and use the Attachments tab.\n";
30068
+ }
30069
+ return output;
30070
+ }
29205
30071
  var get_event_attachment_default = defineTool({
29206
30072
  name: "get_event_attachment",
29207
30073
  skills: ["inspect"],
@@ -29249,7 +30115,7 @@ var get_event_attachment_default = defineTool({
29249
30115
  },
29250
30116
  async handler(params, context$1) {
29251
30117
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
29252
- setTag("organization.slug", params.organizationSlug);
30118
+ setOrganizationContext(params.organizationSlug);
29253
30119
  if (params.attachmentId) {
29254
30120
  const attachment = await apiService.getEventAttachment({
29255
30121
  organizationSlug: params.organizationSlug,
@@ -29257,12 +30123,19 @@ var get_event_attachment_default = defineTool({
29257
30123
  eventId: params.eventId,
29258
30124
  attachmentId: params.attachmentId
29259
30125
  });
30126
+ if (attachment.bytes === null) return formatOversizedAttachment({
30127
+ organizationSlug: params.organizationSlug,
30128
+ projectSlug: params.projectSlug,
30129
+ eventId: params.eventId,
30130
+ attachmentId: params.attachmentId
30131
+ }, attachment);
29260
30132
  const contentParts = [];
29261
30133
  const effectiveMimeType = attachment.contentType;
29262
30134
  const isBinary = !effectiveMimeType.startsWith("text/");
29263
- if (isBinary) {
30135
+ const isEmpty = attachment.bytes.length === 0;
30136
+ if (isBinary && !isEmpty) {
29264
30137
  const isImage = effectiveMimeType.startsWith("image/");
29265
- const base64 = await blobToBase64(attachment.blob);
30138
+ const base64 = bytesToBase64(attachment.bytes);
29266
30139
  if (isImage) {
29267
30140
  const image = {
29268
30141
  type: "image",
@@ -29291,11 +30164,15 @@ var get_event_attachment_default = defineTool({
29291
30164
  output$1 += `**MIME Type:** ${effectiveMimeType}\n`;
29292
30165
  output$1 += `**Created:** ${attachment.attachment.dateCreated}\n\n`;
29293
30166
  output$1 += `**Download URL:** ${attachment.downloadUrl}\n\n`;
29294
- if (isBinary) {
30167
+ if (isEmpty) {
30168
+ output$1 += `## Empty Content\n\n`;
30169
+ if (attachment.attachment.size > 0) output$1 += `The download returned no data even though the attachment metadata reports ${attachment.attachment.size} bytes. This usually indicates a failed or truncated download; try again, or download it directly from the URL above (requires Sentry authentication).\n`;
30170
+ else output$1 += `This attachment is empty (0 bytes).\n`;
30171
+ } else if (isBinary) {
29295
30172
  output$1 += `## Binary Content\n\n`;
29296
30173
  output$1 += `The attachment is included as a resource and accessible through your client.\n`;
29297
30174
  } else {
29298
- const textContent = await attachment.blob.text();
30175
+ const textContent = new TextDecoder().decode(attachment.bytes);
29299
30176
  output$1 += `## File Content\n\n`;
29300
30177
  output$1 += `\`\`\`\n${textContent}\n\`\`\`\n\n`;
29301
30178
  }
@@ -29346,7 +30223,7 @@ var get_event_attachment_default = defineTool({
29346
30223
  });
29347
30224
 
29348
30225
  //#endregion
29349
- //#region ../mcp-core/dist/formatting-Dh3LlFmw.js
30226
+ //#region ../mcp-core/dist/formatting-BG8yQUmg.js
29350
30227
  /**
29351
30228
  * Helper function to format assignedTo field for display
29352
30229
  */
@@ -29358,7 +30235,7 @@ function formatAssignedTo(assignedTo) {
29358
30235
  }
29359
30236
 
29360
30237
  //#endregion
29361
- //#region ../mcp-core/dist/update-issue-q9a5YNJb.js
30238
+ //#region ../mcp-core/dist/update-issue-BH3fTM71.js
29362
30239
  function pluralize(value, noun) {
29363
30240
  return `${value} ${noun}${value === 1 ? "" : "s"}`;
29364
30241
  }
@@ -29497,7 +30374,9 @@ function buildNoChangesOutput(params) {
29497
30374
  return output;
29498
30375
  }
29499
30376
  function isAssigneeAlreadySet(issue, requestedAssignee, currentUserId) {
29500
- if (!requestedAssignee || !issue.assignedTo) return false;
30377
+ if (requestedAssignee === void 0) return false;
30378
+ if (requestedAssignee === null) return !issue.assignedTo;
30379
+ if (!issue.assignedTo) return false;
29501
30380
  if (typeof issue.assignedTo === "string") return issue.assignedTo === requestedAssignee;
29502
30381
  if (requestedAssignee === "me") return issue.assignedTo.type === "user" && currentUserId !== void 0 && String(issue.assignedTo.id) === currentUserId;
29503
30382
  if (requestedAssignee.startsWith("user:")) return issue.assignedTo.type === "user" && String(issue.assignedTo.id) === requestedAssignee.slice(5);
@@ -29622,12 +30501,13 @@ var update_issue_default = defineTool({
29622
30501
  description: [
29623
30502
  "Update a Sentry issue's status or assignment.",
29624
30503
  "",
29625
- "Use this to resolve, reopen, assign, or ignore an issue.",
30504
+ "Use this to resolve, reopen, assign, unassign, or ignore an issue.",
29626
30505
  "",
29627
30506
  "<examples>",
29628
30507
  "```",
29629
30508
  "update_issue(organizationSlug='my-org', issueId='PROJECT-123', status='resolved')",
29630
30509
  "update_issue(organizationSlug='my-org', issueId='PROJECT-123', assignedTo='user:123456')",
30510
+ "update_issue(organizationSlug='my-org', issueId='PROJECT-123', assignedTo=null)",
29631
30511
  "update_issue(organizationSlug='my-org', issueId='PROJECT-123', status='ignored')",
29632
30512
  "update_issue(organizationSlug='my-org', issueId='PROJECT-123', status='ignored', ignoreMode='forever')",
29633
30513
  "update_issue(organizationSlug='my-org', issueId='PROJECT-123', status='ignored', ignoreMode='untilOccurrenceCount', ignoreCount=100, ignoreWindowMinutes=60)",
@@ -29638,7 +30518,7 @@ var update_issue_default = defineTool({
29638
30518
  "<hints>",
29639
30519
  "- Provide `issueUrl` or `organizationSlug` + `issueId`.",
29640
30520
  "- At least one of `status` or `assignedTo` is required.",
29641
- "- `assignedTo` format: `user:ID` or `team:ID_OR_SLUG`.",
30521
+ "- Omit `assignedTo` to leave assignment unchanged. Pass `null` to unassign; otherwise use `user:ID` or `team:ID_OR_SLUG`.",
29642
30522
  "- Use `execute_sentry_tool(name='whoami', arguments={})` to find your user ID for self-assignment.",
29643
30523
  "- Status values: `resolved`, `resolvedInNextRelease`, `unresolved`, `ignored`.",
29644
30524
  "- `status='ignored'` defaults to `ignoreMode='untilEscalating'`.",
@@ -29673,13 +30553,13 @@ var update_issue_default = defineTool({
29673
30553
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
29674
30554
  if (!params.issueUrl && !params.issueId) throw new UserInputError("Either `issueId` or `issueUrl` must be provided");
29675
30555
  if (!params.issueUrl && !params.organizationSlug) throw new UserInputError("`organizationSlug` is required when providing `issueId`");
29676
- if (!params.status && !params.assignedTo) throw new UserInputError("At least one of `status` or `assignedTo` must be provided to update the issue");
30556
+ if (params.status === void 0 && params.assignedTo === void 0) throw new UserInputError("At least one of `status` or `assignedTo` must be provided to update the issue");
29677
30557
  const { organizationSlug: orgSlug, issueId: parsedIssueId } = parseIssueParams({
29678
30558
  organizationSlug: params.organizationSlug,
29679
30559
  issueId: params.issueId,
29680
30560
  issueUrl: params.issueUrl
29681
30561
  });
29682
- setTag("organization.slug", orgSlug);
30562
+ setOrganizationContext(orgSlug);
29683
30563
  const currentIssue = await apiService.getIssue({
29684
30564
  organizationSlug: orgSlug,
29685
30565
  issueId: parsedIssueId
@@ -29707,7 +30587,7 @@ var update_issue_default = defineTool({
29707
30587
  } else if (currentIgnoreState && requestedIgnoreFamily && currentIgnoreState.family !== requestedIgnoreFamily) throw new UserInputError("Changing ignore behavior on an already ignored issue between `untilEscalating`, `forever`, and condition-based modes is not supported. First set `status` to `unresolved`, then ignore it again with the new rule.");
29708
30588
  }
29709
30589
  const requestedIssueUrl = apiService.getIssueUrl(orgSlug, currentIssue.shortId);
29710
- if (!updateStatus && !updateAssignedTo && !updateIgnore) {
30590
+ if (updateStatus === void 0 && updateAssignedTo === void 0 && updateIgnore === void 0) {
29711
30591
  const commentResult$1 = await tryPostReasonComment(apiService, orgSlug, parsedIssueId, params.reason);
29712
30592
  return buildNoChangesOutput({
29713
30593
  issue: currentIssue,
@@ -29742,7 +30622,7 @@ var update_issue_default = defineTool({
29742
30622
  if (statusChanged) output += `**Status**: ${currentStatusDisplay} → **${updatedStatusDisplay}**\n`;
29743
30623
  if (updatedIgnoreState && (statusChanged || ignoreBehaviorChanged) && (ignoreBehaviorChanged || params.status === "ignored")) if (currentIgnoreState && ignoreBehaviorChanged) output += `**Ignore Behavior**: ${currentIgnoreState.behavior} → **${updatedIgnoreState.behavior}**\n`;
29744
30624
  else output += `**Ignore Behavior**: **${updatedIgnoreState.behavior}**\n`;
29745
- if (updateAssignedTo && assignmentChanged) {
30625
+ if (updateAssignedTo !== void 0 && assignmentChanged) {
29746
30626
  const oldAssignee = formatAssignedTo(currentIssue.assignedTo ?? null);
29747
30627
  const newAssignee = params.assignedTo === "me" ? "You" : formatAssignedTo(updatedIssue.assignedTo ?? null);
29748
30628
  output += `**Assigned To**: ${oldAssignee} → **${newAssignee}**\n`;
@@ -29764,7 +30644,7 @@ var update_issue_default = defineTool({
29764
30644
  });
29765
30645
 
29766
30646
  //#endregion
29767
- //#region ../mcp-core/dist/provider-fallback-L61Pbfxx.js
30647
+ //#region ../mcp-core/dist/provider-fallback-B4jxYMQu.js
29768
30648
  /**
29769
30649
  * Run an optional embedded-agent rewrite and fall back to the caller's direct
29770
30650
  * behavior when the agent cannot complete the rewrite.
@@ -29804,7 +30684,126 @@ async function withProviderFallback({ operation, fallback, onFallback, run }) {
29804
30684
  }
29805
30685
 
29806
30686
  //#endregion
29807
- //#region ../mcp-core/dist/callEmbeddedAgent-ffwEeqdP.js
30687
+ //#region ../mcp-core/dist/sentry-CcB-AERp.js
30688
+ const SCRUB_PATTERNS = [
30689
+ {
30690
+ pattern: /\bsk-[a-zA-Z0-9]{48}\b/g,
30691
+ replacement: "[REDACTED_OPENAI_KEY]",
30692
+ description: "OpenAI API key"
30693
+ },
30694
+ {
30695
+ pattern: /\bBearer\s+[a-zA-Z0-9\-._~+/]+={0,}/g,
30696
+ replacement: "Bearer [REDACTED_TOKEN]",
30697
+ description: "Bearer token"
30698
+ },
30699
+ {
30700
+ pattern: /\bsntrys_[a-zA-Z0-9_]+\b/g,
30701
+ replacement: "[REDACTED_SENTRY_TOKEN]",
30702
+ description: "Sentry access token"
30703
+ }
30704
+ ];
30705
+ const MAX_SCRUB_DEPTH = 20;
30706
+ /**
30707
+ * Recursively scrub sensitive data from any value.
30708
+ * Returns tuple of [scrubbedValue, didScrub, descriptionsOfMatchedPatterns]
30709
+ */
30710
+ function scrubValue(value, depth = 0) {
30711
+ if (depth >= MAX_SCRUB_DEPTH) return [
30712
+ "[MAX_DEPTH_EXCEEDED]",
30713
+ false,
30714
+ []
30715
+ ];
30716
+ if (typeof value === "string") {
30717
+ let scrubbed = value;
30718
+ let didScrub = false;
30719
+ const matchedDescriptions = [];
30720
+ for (const { pattern, replacement, description: description$73 } of SCRUB_PATTERNS) {
30721
+ pattern.lastIndex = 0;
30722
+ if (pattern.test(scrubbed)) {
30723
+ didScrub = true;
30724
+ matchedDescriptions.push(description$73);
30725
+ pattern.lastIndex = 0;
30726
+ scrubbed = scrubbed.replace(pattern, replacement);
30727
+ }
30728
+ }
30729
+ return [
30730
+ scrubbed,
30731
+ didScrub,
30732
+ matchedDescriptions
30733
+ ];
30734
+ }
30735
+ if (Array.isArray(value)) {
30736
+ let arrayDidScrub = false;
30737
+ const arrayDescriptions = [];
30738
+ const scrubbedArray = value.map((item) => {
30739
+ const [scrubbed, didScrub, descriptions] = scrubValue(item, depth + 1);
30740
+ if (didScrub) {
30741
+ arrayDidScrub = true;
30742
+ arrayDescriptions.push(...descriptions);
30743
+ }
30744
+ return scrubbed;
30745
+ });
30746
+ return [
30747
+ scrubbedArray,
30748
+ arrayDidScrub,
30749
+ arrayDescriptions
30750
+ ];
30751
+ }
30752
+ if (value && typeof value === "object") {
30753
+ let objectDidScrub = false;
30754
+ const objectDescriptions = [];
30755
+ const scrubbed = {};
30756
+ for (const [key, val] of Object.entries(value)) {
30757
+ const [scrubbedVal, didScrub, descriptions] = scrubValue(val, depth + 1);
30758
+ if (didScrub) {
30759
+ objectDidScrub = true;
30760
+ objectDescriptions.push(...descriptions);
30761
+ }
30762
+ scrubbed[key] = scrubbedVal;
30763
+ }
30764
+ return [
30765
+ scrubbed,
30766
+ objectDidScrub,
30767
+ objectDescriptions
30768
+ ];
30769
+ }
30770
+ return [
30771
+ value,
30772
+ false,
30773
+ []
30774
+ ];
30775
+ }
30776
+ /**
30777
+ * Sentry beforeSend hook that scrubs sensitive data from events
30778
+ * and applies custom fingerprinting for specific error types.
30779
+ */
30780
+ function sentryBeforeSend(event, hint) {
30781
+ const firstException = event?.exception?.values?.[0];
30782
+ if (firstException?.type === "AI_APICallError" && firstException.value) event.fingerprint = ["AI_APICallError", firstException.value];
30783
+ const [scrubbedEvent, didScrub, descriptions] = scrubValue(event);
30784
+ if (didScrub) {
30785
+ const uniqueDescriptions = [...new Set(descriptions)];
30786
+ console.warn(`[Sentry] Event contained sensitive data: ${uniqueDescriptions.join(", ")}`);
30787
+ }
30788
+ return scrubbedEvent;
30789
+ }
30790
+ const EMAIL_PATTERN = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
30791
+ /**
30792
+ * Scrub tokens (OpenAI/Bearer/Sentry) and emails from a free-form string before
30793
+ * logging it. Applied at the log call site so it covers every sink (stderr and
30794
+ * Sentry Logs).
30795
+ */
30796
+ function scrubSensitiveText(text$1) {
30797
+ let scrubbed = text$1;
30798
+ for (const { pattern, replacement } of SCRUB_PATTERNS) {
30799
+ pattern.lastIndex = 0;
30800
+ scrubbed = scrubbed.replace(pattern, replacement);
30801
+ }
30802
+ return scrubbed.replace(EMAIL_PATTERN, "[REDACTED_EMAIL]");
30803
+ }
30804
+
30805
+ //#endregion
30806
+ //#region ../mcp-core/dist/callEmbeddedAgent-DvwjAsbW.js
29808
30807
  /**
29809
30808
  * Resolve the underlying provider failure from an AI SDK error.
29810
30809
  *
@@ -29896,6 +30895,13 @@ async function callEmbeddedAgent({ system, prompt, tools, schema }) {
29896
30895
  });
29897
30896
  throw new UserInputError("The AI was unable to process your query. Please try rephrasing.");
29898
30897
  }
30898
+ if (NoOutputGeneratedError.isInstance(error)) {
30899
+ logWarn("Embedded agent produced no output", {
30900
+ loggerScope: ["agents", "embedded"],
30901
+ extra: { errorMessage: error.message }
30902
+ });
30903
+ throw new UserInputError("The AI could not construct a valid query for this request. Please rephrase or narrow it — for example, specify the fields, a real environment name, or a time range.");
30904
+ }
29899
30905
  const providerError = resolveProviderApiCallError(error);
29900
30906
  if (providerError) throw toLLMProviderError(providerError, error);
29901
30907
  if (RetryError.isInstance(error)) throw new LLMProviderError(`The AI provider is currently unavailable: ${error.message}. Please try again later.`, { cause: error });
@@ -29992,7 +30998,7 @@ function rescueFromText(text$1, schema) {
29992
30998
  }
29993
30999
 
29994
31000
  //#endregion
29995
- //#region ../mcp-core/dist/utils-DHwF0RI3.js
31001
+ //#region ../mcp-core/dist/utils-_7jC6e0y.js
29996
31002
  /**
29997
31003
  * Standard response schema for all embedded agent tools.
29998
31004
  * Tools return either an error message or the result data, never both.
@@ -30111,7 +31117,7 @@ function agentTool(config) {
30111
31117
  }
30112
31118
 
30113
31119
  //#endregion
30114
- //#region ../mcp-core/dist/dataset-fields-CBauoBBr.js
31120
+ //#region ../mcp-core/dist/dataset-fields-nUaj8nt3.js
30115
31121
  const REPLAY_EXCLUDED_TAGS = new Set([
30116
31122
  "browser",
30117
31123
  "device",
@@ -30610,7 +31616,7 @@ function getReplayCommonPatterns(availableFields) {
30610
31616
  }
30611
31617
 
30612
31618
  //#endregion
30613
- //#region ../mcp-core/dist/otel-semantics-DGeu0HI-.js
31619
+ //#region ../mcp-core/dist/otel-semantics-D9c5D-bO.js
30614
31620
  var namespace$72 = "android";
30615
31621
  var description$72 = "The Android platform on which the Android application is running.\n";
30616
31622
  var attributes$72 = {
@@ -35632,7 +36638,7 @@ function createOtelLookupTool(options) {
35632
36638
  }
35633
36639
 
35634
36640
  //#endregion
35635
- //#region ../mcp-core/dist/whoami-DU_KhHDm.js
36641
+ //#region ../mcp-core/dist/whoami-B81Oqo48.js
35636
36642
  /**
35637
36643
  * Get the current authenticated user's information from Sentry API
35638
36644
  */
@@ -35661,7 +36667,7 @@ function createWhoamiTool(options) {
35661
36667
  }
35662
36668
 
35663
36669
  //#endregion
35664
- //#region ../mcp-core/dist/utils-Dg2aeBEb.js
36670
+ //#region ../mcp-core/dist/utils-DNoGJro2.js
35665
36671
  const DEFAULT_MAX_VALUE_LENGTH = 200;
35666
36672
  const DEFAULT_MAX_ARRAY_ITEMS = 20;
35667
36673
  const SENTRY_SEARCH_TOKEN_PATTERN = /(^|\s)!?([A-Za-z_][A-Za-z0-9_.[\],-]*):(?=\S)(?!\/\/)/g;
@@ -36122,7 +37128,7 @@ function createDatasetAttributesTool(options) {
36122
37128
  attributeTypes: z.array(traceItemAttributeTypeSchema).min(1).optional().describe("Optional attribute types to list. Use ['string','number','boolean'] when unsure.")
36123
37129
  }),
36124
37130
  execute: async ({ dataset, substringMatch, query, attributeTypes }) => {
36125
- const { BASE_COMMON_FIELDS, DATASET_FIELDS, RECOMMENDED_FIELDS: RECOMMENDED_FIELDS$2, NUMERIC_FIELDS, DATASET_EXAMPLES } = await import("./config-BUwpc74z.js");
37131
+ const { BASE_COMMON_FIELDS, DATASET_FIELDS, RECOMMENDED_FIELDS: RECOMMENDED_FIELDS$2, NUMERIC_FIELDS, DATASET_EXAMPLES } = await import("./config-_di9BWJ0.js");
36126
37132
  const normalizedDataset = normalizeEventsDataset(dataset);
36127
37133
  const attributeTimeParams = { statsPeriod: "14d" };
36128
37134
  const { attributes: customAttributes, fieldTypes } = await fetchCustomAttributes(apiService, organizationSlug, dataset, projectId, attributeTimeParams, {
@@ -36212,14 +37218,18 @@ function createValidateEventsSearchTool(options) {
36212
37218
  }
36213
37219
 
36214
37220
  //#endregion
36215
- //#region ../mcp-core/dist/agent-BCH9XRWB.js
37221
+ //#region ../mcp-core/dist/agent-D-RH-_8n.js
36216
37222
  const SEARCH_EVENTS_DATASETS$1 = [...PUBLIC_EVENTS_DATASETS, "replays"];
36217
37223
  const searchEventsAgentOutputSchema = z.object({
36218
37224
  dataset: z.enum(SEARCH_EVENTS_DATASETS$1).describe("Which dataset to use for the query"),
36219
37225
  query: z.string().describe("The Sentry query string for filtering results"),
36220
37226
  fields: z.array(z.string()).describe("Array of field names to return in results."),
36221
37227
  sort: z.string().describe("Sort parameter for results."),
36222
- environment: z.union([z.string(), z.array(z.string()).min(1)]).nullable().default(null).describe("Separate environment filter for datasets like replays that do not support environment in the query string. Use a string for one environment or an array when multiple environments are requested."),
37228
+ environment: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]).nullable().default(null).describe("Separate environment filter for datasets like replays that do not support environment in the query string. Set only to a real environment the user named (see the 'Available environments' list); omit otherwise. Never use wildcards, placeholders, or example values."),
37229
+ timeSeries: z.object({
37230
+ yAxis: z.string().describe("The aggregate to plot over time, e.g. 'count()', 'count_unique(user)', 'sum(span.duration)'."),
37231
+ interval: z.string().nullable().default(null).describe("Bucket size like '1h' or '1d'. Set ONLY when the user names a granularity (e.g. 'per hour' -> '1h'); otherwise null so Sentry picks a sensible bucket for the time range.")
37232
+ }).nullable().default(null).describe("Set ONLY when the user wants a metric OVER TIME (e.g. 'per hour', 'per day', 'trend', 'over time'). Otherwise leave null and return a normal query. The interval is decided here, never required from the caller."),
36223
37233
  timeRange: z.union([
36224
37234
  z.object({ statsPeriod: z.string().describe("Relative time period like '1h', '24h', '7d'") }),
36225
37235
  z.object({
@@ -36231,10 +37241,44 @@ const searchEventsAgentOutputSchema = z.object({
36231
37241
  explanation: z.string().default("").describe("Brief explanation of how you translated this query.")
36232
37242
  }).refine((data) => {
36233
37243
  if (data.dataset === "replays") return true;
37244
+ if (data.timeSeries) return true;
36234
37245
  if (!data.sort || !data.fields || data.fields.length === 0) return true;
36235
37246
  const sortField = data.sort.startsWith("-") ? data.sort.substring(1) : data.sort;
36236
37247
  return data.fields.includes(sortField);
36237
37248
  }, { message: "Sort field must be included in the fields array. Sentry requires that any field used for sorting must also be explicitly selected. Add the sort field to the fields array or choose a different sort field that's already included." });
37249
+ const MAX_INLINE_ENVIRONMENTS = 100;
37250
+ /**
37251
+ * Append the organization's real environment names to the system prompt.
37252
+ *
37253
+ * Without this the model invents `environment` values (e.g. `":null"`, `".*"`)
37254
+ * that Sentry rejects, burning the step budget and producing no output — the top
37255
+ * source of search_events failures. Grounding it lets the model pick a real one
37256
+ * or omit the field.
37257
+ */
37258
+ function buildSystemPromptWithEnvironments(base, environmentNames) {
37259
+ if (environmentNames.length === 0) return base;
37260
+ const rule = "When the user names an environment, set the `environment` field to a matching value from this list EXACTLY; otherwise OMIT the field. Never use wildcards, placeholders, \"null\", \"*\", empty strings, or example values.";
37261
+ if (environmentNames.length <= MAX_INLINE_ENVIRONMENTS) {
37262
+ const list = environmentNames.map((name$4) => `"${name$4}"`).join(", ");
37263
+ return `${base}\n\n## Available environments\nThe only valid \`environment\` values for this organization are: ${list}.\n${rule}`;
37264
+ }
37265
+ return `${base}\n\n## Environments\nThis organization has ${environmentNames.length} environments. ${rule}`;
37266
+ }
37267
+ /**
37268
+ * Best-effort fetch of the org's environment names (scoped to the project when
37269
+ * known). Failures are non-fatal — callers still run, just without grounding.
37270
+ */
37271
+ async function fetchEnvironmentNames(options) {
37272
+ try {
37273
+ const environments = await options.apiService.listEnvironments({
37274
+ organizationSlug: options.organizationSlug,
37275
+ projectId: options.projectId
37276
+ });
37277
+ return environments.map((environment) => environment.name).filter((name$4) => name$4.length > 0);
37278
+ } catch {
37279
+ return [];
37280
+ }
37281
+ }
36238
37282
  /**
36239
37283
  * Search events agent - single entry point for translating natural language queries to Sentry search syntax
36240
37284
  * This returns both the translated query result AND the tool calls made by the agent
@@ -36262,8 +37306,9 @@ async function searchEventsAgent(options) {
36262
37306
  projectId: options.projectId
36263
37307
  });
36264
37308
  const whoamiTool = createWhoamiTool({ apiService: options.apiService });
37309
+ const environmentNames = options.environmentNames ?? await fetchEnvironmentNames(options);
36265
37310
  return await callEmbeddedAgent({
36266
- system: systemPrompt,
37311
+ system: buildSystemPromptWithEnvironments(systemPrompt, environmentNames),
36267
37312
  prompt: options.query,
36268
37313
  tools: {
36269
37314
  datasetAttributes: datasetAttributesTool,
@@ -36277,7 +37322,7 @@ async function searchEventsAgent(options) {
36277
37322
  }
36278
37323
 
36279
37324
  //#endregion
36280
- //#region ../mcp-core/dist/analyzer-CtmUqCwO.js
37325
+ //#region ../mcp-core/dist/analyzer-BuS9K0e5.js
36281
37326
  /**
36282
37327
  * Analyzes flamegraph data to extract hot paths (most CPU-intensive call stacks).
36283
37328
  *
@@ -36536,7 +37581,7 @@ function hasProfileData(flamegraph) {
36536
37581
  }
36537
37582
 
36538
37583
  //#endregion
36539
- //#region ../mcp-core/dist/formatters-Cuh2gD9M.js
37584
+ //#region ../mcp-core/dist/formatters-DsABISrU.js
36540
37585
  /**
36541
37586
  * Format an explanation for how the input query was translated
36542
37587
  */
@@ -37001,9 +38046,47 @@ function formatTraceMetricsResults(params) {
37001
38046
  output += "- Switch between samples and aggregates in Sentry for deeper analysis\n";
37002
38047
  return output;
37003
38048
  }
38049
+ /**
38050
+ * Whether summing per-bucket values yields a meaningful series total.
38051
+ * Only `count()` and `sum(...)` are additive across time buckets;
38052
+ * `count_unique`, `avg`, percentiles, min/max, rates, etc. are not.
38053
+ */
38054
+ function isAdditiveAggregate(yAxis) {
38055
+ const fn = yAxis.trim().toLowerCase();
38056
+ return fn === "count()" || fn.startsWith("sum(");
38057
+ }
38058
+ /**
38059
+ * Format an events-stats (timeseries) result: a metric bucketed over time.
38060
+ * `interval` is null when Sentry chose the bucket size for the range.
38061
+ */
38062
+ function formatTimeSeriesResults(params) {
38063
+ const { series, yAxis, interval, inputQuery, includeExplanation, explanation, timeRange, url } = params;
38064
+ const points = series.data.map(([ts, values]) => ({
38065
+ time: (/* @__PURE__ */ new Date(ts * 1e3)).toISOString().slice(0, 16).replace("T", " "),
38066
+ value: values[0]?.count ?? 0
38067
+ }));
38068
+ const total = isAdditiveAggregate(yAxis) ? points.reduce((sum, p) => sum + p.value, 0) : null;
38069
+ const peak = points.reduce((max, p) => max === void 0 || p.value > max.value ? p : max, void 0);
38070
+ const MAX_ROWS = 48;
38071
+ const shown = points.length > MAX_ROWS ? points.slice(-MAX_ROWS) : points;
38072
+ const truncatedNote = points.length > MAX_ROWS ? ` (most recent ${MAX_ROWS} of ${points.length})` : "";
38073
+ const lines = [`# Search Results for "${inputQuery}"`];
38074
+ if (includeExplanation && explanation) lines.push("", formatExplanation$1(explanation));
38075
+ lines.push("", `## ${yAxis} over time`);
38076
+ lines.push(`- **Interval**: ${interval ? `\`${interval}\`` : "auto (chosen by Sentry for the range)"}`);
38077
+ lines.push(`- **Time range**: ${formatExecutedTimeRange(timeRange)}`);
38078
+ if (total !== null) lines.push(`- **Total**: ${total.toLocaleString()}`);
38079
+ if (peak) lines.push(`- **Peak**: ${peak.value.toLocaleString()} at ${peak.time}`);
38080
+ if (shown.length > 0) {
38081
+ lines.push("", `## Buckets${truncatedNote}`, "", "| Time (UTC) | Value |", "| --- | --- |");
38082
+ for (const p of shown) lines.push(`| ${p.time} | ${p.value.toLocaleString()} |`);
38083
+ } else lines.push("", "No data points in this range.");
38084
+ if (url) lines.push("", formatSentryDashboardLink(url).trimEnd());
38085
+ return lines.join("\n");
38086
+ }
37004
38087
 
37005
38088
  //#endregion
37006
- //#region ../mcp-core/dist/replays-Dg9Syytd.js
38089
+ //#region ../mcp-core/dist/replays-DQeYjWub.js
37007
38090
  const DEFAULT_REPLAY_SORT = "-started_at";
37008
38091
  const DEFAULT_REPLAY_STATS_PERIOD = "14d";
37009
38092
  const REPLAY_SORT_FIELDS = [
@@ -37128,7 +38211,7 @@ function formatReplayEnvironment(environment) {
37128
38211
  }
37129
38212
 
37130
38213
  //#endregion
37131
- //#region ../mcp-core/dist/search-events-C8aVtdIY.js
38214
+ //#region ../mcp-core/dist/search-events-BFGK2Xtv.js
37132
38215
  const SEARCH_EVENTS_DATASETS = [...PUBLIC_EVENTS_DATASETS, "replays"];
37133
38216
  const DEFAULT_EVENTS_SORT = "-timestamp";
37134
38217
  function defaultSortForDataset(dataset) {
@@ -37185,6 +38268,42 @@ function appendSearchFilter(query, filter$1) {
37185
38268
  if (tokenizeSearchQuery(trimmedQuery).includes(filter$1)) return trimmedQuery;
37186
38269
  return [trimmedQuery, filter$1].filter(Boolean).join(" ");
37187
38270
  }
38271
+ /**
38272
+ * Collect the environment names a search actually filters on — from both the
38273
+ * separate `environment` field and any `environment:` token in the query string.
38274
+ * Sentry only validates the former against real environments, so a bad value in
38275
+ * the query (e.g. a typo) otherwise slips through and silently returns nothing.
38276
+ */
38277
+ function collectRequestedEnvironments(environment, query) {
38278
+ const values = [];
38279
+ if (typeof environment === "string") values.push(environment);
38280
+ else if (Array.isArray(environment)) values.push(...environment);
38281
+ const tokens = tokenizeSearchQuery(query);
38282
+ for (let i = 0; i < tokens.length; i++) {
38283
+ const match = /^environment:(.*)$/is.exec(tokens[i]);
38284
+ if (!match) continue;
38285
+ let value = match[1];
38286
+ while (value.startsWith("[") && !value.includes("]") && i + 1 < tokens.length) value += ` ${tokens[++i]}`;
38287
+ const inner = value.startsWith("[") && value.endsWith("]") ? value.slice(1, -1) : value;
38288
+ for (const part of inner.split(",")) {
38289
+ const cleaned = part.trim().replace(/^["']|["']$/g, "");
38290
+ if (cleaned) values.push(cleaned);
38291
+ }
38292
+ }
38293
+ return values;
38294
+ }
38295
+ /**
38296
+ * Note listing the org's real environments when a search references one that
38297
+ * doesn't exist, so the caller can retry with a valid name. We don't guess a
38298
+ * match — the calling agent maps from the list.
38299
+ */
38300
+ function formatUnknownEnvironmentNote(unknown, available) {
38301
+ const uniqueUnknown = [...new Set(unknown)].map((name$4) => `\`${name$4}\``);
38302
+ const shown = available.slice(0, 50).map((name$4) => `\`${name$4}\``);
38303
+ const more = available.length > shown.length ? ` (${available.length} total)` : "";
38304
+ const label = uniqueUnknown.length === 1 ? "environment" : "environments";
38305
+ return `> ⚠️ Requested ${label} not found in this organization: ${uniqueUnknown.join(", ")}. Available environments: ${shown.join(", ")}${more}. Re-run filtering by one of these, or omit the environment to search all.`;
38306
+ }
37188
38307
  function applyEnvironmentToEventsQuery(dataset, query, environment) {
37189
38308
  if (dataset === "replays") return query;
37190
38309
  return appendSearchFilter(query, formatEnvironmentFilter(environment));
@@ -37276,11 +38395,12 @@ var search_events_default = defineTool({
37276
38395
  description: [
37277
38396
  "Search Sentry events and replays. Use for event counts/statistics.",
37278
38397
  "",
37279
- "`query` can be natural language or Sentry search syntax. With an agent configured, it fixes dataset, query, fields, and sort before running.",
38398
+ "`query` is natural language or Sentry search syntax; a configured agent fixes dataset, query, fields, and sort.",
37280
38399
  "",
37281
- "Supports TWO query types:",
38400
+ "Supports THREE query types:",
37282
38401
  "1. AGGREGATIONS (counts, sums, averages): 'how many errors', 'total tokens'",
37283
38402
  "2. Individual events with timestamps: 'error logs from last hour'",
38403
+ "3. TIME SERIES (metric over time): 'errors per hour', 'error trend over time'",
37284
38404
  "",
37285
38405
  "Datasets:",
37286
38406
  "- errors: Exception/crash events with stack traces, usually grouped into issues",
@@ -37297,15 +38417,14 @@ var search_events_default = defineTool({
37297
38417
  "",
37298
38418
  "<examples>",
37299
38419
  "search_events(organizationSlug='my-org', query='how many errors today')",
37300
- "search_events(organizationSlug='my-org', dataset='errors', query='level:error')",
37301
38420
  "search_events(organizationSlug='my-org', dataset='errors', fields=['issue', 'count()'], sort='-count()')",
38421
+ "search_events(organizationSlug='my-org', query='errors per hour last 24h')",
37302
38422
  "search_events(organizationSlug='my-org', dataset='spans', query='span.op:db', sort='-span.duration')",
37303
38423
  "search_events(organizationSlug='my-org', dataset='replays', query='count_errors:>0', sort='-count_errors')",
37304
38424
  "</examples>",
37305
38425
  "",
37306
38426
  "<hints>",
37307
- "- If the user passes a parameter in the form of name/otherName, it's likely in the format of <organizationSlug>/<projectSlug>.",
37308
- "- Parse org/project notation directly without calling find_organizations or find_projects.",
38427
+ "- name/otherName notation means <organizationSlug>/<projectSlug>; parse it directly, don't call find_organizations/find_projects.",
37309
38428
  "- Use fields with aggregate functions like count(), avg(), sum() for statistics",
37310
38429
  "- Sort by -count() for most common, -timestamp for newest",
37311
38430
  "</hints>"
@@ -37328,10 +38447,22 @@ var search_events_default = defineTool({
37328
38447
  destructiveHint: false,
37329
38448
  openWorldHint: true
37330
38449
  },
38450
+ onError(error, params, context$1) {
38451
+ const query = params.query;
38452
+ logWarn("search_events query failed", {
38453
+ loggerScope: ["tools", "search_events"],
38454
+ extra: {
38455
+ errorName: error instanceof Error ? error.name : typeof error,
38456
+ errorMessage: scrubSensitiveText(error instanceof Error ? error.message : String(error)),
38457
+ organizationSlug: (typeof params.organizationSlug === "string" ? params.organizationSlug : null) ?? context$1.constraints.organizationSlug,
38458
+ query: typeof query === "string" ? scrubSensitiveText(query) : null
38459
+ }
38460
+ });
38461
+ },
37331
38462
  async handler(params, context$1) {
37332
38463
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
37333
38464
  const organizationSlug = params.organizationSlug;
37334
- setTag("organization.slug", organizationSlug);
38465
+ setOrganizationContext(organizationSlug);
37335
38466
  if (params.projectSlug) setTag("project.slug", params.projectSlug);
37336
38467
  const inputDataset = params.dataset ?? "errors";
37337
38468
  const hasStructuredQuery = looksLikeSentrySearchSyntax(params.query);
@@ -37352,6 +38483,7 @@ var search_events_default = defineTool({
37352
38483
  let timeParams;
37353
38484
  let explanation;
37354
38485
  let environment = params.environment;
38486
+ let timeSeries = null;
37355
38487
  const explicitSort = params.sort?.trim() || void 0;
37356
38488
  const hasExplicitDataset = params.dataset !== void 0;
37357
38489
  const hasExplicitFields = hasFields(params.fields);
@@ -37362,7 +38494,15 @@ var search_events_default = defineTool({
37362
38494
  const environmentFilter = formatEnvironmentFilter(params.environment);
37363
38495
  const explicitStructuredTraceQuery = shouldTrustStructuredTraceSearch ? appendSearchFilter(params.query ?? "", environmentFilter) : params.query ?? "";
37364
38496
  const canRunWithoutAgent = shouldTrustStructuredTraceSearch && hasExplicitFields && hasExplicitSort;
37365
- if (hasAgentProvider() && !canRunWithoutAgent) {
38497
+ const willRunAgent = hasAgentProvider() && !canRunWithoutAgent;
38498
+ const inputReferencesEnvironment = params.environment != null || collectRequestedEnvironments(null, params.query ?? "").length > 0;
38499
+ const environmentNames = willRunAgent || inputReferencesEnvironment ? await fetchEnvironmentNames({
38500
+ apiService,
38501
+ organizationSlug,
38502
+ projectId
38503
+ }) : [];
38504
+ const knownEnvironments = new Set(environmentNames.map((name$4) => name$4.toLowerCase()));
38505
+ if (willRunAgent) {
37366
38506
  const parsed = await withProviderFallback({
37367
38507
  operation: "search_events.rewrite",
37368
38508
  fallback: () => ({
@@ -37371,6 +38511,7 @@ var search_events_default = defineTool({
37371
38511
  fields: inputDataset === "replays" ? [] : params.fields ?? defaultFieldsForDataset(inputDataset),
37372
38512
  sort: explicitSort || defaultSortForDataset(inputDataset),
37373
38513
  environment: params.environment ?? null,
38514
+ timeSeries: null,
37374
38515
  timeRange: { statsPeriod: params.period ?? "14d" },
37375
38516
  explanation: ""
37376
38517
  }),
@@ -37385,11 +38526,13 @@ var search_events_default = defineTool({
37385
38526
  }),
37386
38527
  organizationSlug,
37387
38528
  apiService,
37388
- projectId
38529
+ projectId,
38530
+ environmentNames
37389
38531
  })).result
37390
38532
  });
37391
38533
  const shouldTrustExplicitSearchParams = shouldTrustStructuredTraceSearch || hasStructuredQuery && parsed.dataset === inputDataset;
37392
- if (!parsed.sort?.trim() && !(shouldTrustExplicitSearchParams && hasExplicitSort)) throw new UserInputError(`Search Events Agent response missing required 'sort' parameter. Received: ${JSON.stringify(parsed, null, 2)}. The agent must specify how to sort results (e.g., '-timestamp' for newest first).`);
38534
+ timeSeries = parsed.timeSeries ?? null;
38535
+ if (!timeSeries && !parsed.sort?.trim() && !(shouldTrustExplicitSearchParams && hasExplicitSort)) throw new UserInputError(`Search Events Agent response missing required 'sort' parameter. Received: ${JSON.stringify(parsed, null, 2)}. The agent must specify how to sort results (e.g., '-timestamp' for newest first).`);
37393
38536
  dataset = shouldTrustStructuredTraceSearch ? inputDataset : parsed.dataset;
37394
38537
  sentryQuery = shouldTrustStructuredTraceSearch ? choosePreservingRepairedQuery({
37395
38538
  originalQuery: params.query ?? "",
@@ -37414,6 +38557,9 @@ var search_events_default = defineTool({
37414
38557
  timeParams = { statsPeriod: params.period ?? "14d" };
37415
38558
  fields = dataset === "replays" ? [] : params.fields ?? defaultFieldsForDataset(dataset);
37416
38559
  }
38560
+ const unknownEnvironments = knownEnvironments.size > 0 ? collectRequestedEnvironments(environment, sentryQuery).filter((name$4) => !knownEnvironments.has(name$4.toLowerCase())) : [];
38561
+ const environmentNote = unknownEnvironments.length > 0 ? formatUnknownEnvironmentNote(unknownEnvironments, environmentNames) : "";
38562
+ const withEnvironmentNote = (text$1) => environmentNote ? `${environmentNote}\n\n${text$1}` : text$1;
37417
38563
  if (dataset === "replays") {
37418
38564
  const replaySort = sortParam || DEFAULT_REPLAY_SORT;
37419
38565
  if (!isValidReplaySort(replaySort)) throw new UserInputError(`Invalid replay sort "${replaySort}". Use a supported replay sort like ${DEFAULT_REPLAY_SORT}, -count_errors, -count_rage_clicks, or -duration.`);
@@ -37436,7 +38582,7 @@ var search_events_default = defineTool({
37436
38582
  ...replayTimeParams
37437
38583
  });
37438
38584
  getActiveSpan()?.setAttribute("gen_ai.tool.call.result.count", replays.length);
37439
- return formatReplayResults({
38585
+ const replayOutput = formatReplayResults({
37440
38586
  replays,
37441
38587
  inputQuery: params.query || sentryQuery || "recent replays",
37442
38588
  includeExplanation: params.includeExplanation,
@@ -37459,6 +38605,30 @@ var search_events_default = defineTool({
37459
38605
  availableToolNames: context$1.availableToolNames,
37460
38606
  directToolNames: context$1.directToolNames
37461
38607
  });
38608
+ return withEnvironmentNote(replayOutput);
38609
+ }
38610
+ if (timeSeries) {
38611
+ const timeSeriesQuery = applyEnvironmentToEventsQuery(dataset, sentryQuery, environment);
38612
+ const series = await apiService.getEventsTimeSeries({
38613
+ organizationSlug,
38614
+ query: timeSeriesQuery,
38615
+ yAxis: timeSeries.yAxis,
38616
+ interval: timeSeries.interval ?? void 0,
38617
+ projectId,
38618
+ dataset,
38619
+ ...timeParams
38620
+ });
38621
+ const statsUrl = apiService.getEventsExplorerUrl(organizationSlug, timeSeriesQuery, projectId, dataset, [timeSeries.yAxis], `-${timeSeries.yAxis}`, [timeSeries.yAxis], [], timeParams.statsPeriod, timeParams.start, timeParams.end);
38622
+ return withEnvironmentNote(formatTimeSeriesResults({
38623
+ series,
38624
+ yAxis: timeSeries.yAxis,
38625
+ interval: timeSeries.interval,
38626
+ inputQuery: params.query || timeSeriesQuery,
38627
+ includeExplanation: params.includeExplanation,
38628
+ explanation,
38629
+ timeRange: timeParams,
38630
+ url: statsUrl
38631
+ }));
37462
38632
  }
37463
38633
  fields = augmentFieldsWithSort(fields, sortParam);
37464
38634
  const requestFields = buildRequestFields(dataset, fields);
@@ -37529,17 +38699,17 @@ var search_events_default = defineTool({
37529
38699
  directToolNames: context$1.directToolNames
37530
38700
  };
37531
38701
  switch (dataset) {
37532
- case "errors": return formatErrorResults(formatParams);
37533
- case "logs": return formatLogResults(formatParams);
37534
- case "spans": return formatSpanResults(formatParams);
37535
- case "profiles": return formatProfileResults(formatParams);
37536
- default: return formatTraceMetricsResults(formatParams);
38702
+ case "errors": return withEnvironmentNote(formatErrorResults(formatParams));
38703
+ case "logs": return withEnvironmentNote(formatLogResults(formatParams));
38704
+ case "spans": return withEnvironmentNote(formatSpanResults(formatParams));
38705
+ case "profiles": return withEnvironmentNote(formatProfileResults(formatParams));
38706
+ default: return withEnvironmentNote(formatTraceMetricsResults(formatParams));
37537
38707
  }
37538
38708
  }
37539
38709
  });
37540
38710
 
37541
38711
  //#endregion
37542
- //#region ../mcp-core/dist/create-team-Bz1tSDLQ.js
38712
+ //#region ../mcp-core/dist/create-team-CgnBfkV1.js
37543
38713
  const createTeamOutputSchema = z.object({ team: z.object({
37544
38714
  id: z.string(),
37545
38715
  slug: z.string(),
@@ -37584,7 +38754,7 @@ var create_team_default = defineTool({
37584
38754
  async handler(params, context$1) {
37585
38755
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
37586
38756
  const organizationSlug = params.organizationSlug;
37587
- setTag("organization.slug", organizationSlug);
38757
+ setOrganizationContext(organizationSlug);
37588
38758
  const team = await apiService.createTeam({
37589
38759
  organizationSlug,
37590
38760
  name: params.name
@@ -37598,7 +38768,7 @@ var create_team_default = defineTool({
37598
38768
  });
37599
38769
 
37600
38770
  //#endregion
37601
- //#region ../mcp-core/dist/create-project-CTQakq9G.js
38771
+ //#region ../mcp-core/dist/create-project-BHO4uN-y.js
37602
38772
  function getUsableClientKey(clientKeys) {
37603
38773
  return clientKeys.find((key) => key.name === "Default" && key.isActive && key.dsn.public) ?? clientKeys.find((key) => key.isActive && key.dsn.public);
37604
38774
  }
@@ -37694,7 +38864,7 @@ var create_project_default = defineTool({
37694
38864
  async handler(params, context$1) {
37695
38865
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
37696
38866
  const organizationSlug = params.organizationSlug;
37697
- setTag("organization.slug", organizationSlug);
38867
+ setOrganizationContext(organizationSlug);
37698
38868
  setTag("team.slug", params.teamSlug);
37699
38869
  const repositoryMatch = params.repository ? findRepositoryMatch(await apiService.listRepos({ organizationSlug }), params.repository) : null;
37700
38870
  const project = await apiService.createProject({
@@ -37754,7 +38924,7 @@ var create_project_default = defineTool({
37754
38924
  });
37755
38925
 
37756
38926
  //#endregion
37757
- //#region ../mcp-core/dist/update-project-BYY10KTt.js
38927
+ //#region ../mcp-core/dist/update-project-CQdb0Elv.js
37758
38928
  const updateProjectOutputSchema = z.object({ project: z.object({
37759
38929
  id: z.string(),
37760
38930
  slug: z.string(),
@@ -37815,7 +38985,7 @@ var update_project_default = defineTool({
37815
38985
  async handler(params, context$1) {
37816
38986
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
37817
38987
  const organizationSlug = params.organizationSlug;
37818
- setTag("organization.slug", organizationSlug);
38988
+ setOrganizationContext(organizationSlug);
37819
38989
  setTag("project.slug", params.projectSlug);
37820
38990
  const hasProjectUpdates = params.name || params.slug || params.platform;
37821
38991
  if (!hasProjectUpdates) throw new UserInputError("At least one project metadata field is required: `name`, `slug`, or `platform`.");
@@ -37843,7 +39013,7 @@ var update_project_default = defineTool({
37843
39013
  });
37844
39014
 
37845
39015
  //#endregion
37846
- //#region ../mcp-core/dist/add-team-to-project-DrTGc_T9.js
39016
+ //#region ../mcp-core/dist/add-team-to-project-CNjkc5mL.js
37847
39017
  const assignedTeamSchema$1 = z.object({
37848
39018
  id: z.string(),
37849
39019
  slug: z.string(),
@@ -37901,7 +39071,7 @@ var add_team_to_project_default = defineTool({
37901
39071
  async handler(params, context$1) {
37902
39072
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
37903
39073
  const organizationSlug = params.organizationSlug;
37904
- setTag("organization.slug", organizationSlug);
39074
+ setOrganizationContext(organizationSlug);
37905
39075
  setTag("project.slug", params.projectSlug);
37906
39076
  setTag("team.slug", params.teamSlug);
37907
39077
  const currentTeams = await apiService.listProjectTeams({
@@ -37930,7 +39100,7 @@ var add_team_to_project_default = defineTool({
37930
39100
  });
37931
39101
 
37932
39102
  //#endregion
37933
- //#region ../mcp-core/dist/remove-team-from-project-CT7eqBf7.js
39103
+ //#region ../mcp-core/dist/remove-team-from-project-CM2_RkK5.js
37934
39104
  const assignedTeamSchema = z.object({
37935
39105
  id: z.string(),
37936
39106
  slug: z.string(),
@@ -37989,7 +39159,7 @@ var remove_team_from_project_default = defineTool({
37989
39159
  async handler(params, context$1) {
37990
39160
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
37991
39161
  const organizationSlug = params.organizationSlug;
37992
- setTag("organization.slug", organizationSlug);
39162
+ setOrganizationContext(organizationSlug);
37993
39163
  setTag("project.slug", params.projectSlug);
37994
39164
  setTag("team.slug", params.teamSlug);
37995
39165
  const currentTeams = await apiService.listProjectTeams({
@@ -38016,7 +39186,7 @@ var remove_team_from_project_default = defineTool({
38016
39186
  });
38017
39187
 
38018
39188
  //#endregion
38019
- //#region ../mcp-core/dist/create-dsn-C-kIpqG7.js
39189
+ //#region ../mcp-core/dist/create-dsn-BtFKEMq7.js
38020
39190
  const createDsnOutputSchema = z.object({ dsn: z.object({
38021
39191
  id: z.string(),
38022
39192
  name: z.string(),
@@ -38065,7 +39235,7 @@ var create_dsn_default = defineTool({
38065
39235
  async handler(params, context$1) {
38066
39236
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
38067
39237
  const organizationSlug = params.organizationSlug;
38068
- setTag("organization.slug", organizationSlug);
39238
+ setOrganizationContext(organizationSlug);
38069
39239
  setTag("project.slug", params.projectSlug);
38070
39240
  const clientKey = await apiService.createClientKey({
38071
39241
  organizationSlug,
@@ -38081,7 +39251,7 @@ var create_dsn_default = defineTool({
38081
39251
  });
38082
39252
 
38083
39253
  //#endregion
38084
- //#region ../mcp-core/dist/find-dsns-DCUQXIHr.js
39254
+ //#region ../mcp-core/dist/find-dsns-CqiIxv7u.js
38085
39255
  const findDsnsOutputSchema = z.object({ dsns: z.array(z.object({
38086
39256
  id: z.string(),
38087
39257
  name: z.string(),
@@ -38116,7 +39286,7 @@ var find_dsns_default = defineTool({
38116
39286
  async handler(params, context$1) {
38117
39287
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
38118
39288
  const organizationSlug = params.organizationSlug;
38119
- setTag("organization.slug", organizationSlug);
39289
+ setOrganizationContext(organizationSlug);
38120
39290
  setTag("project.slug", params.projectSlug);
38121
39291
  const clientKeys = await apiService.listClientKeys({
38122
39292
  organizationSlug,
@@ -38131,7 +39301,7 @@ var find_dsns_default = defineTool({
38131
39301
  });
38132
39302
 
38133
39303
  //#endregion
38134
- //#region ../mcp-core/dist/update-dsn-Ce0IWsRx.js
39304
+ //#region ../mcp-core/dist/update-dsn-DP7ljBh8.js
38135
39305
  var update_dsn_default = defineTool({
38136
39306
  name: "update_dsn",
38137
39307
  skills: ["project-management"],
@@ -38195,7 +39365,7 @@ var update_dsn_default = defineTool({
38195
39365
  async handler(params, context$1) {
38196
39366
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
38197
39367
  const organizationSlug = params.organizationSlug;
38198
- setTag("organization.slug", organizationSlug);
39368
+ setOrganizationContext(organizationSlug);
38199
39369
  setTag("project.slug", params.projectSlug);
38200
39370
  const hasUpdates = params.name !== void 0 || params.isActive !== void 0 || params.disableRateLimit !== void 0 || params.rateLimitWindow !== void 0 || params.rateLimitCount !== void 0 || params.browserSdkVersion !== void 0 || params.loaderHasReplay !== void 0 || params.loaderHasPerformance !== void 0 || params.loaderHasDebug !== void 0 || params.loaderHasFeedback !== void 0 || params.loaderHasLogsAndMetrics !== void 0;
38201
39371
  if (!hasUpdates) throw new UserInputError("At least one setting must be provided to update. Provide one or more of: name, isActive, rateLimitWindow + rateLimitCount, disableRateLimit, browserSdkVersion, or loader options.");
@@ -38265,57 +39435,7 @@ var update_dsn_default = defineTool({
38265
39435
  });
38266
39436
 
38267
39437
  //#endregion
38268
- //#region ../mcp-core/dist/fetch-utils-By3YW-Mv.js
38269
- /**
38270
- * Fetch with timeout using AbortController
38271
- * @param url - The URL to fetch
38272
- * @param options - Standard fetch options
38273
- * @param timeoutMs - Timeout in milliseconds (default: 30000)
38274
- * @returns Promise<Response>
38275
- * @throws Error if request times out
38276
- */
38277
- async function fetchWithTimeout(url, options = {}, timeoutMs = 3e4) {
38278
- const controller = new AbortController();
38279
- const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
38280
- try {
38281
- const response = await fetch(url, {
38282
- ...options,
38283
- signal: controller.signal
38284
- });
38285
- return response;
38286
- } catch (error) {
38287
- if (error instanceof Error && error.name === "AbortError") throw new Error(`Request timeout after ${timeoutMs}ms`);
38288
- throw error;
38289
- } finally {
38290
- clearTimeout(timeoutId);
38291
- }
38292
- }
38293
- /**
38294
- * Retry a function with exponential backoff
38295
- * @param fn - The async function to retry
38296
- * @param options - Retry options
38297
- * @param options.maxRetries - Maximum number of retries (default: 3)
38298
- * @param options.initialDelay - Initial delay in milliseconds (default: 1000)
38299
- * @param options.shouldRetry - Predicate to determine if error should be retried (default: always retry)
38300
- * @returns Promise with the function result
38301
- * @throws The last error if all retries are exhausted
38302
- */
38303
- async function retryWithBackoff(fn, { maxRetries = 3, initialDelay = 1e3, shouldRetry = (error) => true } = {}) {
38304
- let lastError;
38305
- let delay$1 = initialDelay;
38306
- for (let attempt = 0; attempt <= maxRetries; attempt++) try {
38307
- return await fn();
38308
- } catch (error) {
38309
- lastError = error;
38310
- if (attempt === maxRetries || !shouldRetry(error)) throw error;
38311
- await new Promise((resolve$1) => setTimeout(resolve$1, delay$1));
38312
- delay$1 = Math.min(delay$1 * 2, 3e4);
38313
- }
38314
- throw lastError;
38315
- }
38316
-
38317
- //#endregion
38318
- //#region ../mcp-core/dist/analyze-issue-with-seer-Dy01BWPf.js
39438
+ //#region ../mcp-core/dist/analyze-issue-with-seer-Bh4zPWGl.js
38319
39439
  var analyze_issue_with_seer_default = defineTool({
38320
39440
  name: "analyze_issue_with_seer",
38321
39441
  skills: ["seer"],
@@ -38381,7 +39501,7 @@ var analyze_issue_with_seer_default = defineTool({
38381
39501
  issueId: params.issueId,
38382
39502
  issueUrl: params.issueUrl
38383
39503
  });
38384
- setTag("organization.slug", orgSlug);
39504
+ setOrganizationContext(orgSlug);
38385
39505
  const issue = await apiService.getIssue({
38386
39506
  organizationSlug: orgSlug,
38387
39507
  issueId: parsedIssueId
@@ -38426,7 +39546,7 @@ var analyze_issue_with_seer_default = defineTool({
38426
39546
  const existingStatus = autofixState.autofix.status;
38427
39547
  if (isTerminalStatus(existingStatus)) {
38428
39548
  output += `## Analysis ${getStatusDisplayName(existingStatus)}\n\n`;
38429
- output += getOutputForAutofixRun(autofixState.autofix);
39549
+ output += autofixState.formatted?.content ? wrapSeerContent(autofixState.formatted.content, autofixState.autofix.run_id) : getOutputForAutofixRun(autofixState.autofix);
38430
39550
  if (existingStatus !== "completed") {
38431
39551
  output += `\n**Status**: ${existingStatus}\n`;
38432
39552
  output += getHumanInterventionGuidance(existingStatus);
@@ -38449,7 +39569,7 @@ var analyze_issue_with_seer_default = defineTool({
38449
39569
  const status = autofixState.autofix.status;
38450
39570
  if (isTerminalStatus(status)) {
38451
39571
  output += `## Analysis ${getStatusDisplayName(status)}\n\n`;
38452
- output += getOutputForAutofixRun(autofixState.autofix);
39572
+ output += autofixState.formatted?.content ? wrapSeerContent(autofixState.formatted.content, autofixState.autofix.run_id) : getOutputForAutofixRun(autofixState.autofix);
38453
39573
  if (status !== "completed") {
38454
39574
  output += `\n**Status**: ${status}\n`;
38455
39575
  output += getHumanInterventionGuidance(status);
@@ -38491,7 +39611,7 @@ var analyze_issue_with_seer_default = defineTool({
38491
39611
  }
38492
39612
  if (autofixState.autofix) {
38493
39613
  output += `**Current Status**: ${getStatusDisplayName(autofixState.autofix.status)}\n\n`;
38494
- output += getOutputForAutofixRun(autofixState.autofix);
39614
+ output += autofixState.formatted?.content ? wrapSeerContent(autofixState.formatted.content, autofixState.autofix.run_id) : getOutputForAutofixRun(autofixState.autofix);
38495
39615
  }
38496
39616
  output += `\n## Analysis Timed Out\n\n`;
38497
39617
  output += `The analysis is taking longer than expected (>${SEER_TIMEOUT / 1e3}s).\n\n`;
@@ -38504,7 +39624,7 @@ var analyze_issue_with_seer_default = defineTool({
38504
39624
  });
38505
39625
 
38506
39626
  //#endregion
38507
- //#region ../mcp-core/dist/search-docs-DVVQKCxP.js
39627
+ //#region ../mcp-core/dist/search-docs-Tj5IpQIk.js
38508
39628
  var search_docs_default = defineTool({
38509
39629
  name: "search_docs",
38510
39630
  skills: ["inspect", "docs"],
@@ -38601,7 +39721,7 @@ var search_docs_default = defineTool({
38601
39721
  });
38602
39722
 
38603
39723
  //#endregion
38604
- //#region ../mcp-core/dist/get-doc-CnSvhrTG.js
39724
+ //#region ../mcp-core/dist/get-doc-D-DZcOOW.js
38605
39725
  var get_doc_default = defineTool({
38606
39726
  name: "get_doc",
38607
39727
  skills: ["inspect", "docs"],
@@ -38679,7 +39799,7 @@ var get_doc_default = defineTool({
38679
39799
  });
38680
39800
 
38681
39801
  //#endregion
38682
- //#region ../mcp-core/dist/config-lLg5qzu0.js
39802
+ //#region ../mcp-core/dist/config-CCjTO4AY.js
38683
39803
  /**
38684
39804
  * Configuration for the search-issues agent
38685
39805
  */
@@ -38776,7 +39896,7 @@ Use issueFields only when a requested field is not in the built-in fields list.
38776
39896
  Use whoami only for natural-language me references.`;
38777
39897
 
38778
39898
  //#endregion
38779
- //#region ../mcp-core/dist/agent-BIAUd2t1.js
39899
+ //#region ../mcp-core/dist/agent-DyOsplyJ.js
38780
39900
  const searchIssuesAgentOutputSchema = z.object({
38781
39901
  query: z.string().describe("The Sentry issue search query"),
38782
39902
  sort: z.enum([
@@ -38810,7 +39930,7 @@ async function searchIssuesAgent(options) {
38810
39930
  }
38811
39931
 
38812
39932
  //#endregion
38813
- //#region ../mcp-core/dist/formatters-3Z1cdvzp.js
39933
+ //#region ../mcp-core/dist/formatters-CZbnEl5Q.js
38814
39934
  /**
38815
39935
  * Format an explanation for how the input query was translated
38816
39936
  */
@@ -38904,7 +40024,7 @@ function formatDate$1(dateString) {
38904
40024
  }
38905
40025
 
38906
40026
  //#endregion
38907
- //#region ../mcp-core/dist/search-issues-CQ0efOru.js
40027
+ //#region ../mcp-core/dist/search-issues-lbSTiP3S.js
38908
40028
  const ProjectSlugOrIdSchema = z.string().trim().superRefine(validateSlugOrId);
38909
40029
  function buildIssueSearchRepairPrompt(params) {
38910
40030
  return [
@@ -38986,7 +40106,7 @@ var search_issues_default = defineTool({
38986
40106
  },
38987
40107
  async handler(params, context$1) {
38988
40108
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
38989
- setTag("organization.slug", params.organizationSlug);
40109
+ setOrganizationContext(params.organizationSlug);
38990
40110
  if (params.projectSlugOrId) if (isNumericId(params.projectSlugOrId)) setTag("project.id", params.projectSlugOrId);
38991
40111
  else setTag("project.slug", params.projectSlugOrId);
38992
40112
  let query;
@@ -39084,7 +40204,7 @@ var search_issues_default = defineTool({
39084
40204
  });
39085
40205
 
39086
40206
  //#endregion
39087
- //#region ../mcp-core/dist/config-ChOUIglS.js
40207
+ //#region ../mcp-core/dist/config-Nif76Shh.js
39088
40208
  const systemPrompt$1 = `You are a Sentry issue event filter translator. Your job is to:
39089
40209
  1. Translate natural language queries into Sentry tag filters for events within a SPECIFIC issue
39090
40210
  2. Select appropriate fields to return in the results
@@ -39417,7 +40537,7 @@ const EXAMPLE_QUERIES = [
39417
40537
  ];
39418
40538
 
39419
40539
  //#endregion
39420
- //#region ../mcp-core/dist/utils-_4r1K2PE.js
40540
+ //#region ../mcp-core/dist/utils-DeCBYEnS.js
39421
40541
  /**
39422
40542
  * Create a tool for the agent to query available tags and fields for issue events
39423
40543
  * The tool is pre-bound with the API service and organization configured for the appropriate region
@@ -39500,7 +40620,7 @@ Received: ${params.issueUrl}`);
39500
40620
  }
39501
40621
 
39502
40622
  //#endregion
39503
- //#region ../mcp-core/dist/agent-Bbb5dUlD.js
40623
+ //#region ../mcp-core/dist/agent-DTdycAuW.js
39504
40624
  const searchIssueEventsAgentOutputSchema = z.object({
39505
40625
  query: z.string().describe("Sentry query filters for tags/fields (NOT including issue: prefix - handler adds that)"),
39506
40626
  fields: z.array(z.string()).describe("Array of field names to return in results"),
@@ -39542,7 +40662,7 @@ async function searchIssueEventsAgent(options) {
39542
40662
  }
39543
40663
 
39544
40664
  //#endregion
39545
- //#region ../mcp-core/dist/search-issue-events-fYjr_r6r.js
40665
+ //#region ../mcp-core/dist/search-issue-events-Ck9S6CNC.js
39546
40666
  function buildIssueEventSearchRepairPrompt(params) {
39547
40667
  return [
39548
40668
  "Fix this Sentry issue event search request.",
@@ -39606,7 +40726,7 @@ var search_issue_events_default = defineTool({
39606
40726
  issueUrl: params.issueUrl
39607
40727
  });
39608
40728
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
39609
- setTag("organization.slug", organizationSlug);
40729
+ setOrganizationContext(organizationSlug);
39610
40730
  setTag("issue.id", issueId);
39611
40731
  if (params.projectSlug) setTag("project.slug", params.projectSlug);
39612
40732
  await ensureIssueWithinProjectConstraint({
@@ -39695,7 +40815,7 @@ var search_issue_events_default = defineTool({
39695
40815
  });
39696
40816
 
39697
40817
  //#endregion
39698
- //#region ../mcp-core/dist/formatter-UsEdX-DU.js
40818
+ //#region ../mcp-core/dist/formatter-ffKOVbDF.js
39699
40819
  /**
39700
40820
  * Maps a change type to its corresponding status icon.
39701
40821
  */
@@ -40071,7 +41191,7 @@ function formatSdkSummary(profile) {
40071
41191
  }
40072
41192
 
40073
41193
  //#endregion
40074
- //#region ../mcp-core/dist/get-profile-CilEVKTg.js
41194
+ //#region ../mcp-core/dist/get-profile-4EwZiRri.js
40075
41195
  /**
40076
41196
  * Resolves profile parameters from URL or explicit params.
40077
41197
  * URL takes precedence if provided and valid.
@@ -40201,7 +41321,7 @@ var get_profile_default = defineTool({
40201
41321
  setTag("project.slug", String(projectSlugOrId));
40202
41322
  setTag("project.id", String(project.id));
40203
41323
  }
40204
- setTag("organization.slug", organizationSlug);
41324
+ setOrganizationContext(organizationSlug);
40205
41325
  setTag("transaction.name", transactionName);
40206
41326
  if (params.compareAgainstPeriod) {
40207
41327
  setTag("baseline.period", params.compareAgainstPeriod);
@@ -40289,7 +41409,7 @@ var get_profile_default = defineTool({
40289
41409
  });
40290
41410
 
40291
41411
  //#endregion
40292
- //#region ../mcp-core/dist/get-profile-details-B7TCia0B.js
41412
+ //#region ../mcp-core/dist/get-profile-details-KNM3CXky.js
40293
41413
  function resolveProfileDetailsParams(params) {
40294
41414
  if (params.profileUrl) {
40295
41415
  if (!isProfileUrl(params.profileUrl)) throw new UserInputError("Invalid profile URL. URL must point to a Sentry profile resource.");
@@ -40447,7 +41567,7 @@ var get_profile_details_default = defineTool({
40447
41567
  regionUrl: params.regionUrl
40448
41568
  });
40449
41569
  const apiService = apiServiceFromContext(context$1, { regionUrl: regionUrl ?? void 0 });
40450
- setTag("organization.slug", resolved.organizationSlug);
41570
+ setOrganizationContext(resolved.organizationSlug);
40451
41571
  if (resolved.mode === "transaction") {
40452
41572
  setTag("profile.id", resolved.profileId);
40453
41573
  const isNumericProjectInput = typeof resolved.projectSlugOrId === "number" || isNumericId(String(resolved.projectSlugOrId));
@@ -40517,7 +41637,7 @@ var get_profile_details_default = defineTool({
40517
41637
  });
40518
41638
 
40519
41639
  //#endregion
40520
- //#region ../mcp-core/dist/get-agent-conversation-details-DTJR8hFg.js
41640
+ //#region ../mcp-core/dist/get-agent-conversation-details-bM0VVNAG.js
40521
41641
  function withoutUndefined(value) {
40522
41642
  return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0));
40523
41643
  }
@@ -40905,7 +42025,7 @@ var get_agent_conversation_details_default = defineTool({
40905
42025
  },
40906
42026
  outputSchema: aiConversationDetailsOutputSchema,
40907
42027
  async handler(params, context$1) {
40908
- setTag("organization.slug", params.organizationSlug);
42028
+ setOrganizationContext(params.organizationSlug);
40909
42029
  setTag("ai_conversation.id", params.conversationId);
40910
42030
  if (params.start && !params.end || !params.start && params.end) throw new UserInputError("`start` and `end` must be provided together.");
40911
42031
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
@@ -40933,7 +42053,7 @@ var get_agent_conversation_details_default = defineTool({
40933
42053
  });
40934
42054
 
40935
42055
  //#endregion
40936
- //#region ../mcp-core/dist/formatting-C_fxwUSt.js
42056
+ //#region ../mcp-core/dist/formatting-B1ckR5H7.js
40937
42057
  function getSnapshotImageDisplayName(img) {
40938
42058
  return img.display_name || img.image_file_name || "unknown";
40939
42059
  }
@@ -41027,7 +42147,7 @@ function isPlainObject$2(value) {
41027
42147
  }
41028
42148
 
41029
42149
  //#endregion
41030
- //#region ../mcp-core/dist/handlers-CCIzlp0E.js
42150
+ //#region ../mcp-core/dist/handlers-DhPeWak0.js
41031
42151
  function fullResolutionHint({ organizationSlug, snapshotId, imageIdentifier, experimentalMode, availableToolNames, directToolNames }) {
41032
42152
  return `- **Full Resolution**: ${formatToolCallInstruction({
41033
42153
  toolName: "get_snapshot_image",
@@ -41293,7 +42413,7 @@ async function fetchSnapshotSummary(apiService, organizationSlug, snapshotId, so
41293
42413
  }
41294
42414
 
41295
42415
  //#endregion
41296
- //#region ../mcp-core/dist/get-snapshot-Ce1Z98WR.js
42416
+ //#region ../mcp-core/dist/get-snapshot-P1FuvUwa.js
41297
42417
  var get_snapshot_default = defineTool({
41298
42418
  name: "get_snapshot",
41299
42419
  skills: ["inspect"],
@@ -41358,7 +42478,7 @@ var get_snapshot_default = defineTool({
41358
42478
  },
41359
42479
  async handler(params, context$1) {
41360
42480
  if (!params.organizationSlug || !params.snapshotId) throw new UserInputError("Provide both organizationSlug and snapshotId. Use get_sentry_resource for snapshot URLs.");
41361
- setTag("organization.slug", params.organizationSlug);
42481
+ setOrganizationContext(params.organizationSlug);
41362
42482
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
41363
42483
  return fetchSnapshotSummary(apiService, params.organizationSlug, params.snapshotId, null, {
41364
42484
  showUnmodified: params.showUnmodified,
@@ -41371,7 +42491,7 @@ var get_snapshot_default = defineTool({
41371
42491
  });
41372
42492
 
41373
42493
  //#endregion
41374
- //#region ../mcp-core/dist/get-snapshot-image-CWtW-DQz.js
42494
+ //#region ../mcp-core/dist/get-snapshot-image-DjtwEpMj.js
41375
42495
  var get_snapshot_image_default = defineTool({
41376
42496
  name: "get_snapshot_image",
41377
42497
  skills: ["inspect"],
@@ -41421,7 +42541,7 @@ var get_snapshot_image_default = defineTool({
41421
42541
  },
41422
42542
  async handler(params, context$1) {
41423
42543
  if (!params.organizationSlug || !params.snapshotId) throw new UserInputError("Provide both organizationSlug and snapshotId. Use get_sentry_resource for snapshot URLs.");
41424
- setTag("organization.slug", params.organizationSlug);
42544
+ setOrganizationContext(params.organizationSlug);
41425
42545
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
41426
42546
  return fetchSnapshotImage(apiService, params.organizationSlug, params.snapshotId, params.imageIdentifier, params.imageResolution, {
41427
42547
  experimentalMode: context$1.experimentalMode ?? false,
@@ -41432,7 +42552,7 @@ var get_snapshot_image_default = defineTool({
41432
42552
  });
41433
42553
 
41434
42554
  //#endregion
41435
- //#region ../mcp-core/dist/get-sentry-resource-DAx17Rhc.js
42555
+ //#region ../mcp-core/dist/get-sentry-resource-BXVp2SKN.js
41436
42556
  /** Types with full API integration. */
41437
42557
  const FULLY_SUPPORTED_TYPES = [
41438
42558
  "issue",
@@ -41727,7 +42847,7 @@ var get_sentry_resource_default = defineTool({
41727
42847
  projectSlug: context$1.constraints.projectSlug
41728
42848
  });
41729
42849
  setTag("resource.type", resolved.type);
41730
- setTag("organization.slug", resolved.organizationSlug);
42850
+ setOrganizationContext(resolved.organizationSlug);
41731
42851
  if (resolved.spanId) setTag("trace.span_id", resolved.spanId);
41732
42852
  getActiveSpan()?.setAttribute("app.resource.type", resolved.type);
41733
42853
  if (resolved.type === "release") {
@@ -41820,7 +42940,7 @@ var get_sentry_resource_default = defineTool({
41820
42940
  });
41821
42941
 
41822
42942
  //#endregion
41823
- //#region ../mcp-core/dist/get-latest-base-snapshot-KoSAQyLF.js
42943
+ //#region ../mcp-core/dist/get-latest-base-snapshot-CEkWKEZJ.js
41824
42944
  var get_latest_base_snapshot_default = defineTool({
41825
42945
  name: "get_latest_base_snapshot",
41826
42946
  skills: ["inspect"],
@@ -41873,7 +42993,7 @@ var get_latest_base_snapshot_default = defineTool({
41873
42993
  openWorldHint: true
41874
42994
  },
41875
42995
  async handler(params, context$1) {
41876
- setTag("organization.slug", params.organizationSlug);
42996
+ setOrganizationContext(params.organizationSlug);
41877
42997
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
41878
42998
  const project = params.project ?? void 0;
41879
42999
  const projectId = project && isNumericId(project) ? project : void 0;
@@ -41916,9 +43036,15 @@ var get_latest_base_snapshot_default = defineTool({
41916
43036
  });
41917
43037
 
41918
43038
  //#endregion
41919
- //#region ../mcp-core/dist/search-agent-conversations-CUhIOq09.js
43039
+ //#region ../mcp-core/dist/search-agent-conversations-BGO_38e-.js
41920
43040
  const PREVIEW_LENGTH = 240;
41921
43041
  const TRACE_ID_SAMPLE_SIZE = 3;
43042
+ const usdFormatter = new Intl.NumberFormat("en-US", {
43043
+ style: "currency",
43044
+ currency: "USD",
43045
+ notation: "compact",
43046
+ maximumSignificantDigits: 3
43047
+ });
41922
43048
  const aiConversationSearchResultSchema = z.object({
41923
43049
  conversationId: z.string(),
41924
43050
  title: z.string().nullable(),
@@ -41931,7 +43057,7 @@ const aiConversationSearchResultSchema = z.object({
41931
43057
  toolCallCount: z.number(),
41932
43058
  toolErrorCount: z.number(),
41933
43059
  totalTokens: z.number(),
41934
- totalCost: z.number(),
43060
+ totalCost: z.string(),
41935
43061
  traceCount: z.number(),
41936
43062
  sampleTraceIds: z.array(z.string()),
41937
43063
  firstInputPreview: z.string().nullable(),
@@ -41977,6 +43103,11 @@ function previewText(value) {
41977
43103
  if (value == null || value.length <= PREVIEW_LENGTH) return value;
41978
43104
  return `${value.slice(0, PREVIEW_LENGTH - 3)}...`;
41979
43105
  }
43106
+ function formatLLMCost(cost) {
43107
+ if (cost === 0) return "—";
43108
+ if (cost > 0 && cost < .01) return "<$0.01";
43109
+ return usdFormatter.format(cost);
43110
+ }
41980
43111
  function projectUser(user) {
41981
43112
  if (!user) return null;
41982
43113
  return {
@@ -42003,7 +43134,7 @@ function buildArtifact(apiService, organizationSlug, conversations, nextCursor,
42003
43134
  aiCallCount: llmCalls,
42004
43135
  toolCallCount: toolCalls,
42005
43136
  totalTokens,
42006
- totalCost,
43137
+ totalCost: formatLLMCost(totalCost),
42007
43138
  startTimestamp,
42008
43139
  endTimestamp,
42009
43140
  traceCount,
@@ -42031,7 +43162,7 @@ var search_agent_conversations_default = defineTool({
42031
43162
  "Search Sentry Agent Conversations, formerly called AI Conversations, and return one summary row per conversation.",
42032
43163
  "",
42033
43164
  "Use this tool to find or list Agent Conversations. Results are conversation summaries, not raw span rows.",
42034
- "Each row includes title (when available), cost, tokens, call counts, previews, and other list metadata.",
43165
+ "Each row includes title (when available), USD cost, tokens, call counts, previews, and other list metadata.",
42035
43166
  "Use get_agent_conversation_details with a conversationId to fetch the transcript. Use get_sentry_resource for Sentry conversation URLs.",
42036
43167
  "",
42037
43168
  "<examples>",
@@ -42062,7 +43193,7 @@ var search_agent_conversations_default = defineTool({
42062
43193
  const requestedPeriod = params.period ?? "30d";
42063
43194
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
42064
43195
  const organizationSlug = params.organizationSlug;
42065
- setTag("organization.slug", organizationSlug);
43196
+ setOrganizationContext(organizationSlug);
42066
43197
  const projectIds = await resolveProjectIds({
42067
43198
  apiService,
42068
43199
  organizationSlug,
@@ -42095,7 +43226,7 @@ var search_agent_conversations_default = defineTool({
42095
43226
  });
42096
43227
 
42097
43228
  //#endregion
42098
- //#region ../mcp-core/dist/add-issue-note-DqTid9mJ.js
43229
+ //#region ../mcp-core/dist/add-issue-note-YI_XzMvf.js
42099
43230
  function formatComment(comment) {
42100
43231
  const actor = comment.user ? formatActor(comment.user) : "current user";
42101
43232
  const text$1 = comment.data ? readString(comment.data, "text") : null;
@@ -42145,7 +43276,7 @@ var add_issue_note_default = defineTool({
42145
43276
  organizationSlug: params.organizationSlug ?? context$1.constraints.organizationSlug
42146
43277
  });
42147
43278
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? context$1.constraints.regionUrl ?? void 0 });
42148
- setTag("organization.slug", parsed.organizationSlug);
43279
+ setOrganizationContext(parsed.organizationSlug);
42149
43280
  setTag("issue.id", parsed.issueId);
42150
43281
  await ensureIssueWithinProjectConstraint({
42151
43282
  apiService,
@@ -42171,7 +43302,7 @@ var add_issue_note_default = defineTool({
42171
43302
  });
42172
43303
 
42173
43304
  //#endregion
42174
- //#region ../mcp-core/dist/onboarding-status-update-ZaTsL300.js
43305
+ //#region ../mcp-core/dist/onboarding-status-update-BJR7w05r.js
42175
43306
  const updateBaseSchema = z.object({
42176
43307
  status: AgenticOnboardingStageStatusUpdateSchema.describe("The stage's current status."),
42177
43308
  runStatus: AgenticOnboardingRunStatusUpdateSchema.optional().describe("Set only when the entire onboarding run has completed or failed."),
@@ -42224,7 +43355,7 @@ var onboarding_status_update_default = defineTool({
42224
43355
  },
42225
43356
  async handler(params, context$1) {
42226
43357
  const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? context$1.constraints.regionUrl ?? void 0 });
42227
- setTag("organization.slug", params.organizationSlug);
43358
+ setOrganizationContext(params.organizationSlug);
42228
43359
  const update = AgenticOnboardingStatusUpdateSchema.parse({
42229
43360
  schemaVersion: 1,
42230
43361
  runToken: params.runToken,
@@ -42239,7 +43370,7 @@ var onboarding_status_update_default = defineTool({
42239
43370
  });
42240
43371
 
42241
43372
  //#endregion
42242
- //#region ../mcp-core/dist/catalog-DaTB1cy-.js
43373
+ //#region ../mcp-core/dist/catalog-CZAR_B3F.js
42243
43374
  const legacyGetAIConversationDetails = {
42244
43375
  ...get_agent_conversation_details_default,
42245
43376
  name: "get_ai_conversation_details",
@@ -42287,6 +43418,7 @@ const catalogTools = {
42287
43418
  delete_uptime_monitor: delete_uptime_monitor_default,
42288
43419
  find_alert_rules: find_alert_rules_default,
42289
43420
  get_alert_rule: get_alert_rule_default,
43421
+ get_alert_options: get_alert_options_default,
42290
43422
  get_issue_details: get_issue_details_default,
42291
43423
  get_event_stacktrace: get_event_stacktrace_default,
42292
43424
  get_issue_activity: get_issue_activity_default,
@@ -42314,6 +43446,7 @@ const catalogTools = {
42314
43446
  search_issue_events: search_issue_events_default,
42315
43447
  get_profile: get_profile_default,
42316
43448
  get_profile_details: get_profile_details_default,
43449
+ get_sentry_mcp_info: get_sentry_mcp_info_default,
42317
43450
  get_sentry_resource: get_sentry_resource_default,
42318
43451
  get_snapshot: get_snapshot_default,
42319
43452
  get_snapshot_image: get_snapshot_image_default,
@@ -42328,7 +43461,7 @@ const catalogTools = {
42328
43461
  var catalog_default = catalogTools;
42329
43462
 
42330
43463
  //#endregion
42331
- //#region ../mcp-core/dist/schema-BuKqZlvC.js
43464
+ //#region ../mcp-core/dist/schema-Bf6vaXky.js
42332
43465
  function zodFieldMapToJsonSchema(fieldMap) {
42333
43466
  const zodObject = Object.keys(fieldMap).length > 0 ? z.object(fieldMap) : z.object({});
42334
43467
  const { $schema: _,...jsonSchema$1 } = z.toJSONSchema(zodObject, {
@@ -42340,7 +43473,7 @@ function zodFieldMapToJsonSchema(fieldMap) {
42340
43473
  }
42341
43474
 
42342
43475
  //#endregion
42343
- //#region ../mcp-core/dist/search-CX6pdulw.js
43476
+ //#region ../mcp-core/dist/search--TO414uy.js
42344
43477
  function tokenize(value) {
42345
43478
  return value.toLowerCase().split(/[^a-z0-9_]+/).map((token) => token.trim()).filter(Boolean);
42346
43479
  }
@@ -42391,7 +43524,7 @@ function searchToolCatalog({ tools, context: context$1, query, limit }) {
42391
43524
  }
42392
43525
 
42393
43526
  //#endregion
42394
- //#region ../mcp-core/dist/search-tools-CbtWC7w4.js
43527
+ //#region ../mcp-core/dist/search-tools-DD_Fpn20.js
42395
43528
  const DEFAULT_LIMIT = 8;
42396
43529
  const MAX_LIMIT = 20;
42397
43530
  const toolAnnotationsOutputSchema = z.object({
@@ -42473,7 +43606,7 @@ function createSearchToolsTool(getTools) {
42473
43606
  }
42474
43607
 
42475
43608
  //#endregion
42476
- //#region ../mcp-core/dist/execute-tool-B_06lhoJ.js
43609
+ //#region ../mcp-core/dist/execute-tool-Z6g9XYm0.js
42477
43610
  function setToolArgumentAttributes(span, params) {
42478
43611
  for (const [key, value] of Object.entries(params)) {
42479
43612
  const attributeValue = value == null || typeof value === "object" ? JSON.stringify(value) : value;
@@ -42502,6 +43635,7 @@ async function executeCatalogToolWithSpan({ tool: tool$1, params, context: conte
42502
43635
  } catch (error) {
42503
43636
  span.setStatus({ code: 2 });
42504
43637
  if (!isExpectedToolError(error)) span.recordException(error);
43638
+ recordToolFailure(tool$1, error, params, context$1);
42505
43639
  throw error;
42506
43640
  }
42507
43641
  });
@@ -42557,7 +43691,7 @@ function createExecuteTool(getTools) {
42557
43691
  }
42558
43692
 
42559
43693
  //#endregion
42560
- //#region ../mcp-core/dist/tools-fGO-TOBm.js
43694
+ //#region ../mcp-core/dist/tools-EVTUbO4b.js
42561
43695
  function getAllTools() {
42562
43696
  return allTools;
42563
43697
  }
@@ -59264,8 +60398,8 @@ function configureServer({ server, context: context$1, experimentalMode = false,
59264
60398
  if (context$1.clientFamily) setTag("app.client.family", context$1.clientFamily);
59265
60399
  if (context$1.transport) setTag("app.transport", context$1.transport);
59266
60400
  setTag("app.server.mode.experimental", experimentalMode);
60401
+ const rawParams = params && typeof params === "object" && !Array.isArray(params) ? params : {};
59267
60402
  try {
59268
- const rawParams = params && typeof params === "object" && !Array.isArray(params) ? params : {};
59269
60403
  const paramsWithConstraints = injectConstraintParams(rawParams, tool$1, contextWithToolAvailability);
59270
60404
  if (activeSpan) for (const [key, value] of Object.entries(paramsWithConstraints)) {
59271
60405
  const attributeValue = value == null || typeof value === "object" ? JSON.stringify(value) : value;
@@ -59293,6 +60427,7 @@ function configureServer({ server, context: context$1, experimentalMode = false,
59293
60427
  if (isApiAuthenticationErrorDeep(error) && context$1.onUpstreamUnauthorized) try {
59294
60428
  await context$1.onUpstreamUnauthorized();
59295
60429
  } catch {}
60430
+ recordToolFailure(tool$1, error, rawParams, contextWithToolAvailability);
59296
60431
  return {
59297
60432
  content: [{
59298
60433
  type: "text",
@@ -59311,111 +60446,6 @@ function configureServer({ server, context: context$1, experimentalMode = false,
59311
60446
  return registrations;
59312
60447
  }
59313
60448
 
59314
- //#endregion
59315
- //#region ../mcp-core/dist/sentry-D99fvngC.js
59316
- const SCRUB_PATTERNS = [
59317
- {
59318
- pattern: /\bsk-[a-zA-Z0-9]{48}\b/g,
59319
- replacement: "[REDACTED_OPENAI_KEY]",
59320
- description: "OpenAI API key"
59321
- },
59322
- {
59323
- pattern: /\bBearer\s+[a-zA-Z0-9\-._~+/]+={0,}/g,
59324
- replacement: "Bearer [REDACTED_TOKEN]",
59325
- description: "Bearer token"
59326
- },
59327
- {
59328
- pattern: /\bsntrys_[a-zA-Z0-9_]+\b/g,
59329
- replacement: "[REDACTED_SENTRY_TOKEN]",
59330
- description: "Sentry access token"
59331
- }
59332
- ];
59333
- const MAX_SCRUB_DEPTH = 20;
59334
- /**
59335
- * Recursively scrub sensitive data from any value.
59336
- * Returns tuple of [scrubbedValue, didScrub, descriptionsOfMatchedPatterns]
59337
- */
59338
- function scrubValue(value, depth = 0) {
59339
- if (depth >= MAX_SCRUB_DEPTH) return [
59340
- "[MAX_DEPTH_EXCEEDED]",
59341
- false,
59342
- []
59343
- ];
59344
- if (typeof value === "string") {
59345
- let scrubbed = value;
59346
- let didScrub = false;
59347
- const matchedDescriptions = [];
59348
- for (const { pattern, replacement, description: description$73 } of SCRUB_PATTERNS) {
59349
- pattern.lastIndex = 0;
59350
- if (pattern.test(scrubbed)) {
59351
- didScrub = true;
59352
- matchedDescriptions.push(description$73);
59353
- pattern.lastIndex = 0;
59354
- scrubbed = scrubbed.replace(pattern, replacement);
59355
- }
59356
- }
59357
- return [
59358
- scrubbed,
59359
- didScrub,
59360
- matchedDescriptions
59361
- ];
59362
- }
59363
- if (Array.isArray(value)) {
59364
- let arrayDidScrub = false;
59365
- const arrayDescriptions = [];
59366
- const scrubbedArray = value.map((item) => {
59367
- const [scrubbed, didScrub, descriptions] = scrubValue(item, depth + 1);
59368
- if (didScrub) {
59369
- arrayDidScrub = true;
59370
- arrayDescriptions.push(...descriptions);
59371
- }
59372
- return scrubbed;
59373
- });
59374
- return [
59375
- scrubbedArray,
59376
- arrayDidScrub,
59377
- arrayDescriptions
59378
- ];
59379
- }
59380
- if (value && typeof value === "object") {
59381
- let objectDidScrub = false;
59382
- const objectDescriptions = [];
59383
- const scrubbed = {};
59384
- for (const [key, val] of Object.entries(value)) {
59385
- const [scrubbedVal, didScrub, descriptions] = scrubValue(val, depth + 1);
59386
- if (didScrub) {
59387
- objectDidScrub = true;
59388
- objectDescriptions.push(...descriptions);
59389
- }
59390
- scrubbed[key] = scrubbedVal;
59391
- }
59392
- return [
59393
- scrubbed,
59394
- objectDidScrub,
59395
- objectDescriptions
59396
- ];
59397
- }
59398
- return [
59399
- value,
59400
- false,
59401
- []
59402
- ];
59403
- }
59404
- /**
59405
- * Sentry beforeSend hook that scrubs sensitive data from events
59406
- * and applies custom fingerprinting for specific error types.
59407
- */
59408
- function sentryBeforeSend(event, hint) {
59409
- const firstException = event?.exception?.values?.[0];
59410
- if (firstException?.type === "AI_APICallError" && firstException.value) event.fingerprint = ["AI_APICallError", firstException.value];
59411
- const [scrubbedEvent, didScrub, descriptions] = scrubValue(event);
59412
- if (didScrub) {
59413
- const uniqueDescriptions = [...new Set(descriptions)];
59414
- console.warn(`[Sentry] Event contained sensitive data: ${uniqueDescriptions.join(", ")}`);
59415
- }
59416
- return scrubbedEvent;
59417
- }
59418
-
59419
60449
  //#endregion
59420
60450
  //#region src/index.ts
59421
60451
  const packageName = "@sentry/mcp-server";
@@ -59549,7 +60579,6 @@ async function main() {
59549
60579
  }
59550
60580
  Sentry.init({
59551
60581
  dsn: cfg.sentryDsn,
59552
- sendDefaultPii: true,
59553
60582
  tracesSampleRate: 1,
59554
60583
  beforeSend: sentryBeforeSend,
59555
60584
  initialScope: { tags: {
@@ -59582,17 +60611,28 @@ async function main() {
59582
60611
  }
59583
60612
  process.on("SIGTERM", () => shutdown("SIGTERM"));
59584
60613
  process.on("SIGINT", () => shutdown("SIGINT"));
59585
- process.on("uncaughtException", async (error) => {
59586
- console.error("Uncaught exception:", error);
59587
- Sentry.captureException(error);
59588
- await Sentry.flush(SENTRY_TIMEOUT);
59589
- process.exit(1);
60614
+ let exiting = false;
60615
+ function exitAfterError(error, label) {
60616
+ if (exiting) {
60617
+ process.exit(1);
60618
+ return;
60619
+ }
60620
+ exiting = true;
60621
+ try {
60622
+ console.error(label, error);
60623
+ } catch {}
60624
+ try {
60625
+ Sentry.captureException(error);
60626
+ } catch {}
60627
+ const timer = setTimeout(() => process.exit(1), SENTRY_TIMEOUT);
60628
+ timer.unref();
60629
+ Sentry.flush(SENTRY_TIMEOUT).finally(() => process.exit(1));
60630
+ }
60631
+ process.on("uncaughtException", (error) => {
60632
+ exitAfterError(error, "Uncaught exception:");
59590
60633
  });
59591
- process.on("unhandledRejection", async (reason) => {
59592
- console.error("Unhandled rejection:", reason);
59593
- Sentry.captureException(reason);
59594
- await Sentry.flush(SENTRY_TIMEOUT);
59595
- process.exit(1);
60634
+ process.on("unhandledRejection", (reason) => {
60635
+ exitAfterError(reason, "Unhandled rejection:");
59596
60636
  });
59597
60637
  const context$1 = {
59598
60638
  accessToken: cfg.accessToken,
@@ -59613,11 +60653,8 @@ async function main() {
59613
60653
  context: context$1,
59614
60654
  experimentalMode: cli.experimental
59615
60655
  });
59616
- startStdio(server, context$1).catch(async (err) => {
59617
- console.error("Server error:", err);
59618
- Sentry.captureException(err);
59619
- await Sentry.flush(SENTRY_TIMEOUT);
59620
- process.exit(1);
60656
+ startStdio(server, context$1).catch((err) => {
60657
+ exitAfterError(err, "Server error:");
59621
60658
  });
59622
60659
  }
59623
60660
  main().catch((err) => {