@sentry/mcp-server 0.30.0 → 0.32.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 (136) hide show
  1. package/dist/auth/constants.cjs +9 -0
  2. package/dist/auth/constants.d.cts +31 -0
  3. package/dist/auth/constants.d.cts.map +1 -0
  4. package/dist/auth/constants.d.ts +31 -0
  5. package/dist/auth/constants.d.ts.map +1 -0
  6. package/dist/auth/constants.js +3 -0
  7. package/dist/auth/device-code-flow.cjs +10 -0
  8. package/dist/auth/device-code-flow.d.cts +34 -0
  9. package/dist/auth/device-code-flow.d.cts.map +1 -0
  10. package/dist/auth/device-code-flow.d.ts +34 -0
  11. package/dist/auth/device-code-flow.d.ts.map +1 -0
  12. package/dist/auth/device-code-flow.js +6 -0
  13. package/dist/auth/resolve-token.cjs +8 -0
  14. package/dist/auth/resolve-token.d.cts +17 -0
  15. package/dist/auth/resolve-token.d.cts.map +1 -0
  16. package/dist/auth/resolve-token.d.ts +17 -0
  17. package/dist/auth/resolve-token.d.ts.map +1 -0
  18. package/dist/auth/resolve-token.js +8 -0
  19. package/dist/auth/token-cache.cjs +5 -0
  20. package/dist/auth/token-cache.d.cts +11 -0
  21. package/dist/auth/token-cache.d.cts.map +1 -0
  22. package/dist/auth/token-cache.d.ts +11 -0
  23. package/dist/auth/token-cache.d.ts.map +1 -0
  24. package/dist/auth/token-cache.js +3 -0
  25. package/dist/auth/types.cjs +7 -0
  26. package/dist/auth/types.d.cts +2 -0
  27. package/dist/auth/types.d.ts +2 -0
  28. package/dist/auth/types.js +3 -0
  29. package/dist/auth-DamN9R04.cjs +90 -0
  30. package/dist/auth-DamN9R04.cjs.map +1 -0
  31. package/dist/auth-XNi9K4Nz.js +79 -0
  32. package/dist/auth-XNi9K4Nz.js.map +1 -0
  33. package/dist/cli/commands/auth.cjs +11 -0
  34. package/dist/cli/commands/auth.d.cts +8 -0
  35. package/dist/cli/commands/auth.d.cts.map +1 -0
  36. package/dist/cli/commands/auth.d.ts +8 -0
  37. package/dist/cli/commands/auth.d.ts.map +1 -0
  38. package/dist/cli/commands/auth.js +10 -0
  39. package/dist/cli/parse.cjs +1 -1
  40. package/dist/cli/parse.d.cts +1 -1
  41. package/dist/cli/parse.d.cts.map +1 -1
  42. package/dist/cli/parse.d.ts +1 -1
  43. package/dist/cli/parse.d.ts.map +1 -1
  44. package/dist/cli/parse.js +1 -1
  45. package/dist/cli/resolve.cjs +4 -2
  46. package/dist/cli/resolve.d.cts +9 -3
  47. package/dist/cli/resolve.d.cts.map +1 -1
  48. package/dist/cli/resolve.d.ts +9 -3
  49. package/dist/cli/resolve.d.ts.map +1 -1
  50. package/dist/cli/resolve.js +3 -2
  51. package/dist/cli/types.d.cts +2 -2
  52. package/dist/cli/types.d.ts +2 -2
  53. package/dist/cli/usage.cjs +1 -1
  54. package/dist/cli/usage.js +1 -1
  55. package/dist/{config-BYPjNBPX-CxPh7iM8.cjs → config-D1QOSX9W-BurxE_FB.cjs} +4 -4
  56. package/dist/{config-BYPjNBPX-CxPh7iM8.cjs.map → config-D1QOSX9W-BurxE_FB.cjs.map} +1 -1
  57. package/dist/{config-BYPjNBPX-CdPOenPb.js → config-D1QOSX9W-CtF1qegU.js} +4 -4
  58. package/dist/{config-BYPjNBPX-CdPOenPb.js.map → config-D1QOSX9W-CtF1qegU.js.map} +1 -1
  59. package/dist/config-DvaRyDc4.cjs +7 -0
  60. package/dist/{config-NKdlAxBc.js → config-UqbHNH-n.js} +1 -1
  61. package/dist/{resolve-Ci97NUwJ.js → constants-CnQOQOfw.js} +43 -122
  62. package/dist/constants-CnQOQOfw.js.map +1 -0
  63. package/dist/{resolve-CxQZsYhh.cjs → constants-zXY4MUBL.cjs} +84 -133
  64. package/dist/constants-zXY4MUBL.cjs.map +1 -0
  65. package/dist/device-code-flow-B-sYi7io.cjs +154 -0
  66. package/dist/device-code-flow-B-sYi7io.cjs.map +1 -0
  67. package/dist/device-code-flow-BCdcs8S7.js +124 -0
  68. package/dist/device-code-flow-BCdcs8S7.js.map +1 -0
  69. package/dist/index.cjs +1694 -808
  70. package/dist/index.cjs.map +1 -1
  71. package/dist/index.js +1678 -792
  72. package/dist/index.js.map +1 -1
  73. package/dist/{parse-c8rvP4YQ.js → parse-BC0czE2L.js} +3 -1
  74. package/dist/{parse-c8rvP4YQ.js.map → parse-BC0czE2L.js.map} +1 -1
  75. package/dist/{parse-C6k7VZkG.cjs → parse-CBlXTQfk.cjs} +3 -1
  76. package/dist/{parse-C6k7VZkG.cjs.map → parse-CBlXTQfk.cjs.map} +1 -1
  77. package/dist/resolve-D19wc4BJ.js +133 -0
  78. package/dist/resolve-D19wc4BJ.js.map +1 -0
  79. package/dist/resolve-DQS7cx8P.cjs +168 -0
  80. package/dist/resolve-DQS7cx8P.cjs.map +1 -0
  81. package/dist/resolve-token-BeHiwgSY.js +47 -0
  82. package/dist/resolve-token-BeHiwgSY.js.map +1 -0
  83. package/dist/resolve-token-DKH-nkWs.cjs +52 -0
  84. package/dist/resolve-token-DKH-nkWs.cjs.map +1 -0
  85. package/dist/{stdio-D7HAkmRe.js → stdio-B6V73MMI.js} +3 -7
  86. package/dist/stdio-B6V73MMI.js.map +1 -0
  87. package/dist/{stdio-BlFtz2dW.cjs → stdio-CSjj4HGd.cjs} +3 -19
  88. package/dist/stdio-CSjj4HGd.cjs.map +1 -0
  89. package/dist/{token-CwkkxgwR.js → token-D7eiINbV.js} +2 -2
  90. package/dist/{token-CwkkxgwR.js.map → token-D7eiINbV.js.map} +1 -1
  91. package/dist/{token-C7V4_3ji.cjs → token-Dx4qrxlx.cjs} +3 -3
  92. package/dist/{token-C7V4_3ji.cjs.map → token-Dx4qrxlx.cjs.map} +1 -1
  93. package/dist/token-cache-BTEUyVx2.js +66 -0
  94. package/dist/token-cache-BTEUyVx2.js.map +1 -0
  95. package/dist/token-cache-iqkTOca3.cjs +84 -0
  96. package/dist/token-cache-iqkTOca3.cjs.map +1 -0
  97. package/dist/{token-error-BCFB3iKM.cjs → token-error-x_miDBP3.cjs} +1 -1
  98. package/dist/{token-error-BCFB3iKM.cjs.map → token-error-x_miDBP3.cjs.map} +1 -1
  99. package/dist/{token-util-D5kD3Z8e.js → token-util-DtX1UM9f.js} +1 -1
  100. package/dist/{token-util-CQ4Ghf_7.js → token-util-VkLmCUNV.js} +1 -1
  101. package/dist/{token-util-CQ4Ghf_7.js.map → token-util-VkLmCUNV.js.map} +1 -1
  102. package/dist/{token-util-8fvl2CtH.cjs → token-util-bEa_1v46.cjs} +2 -2
  103. package/dist/{token-util-CMaRPlqM.cjs → token-util-oe0G9a-s.cjs} +2 -2
  104. package/dist/{token-util-CMaRPlqM.cjs.map → token-util-oe0G9a-s.cjs.map} +1 -1
  105. package/dist/transports/stdio.cjs +2 -1
  106. package/dist/transports/stdio.js +2 -1
  107. package/dist/types-BJpeKPWI.d.cts +112 -0
  108. package/dist/types-BJpeKPWI.d.cts.map +1 -0
  109. package/dist/types-C336ZSwF.js +57 -0
  110. package/dist/types-C336ZSwF.js.map +1 -0
  111. package/dist/types-DDkgkRP9.d.ts +112 -0
  112. package/dist/types-DDkgkRP9.d.ts.map +1 -0
  113. package/dist/types-DViCeKUc.cjs +87 -0
  114. package/dist/types-DViCeKUc.cjs.map +1 -0
  115. package/dist/{types-BZvFOe59.d.ts → types-T07_vWhw.d.cts} +15 -5
  116. package/dist/types-T07_vWhw.d.cts.map +1 -0
  117. package/dist/{types-C0DSLPbp.d.cts → types-uISvMJKw.d.ts} +15 -5
  118. package/dist/types-uISvMJKw.d.ts.map +1 -0
  119. package/dist/{usage-DAChHAia.cjs → usage-DqxR1zdC.cjs} +17 -6
  120. package/dist/usage-DqxR1zdC.cjs.map +1 -0
  121. package/dist/{usage-BRTpzFg9.js → usage-QnwsoeF4.js} +17 -6
  122. package/dist/usage-QnwsoeF4.js.map +1 -0
  123. package/dist/version-BBolBvwF.js +7 -0
  124. package/dist/version-BBolBvwF.js.map +1 -0
  125. package/dist/version-g6exOvkr.cjs +19 -0
  126. package/dist/version-g6exOvkr.cjs.map +1 -0
  127. package/package.json +5 -5
  128. package/dist/config-CLW41PUq.cjs +0 -7
  129. package/dist/resolve-Ci97NUwJ.js.map +0 -1
  130. package/dist/resolve-CxQZsYhh.cjs.map +0 -1
  131. package/dist/stdio-BlFtz2dW.cjs.map +0 -1
  132. package/dist/stdio-D7HAkmRe.js.map +0 -1
  133. package/dist/types-BZvFOe59.d.ts.map +0 -1
  134. package/dist/types-C0DSLPbp.d.cts.map +0 -1
  135. package/dist/usage-BRTpzFg9.js.map +0 -1
  136. package/dist/usage-DAChHAia.cjs.map +0 -1
@@ -1,74 +1,4 @@
1
- //#region ../mcp-core/dist/skills-DEPBbN1h.js
2
- const SKILLS = {
3
- inspect: {
4
- id: "inspect",
5
- name: "Inspect Issues & Events",
6
- description: "Search for errors, analyze traces, and explore event details",
7
- defaultEnabled: true,
8
- order: 1
9
- },
10
- seer: {
11
- id: "seer",
12
- name: "Seer",
13
- description: "Sentry's AI debugger that helps you analyze, root cause, and fix issues",
14
- defaultEnabled: true,
15
- order: 2
16
- },
17
- docs: {
18
- id: "docs",
19
- name: "Documentation",
20
- description: "Search and read Sentry SDK documentation",
21
- defaultEnabled: false,
22
- order: 3
23
- },
24
- triage: {
25
- id: "triage",
26
- name: "Triage Issues",
27
- description: "Resolve, assign, and update issues",
28
- defaultEnabled: false,
29
- order: 4
30
- },
31
- "project-management": {
32
- id: "project-management",
33
- name: "Manage Projects & Teams",
34
- description: "Create and modify projects, teams, and DSNs",
35
- defaultEnabled: false,
36
- order: 5
37
- }
38
- };
39
- const SKILLS_ARRAY = Object.values(SKILLS).sort((a, b) => a.order - b.order);
40
- const ALL_SKILLS = Object.keys(SKILLS);
41
- const DEFAULT_SKILLS = SKILLS_ARRAY.filter((s) => s.defaultEnabled).map((s) => s.id);
42
- function isValidSkill(skill) {
43
- return skill in SKILLS;
44
- }
45
- function isEnabledBySkills(grantedSkills, toolSkills) {
46
- if (!grantedSkills || toolSkills.length === 0) return false;
47
- return toolSkills.some((skill) => grantedSkills.has(skill));
48
- }
49
- function parseSkills(input) {
50
- const valid = /* @__PURE__ */ new Set();
51
- const invalid = [];
52
- if (!input) return {
53
- valid,
54
- invalid
55
- };
56
- let skills = [];
57
- if (typeof input === "string") skills = input.split(",");
58
- else if (Array.isArray(input)) skills = input.map((v) => typeof v === "string" ? v : "");
59
- for (const skill of skills) {
60
- const trimmed = String(skill).trim();
61
- if (isValidSkill(trimmed)) valid.add(trimmed);
62
- else if (trimmed) invalid.push(trimmed);
63
- }
64
- return {
65
- valid,
66
- invalid
67
- };
68
- }
69
-
70
- //#endregion
71
- //#region ../mcp-core/dist/url-utils-hSW2gkfr.js
1
+ //#region ../mcp-core/dist/url-utils-BImEGNCy.js
72
2
  /**
73
3
  * Determines if a Sentry instance is SaaS or self-hosted based on the host.
74
4
  * @param host The Sentry host (e.g., "sentry.io" or "sentry.company.com")
@@ -121,6 +51,18 @@ function getTraceUrl(host, organizationSlug, traceId) {
121
51
  return isSaas ? `https://${organizationSlug}.${webHost}/explore/traces/trace/${traceId}` : `https://${host}/organizations/${organizationSlug}/explore/traces/trace/${traceId}`;
122
52
  }
123
53
  /**
54
+ * Generates a Sentry replay URL.
55
+ * @param host The Sentry host (may include regional subdomain for API access)
56
+ * @param organizationSlug Organization identifier
57
+ * @param replayId Replay identifier
58
+ * @returns The complete replay URL
59
+ */
60
+ function getReplayUrl(host, organizationSlug, replayId) {
61
+ const isSaas = isSentryHost(host);
62
+ const webHost = isSaas ? "sentry.io" : host;
63
+ return isSaas ? `https://${organizationSlug}.${webHost}/replays/${replayId}/` : `https://${host}/organizations/${organizationSlug}/replays/${replayId}/`;
64
+ }
65
+ /**
124
66
  * Internal validation function that checks if a SENTRY_HOST value contains only hostname (no protocol).
125
67
  * Throws an error if validation fails instead of exiting the process.
126
68
  *
@@ -189,56 +131,35 @@ function validateOpenAiBaseUrlThrows(url) {
189
131
  }
190
132
 
191
133
  //#endregion
192
- //#region src/cli/resolve.ts
193
- function formatInvalidSkills(invalid, source) {
194
- const prefix = source ? `${source} provided` : "Invalid skills provided";
195
- return `Error: ${prefix}: ${invalid.join(", ")}\nAvailable skills: ${ALL_SKILLS.join(", ")}`;
196
- }
197
- function finalize(input) {
198
- if (!input.accessToken) throw new Error("Error: No access token was provided. Pass one with `--access-token` or via `SENTRY_ACCESS_TOKEN`.");
199
- let sentryHost = "sentry.io";
200
- if (input.url) sentryHost = validateAndParseSentryUrlThrows(input.url);
201
- else if (input.host) {
202
- validateSentryHostThrows(input.host);
203
- sentryHost = input.host;
204
- }
205
- let finalSkills;
206
- if (input.skills) {
207
- const { valid, invalid } = parseSkills(input.skills);
208
- if (invalid.length > 0) throw new Error(formatInvalidSkills(invalid));
209
- if (valid.size === 0) throw new Error("Error: Invalid skills provided. No valid skills found.");
210
- finalSkills = valid;
211
- } else finalSkills = new Set(ALL_SKILLS);
212
- if (input.disableSkills) {
213
- const { valid: skillsToDisable, invalid } = parseSkills(input.disableSkills);
214
- if (invalid.length > 0) throw new Error(formatInvalidSkills(invalid, "--disable-skills"));
215
- for (const skill of skillsToDisable) finalSkills.delete(skill);
216
- if (finalSkills.size === 0) throw new Error("Error: All skills have been disabled. At least one skill must remain enabled.");
217
- }
218
- const resolvedOpenAiBaseUrl = input.openaiBaseUrl ? validateOpenAiBaseUrlThrows(input.openaiBaseUrl) : void 0;
219
- const resolvedAnthropicBaseUrl = input.anthropicBaseUrl ? validateOpenAiBaseUrlThrows(input.anthropicBaseUrl) : void 0;
220
- let agentProvider = void 0;
221
- if (input.agentProvider) {
222
- const provider = input.agentProvider.toLowerCase();
223
- if (provider !== "openai" && provider !== "anthropic") throw new Error(`Error: Invalid agent provider "${input.agentProvider}". Must be "openai" or "anthropic".`);
224
- agentProvider = provider;
225
- }
226
- return {
227
- accessToken: input.accessToken,
228
- sentryHost,
229
- mcpUrl: input.mcpUrl,
230
- sentryDsn: input.sentryDsn,
231
- openaiBaseUrl: resolvedOpenAiBaseUrl,
232
- openaiModel: input.openaiModel,
233
- anthropicBaseUrl: resolvedAnthropicBaseUrl,
234
- anthropicModel: input.anthropicModel,
235
- agentProvider,
236
- finalSkills,
237
- organizationSlug: input.organizationSlug,
238
- projectSlug: input.projectSlug
239
- };
240
- }
134
+ //#region ../mcp-core/dist/scopes.js
135
+ const SCOPES = {
136
+ "org:read": "Read organization data",
137
+ "project:write": "Write project data",
138
+ "team:write": "Write team data",
139
+ "event:write": "Write event data"
140
+ };
141
+
142
+ //#endregion
143
+ //#region src/auth/constants.ts
144
+ /**
145
+ * Public OAuth app registered on sentry.io for the stdio device code flow.
146
+ * No client secret — device code grant is a public client flow.
147
+ * The Cloudflare transport uses a separate OAuth app with a secret.
148
+ * Override via SENTRY_CLIENT_ID environment variable.
149
+ * See docs/stdio-auth.md for the full credential architecture.
150
+ */
151
+ const DEFAULT_SENTRY_CLIENT_ID = "0acbeba7d07d58076dd7dbde8cea2fed8ab525ce3713bda604988009ab35d765";
152
+ const DEVICE_CODE_ENDPOINT = "/oauth/device/code/";
153
+ const TOKEN_ENDPOINT = "/oauth/token/";
154
+ const DEVICE_CODE_SCOPES = Object.keys(SCOPES).join(" ");
155
+ /** Interval increment on slow_down response (RFC 8628). */
156
+ const SLOW_DOWN_INCREMENT_SEC = 5;
157
+ /**
158
+ * OAuth endpoints live on sentry.io regardless of regional host.
159
+ * Always use this as the host for device code and token requests.
160
+ */
161
+ const OAUTH_HOST = "sentry.io";
241
162
 
242
163
  //#endregion
243
- export { ALL_SKILLS, SKILLS, finalize, formatInvalidSkills, getIssueUrl, getIssuesSearchUrl, getTraceUrl, isEnabledBySkills, isSentryHost };
244
- //# sourceMappingURL=resolve-Ci97NUwJ.js.map
164
+ export { DEFAULT_SENTRY_CLIENT_ID, DEVICE_CODE_ENDPOINT, DEVICE_CODE_SCOPES, OAUTH_HOST, SLOW_DOWN_INCREMENT_SEC, TOKEN_ENDPOINT, getIssueUrl, getIssuesSearchUrl, getReplayUrl, getTraceUrl, isSentryHost, validateAndParseSentryUrlThrows, validateOpenAiBaseUrlThrows, validateSentryHostThrows };
165
+ //# sourceMappingURL=constants-CnQOQOfw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-CnQOQOfw.js","names":[],"sources":["../../mcp-core/dist/url-utils-BImEGNCy.js","../../mcp-core/dist/scopes.js","../src/auth/constants.ts"],"sourcesContent":["//#region src/utils/url-utils.ts\n/**\n* Determines if a Sentry instance is SaaS or self-hosted based on the host.\n* @param host The Sentry host (e.g., \"sentry.io\" or \"sentry.company.com\")\n* @returns true if SaaS instance, false if self-hosted\n*/\nfunction isSentryHost(host) {\n\treturn host === \"sentry.io\" || host.endsWith(\".sentry.io\");\n}\n/**\n* Generates a Sentry issue URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param issueId Issue identifier (e.g., \"PROJECT-123\")\n* @returns The complete issue URL\n*/\nfunction getIssueUrl(host, organizationSlug, issueId) {\n\tconst isSaas = isSentryHost(host);\n\tconst webHost = isSaas ? \"sentry.io\" : host;\n\treturn isSaas ? `https://${organizationSlug}.${webHost}/issues/${issueId}` : `https://${host}/organizations/${organizationSlug}/issues/${issueId}`;\n}\n/**\n* Generates a Sentry issues search URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param query Optional search query\n* @param projectSlugOrId Optional project slug or ID\n* @returns The complete issues search URL\n*/\nfunction getIssuesSearchUrl(host, organizationSlug, query, projectSlugOrId) {\n\tconst isSaas = isSentryHost(host);\n\tconst webHost = isSaas ? \"sentry.io\" : host;\n\tlet url = isSaas ? `https://${organizationSlug}.${webHost}/issues/` : `https://${host}/organizations/${organizationSlug}/issues/`;\n\tconst params = new URLSearchParams();\n\tif (projectSlugOrId) params.append(\"project\", projectSlugOrId);\n\tif (query) params.append(\"query\", query);\n\tconst queryString = params.toString();\n\tif (queryString) url += `?${queryString}`;\n\treturn url;\n}\n/**\n* Generates a Sentry trace URL for performance investigation.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param traceId Trace identifier\n* @returns The complete trace URL\n*/\nfunction getTraceUrl(host, organizationSlug, traceId) {\n\tconst isSaas = isSentryHost(host);\n\tconst webHost = isSaas ? \"sentry.io\" : host;\n\treturn isSaas ? `https://${organizationSlug}.${webHost}/explore/traces/trace/${traceId}` : `https://${host}/organizations/${organizationSlug}/explore/traces/trace/${traceId}`;\n}\n/**\n* Generates a Sentry replay URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param replayId Replay identifier\n* @returns The complete replay URL\n*/\nfunction getReplayUrl(host, organizationSlug, replayId) {\n\tconst isSaas = isSentryHost(host);\n\tconst webHost = isSaas ? \"sentry.io\" : host;\n\treturn isSaas ? `https://${organizationSlug}.${webHost}/replays/${replayId}/` : `https://${host}/organizations/${organizationSlug}/replays/${replayId}/`;\n}\n/**\n* Generates a Sentry events explorer URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param query Search query\n* @param dataset Dataset type\n* @param projectSlug Optional project slug\n* @param fields Optional fields to display\n* @returns The complete events explorer URL\n*/\nfunction getEventsExplorerUrl(host, organizationSlug, query, dataset = \"spans\", projectSlug, fields) {\n\tconst isSaas = isSentryHost(host);\n\tconst webHost = isSaas ? \"sentry.io\" : host;\n\tlet url = isSaas ? `https://${organizationSlug}.${webHost}/explore/` : `https://${host}/organizations/${organizationSlug}/explore/`;\n\tconst params = new URLSearchParams();\n\tparams.append(\"query\", query);\n\tparams.append(\"dataset\", dataset);\n\tparams.append(\"layout\", \"table\");\n\tif (projectSlug) params.append(\"project\", projectSlug);\n\tif (fields && fields.length > 0) for (const field of fields) params.append(\"field\", field);\n\turl += `?${params.toString()}`;\n\treturn url;\n}\n/**\n* Internal validation function that checks if a SENTRY_HOST value contains only hostname (no protocol).\n* Throws an error if validation fails instead of exiting the process.\n*\n* @param host The hostname to validate\n* @throws {Error} If the host contains a protocol\n*/\nfunction _validateSentryHostInternal(host) {\n\tif (host.startsWith(\"http://\") || host.startsWith(\"https://\")) throw new Error(\"SENTRY_HOST should only contain a hostname (e.g., sentry.example.com). Use SENTRY_URL if you want to provide a full URL.\");\n}\n/**\n* Internal validation function that checks if a SENTRY_URL value is a valid HTTPS URL and extracts the hostname.\n* Throws an error if validation fails instead of exiting the process.\n*\n* @param url The HTTPS URL to validate and parse\n* @returns The extracted hostname from the URL\n* @throws {Error} If the URL is invalid or not HTTPS\n*/\nfunction _validateAndParseSentryUrlInternal(url) {\n\tif (!url.startsWith(\"https://\")) throw new Error(\"SENTRY_URL must be a full HTTPS URL (e.g., https://sentry.example.com).\");\n\ttry {\n\t\tconst parsedUrl = new URL(url);\n\t\treturn parsedUrl.host;\n\t} catch (error) {\n\t\tthrow new Error(\"SENTRY_URL must be a valid HTTPS URL (e.g., https://sentry.example.com).\");\n\t}\n}\n/**\n* Validates that a SENTRY_HOST value contains only hostname (no protocol).\n* Exits the process with error code 1 if validation fails (CLI behavior).\n*\n* @param host The hostname to validate\n*/\nfunction validateSentryHost(host) {\n\ttry {\n\t\t_validateSentryHostInternal(host);\n\t} catch (error) {\n\t\tconsole.error(`Error: ${error.message}`);\n\t\tprocess.exit(1);\n\t}\n}\n/**\n* Validates that a SENTRY_URL value is a valid HTTPS URL and extracts the hostname.\n* Exits the process with error code 1 if validation fails (CLI behavior).\n*\n* @param url The HTTPS URL to validate and parse\n* @returns The extracted hostname from the URL\n*/\nfunction validateAndParseSentryUrl(url) {\n\ttry {\n\t\treturn _validateAndParseSentryUrlInternal(url);\n\t} catch (error) {\n\t\tconsole.error(`Error: ${error.message}`);\n\t\tprocess.exit(1);\n\t}\n}\n/**\n* Validates that a SENTRY_HOST value contains only hostname (no protocol).\n* Throws an error instead of exiting the process (for testing).\n*\n* @param host The hostname to validate\n* @throws {Error} If the host contains a protocol\n*/\nfunction validateSentryHostThrows(host) {\n\t_validateSentryHostInternal(host);\n}\n/**\n* Validates that a SENTRY_URL value is a valid HTTPS URL and extracts the hostname.\n* Throws an error instead of exiting the process (for testing).\n*\n* @param url The HTTPS URL to validate and parse\n* @returns The extracted hostname from the URL\n* @throws {Error} If the URL is invalid or not HTTPS\n*/\nfunction validateAndParseSentryUrlThrows(url) {\n\treturn _validateAndParseSentryUrlInternal(url);\n}\n/**\n* Validates that the provided OpenAI base URL is a valid HTTP(S) URL and returns a normalized string.\n*\n* @param url The URL to validate and normalize\n* @returns The normalized URL string\n* @throws {Error} If the URL is empty, invalid, or uses an unsupported protocol\n*/\nfunction validateOpenAiBaseUrlThrows(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw new Error(\"OPENAI base URL must not be empty.\");\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch (error) {\n\t\tthrow new Error(\"OPENAI base URL must be a valid HTTP or HTTPS URL (e.g., https://example.com/v1).\", { cause: error });\n\t}\n\tif (parsed.protocol !== \"https:\" && parsed.protocol !== \"http:\") throw new Error(\"OPENAI base URL must use http or https scheme (e.g., https://example.com/v1).\");\n\treturn parsed.toString();\n}\n\n//#endregion\nexport { getEventsExplorerUrl, getIssueUrl, getIssuesSearchUrl, getReplayUrl, getTraceUrl, isSentryHost, validateAndParseSentryUrl, validateAndParseSentryUrlThrows, validateOpenAiBaseUrlThrows, validateSentryHost, validateSentryHostThrows };\n//# sourceMappingURL=url-utils-BImEGNCy.js.map","//#region src/scopes.ts\nconst SCOPES = {\n\t\"org:read\": \"Read organization data\",\n\t\"project:write\": \"Write project data\",\n\t\"team:write\": \"Write team data\",\n\t\"event:write\": \"Write event data\"\n};\n\n//#endregion\nexport { SCOPES };\n//# sourceMappingURL=scopes.js.map","import { SCOPES } from \"@sentry/mcp-core/scopes\";\nimport { isSentryHost } from \"@sentry/mcp-core/utils/url-utils\";\n\n/**\n * Public OAuth app registered on sentry.io for the stdio device code flow.\n * No client secret — device code grant is a public client flow.\n * The Cloudflare transport uses a separate OAuth app with a secret.\n * Override via SENTRY_CLIENT_ID environment variable.\n * See docs/stdio-auth.md for the full credential architecture.\n */\nexport const DEFAULT_SENTRY_CLIENT_ID =\n \"0acbeba7d07d58076dd7dbde8cea2fed8ab525ce3713bda604988009ab35d765\";\n\nexport const DEVICE_CODE_ENDPOINT = \"/oauth/device/code/\";\nexport const TOKEN_ENDPOINT = \"/oauth/token/\";\nexport const DEVICE_CODE_SCOPES = Object.keys(SCOPES).join(\" \");\n\n/** Interval increment on slow_down response (RFC 8628). */\nexport const SLOW_DOWN_INCREMENT_SEC = 5;\n\n/**\n * Whether device code auth is available for this host.\n * Supports sentry.io and regional subdomains (us.sentry.io, eu.sentry.io).\n */\nexport { isSentryHost as isSentryIo };\n\n/**\n * OAuth endpoints live on sentry.io regardless of regional host.\n * Always use this as the host for device code and token requests.\n */\nexport const OAUTH_HOST = \"sentry.io\";\n"],"mappings":";;;;;;AAMA,SAAS,aAAa,MAAM;AAC3B,QAAO,SAAS,eAAe,KAAK,SAAS,aAAa;AAC1D;;;;;;;;AAQD,SAAS,YAAY,MAAM,kBAAkB,SAAS;CACrD,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,UAAU,SAAS,cAAc;AACvC,QAAO,UAAU,UAAU,iBAAiB,GAAG,QAAQ,UAAU,aAAa,UAAU,KAAK,iBAAiB,iBAAiB,UAAU;AACzI;;;;;;;;;AASD,SAAS,mBAAmB,MAAM,kBAAkB,OAAO,iBAAiB;CAC3E,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,UAAU,SAAS,cAAc;CACvC,IAAI,MAAM,UAAU,UAAU,iBAAiB,GAAG,QAAQ,aAAa,UAAU,KAAK,iBAAiB,iBAAiB;CACxH,MAAM,SAAS,IAAI;AACnB,KAAI,gBAAiB,QAAO,OAAO,WAAW,gBAAgB;AAC9D,KAAI,MAAO,QAAO,OAAO,SAAS,MAAM;CACxC,MAAM,cAAc,OAAO,UAAU;AACrC,KAAI,YAAa,SAAQ,GAAG;AAC5B,QAAO;AACP;;;;;;;;AAQD,SAAS,YAAY,MAAM,kBAAkB,SAAS;CACrD,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,UAAU,SAAS,cAAc;AACvC,QAAO,UAAU,UAAU,iBAAiB,GAAG,QAAQ,wBAAwB,aAAa,UAAU,KAAK,iBAAiB,iBAAiB,wBAAwB;AACrK;;;;;;;;AAQD,SAAS,aAAa,MAAM,kBAAkB,UAAU;CACvD,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,UAAU,SAAS,cAAc;AACvC,QAAO,UAAU,UAAU,iBAAiB,GAAG,QAAQ,WAAW,SAAS,MAAM,UAAU,KAAK,iBAAiB,iBAAiB,WAAW,SAAS;AACtJ;;;;;;;;AA+BD,SAAS,4BAA4B,MAAM;AAC1C,KAAI,KAAK,WAAW,UAAU,IAAI,KAAK,WAAW,WAAW,CAAE,OAAM,IAAI,MAAM;AAC/E;;;;;;;;;AASD,SAAS,mCAAmC,KAAK;AAChD,MAAK,IAAI,WAAW,WAAW,CAAE,OAAM,IAAI,MAAM;AACjD,KAAI;EACH,MAAM,YAAY,IAAI,IAAI;AAC1B,SAAO,UAAU;CACjB,SAAQ,OAAO;AACf,QAAM,IAAI,MAAM;CAChB;AACD;;;;;;;;AAqCD,SAAS,yBAAyB,MAAM;AACvC,6BAA4B,KAAK;AACjC;;;;;;;;;AASD,SAAS,gCAAgC,KAAK;AAC7C,QAAO,mCAAmC,IAAI;AAC9C;;;;;;;;AAQD,SAAS,4BAA4B,KAAK;CACzC,MAAM,UAAU,IAAI,MAAM;AAC1B,KAAI,QAAQ,WAAW,EAAG,OAAM,IAAI,MAAM;CAC1C,IAAI;AACJ,KAAI;AACH,WAAS,IAAI,IAAI;CACjB,SAAQ,OAAO;AACf,QAAM,IAAI,MAAM,qFAAqF,EAAE,OAAO,MAAO;CACrH;AACD,KAAI,OAAO,aAAa,YAAY,OAAO,aAAa,QAAS,OAAM,IAAI,MAAM;AACjF,QAAO,OAAO,UAAU;AACxB;;;;ACrLD,MAAM,SAAS;CACd,YAAY;CACZ,iBAAiB;CACjB,cAAc;CACd,eAAe;AACf;;;;;;;;;;;ACID,MAAa,2BACX;AAEF,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;AAC9B,MAAa,qBAAqB,OAAO,KAAK,OAAO,CAAC,KAAK,IAAI;;AAG/D,MAAa,0BAA0B;;;;;AAYvC,MAAa,aAAa"}
@@ -1,75 +1,5 @@
1
1
 
2
- //#region ../mcp-core/dist/skills-DEPBbN1h.js
3
- const SKILLS = {
4
- inspect: {
5
- id: "inspect",
6
- name: "Inspect Issues & Events",
7
- description: "Search for errors, analyze traces, and explore event details",
8
- defaultEnabled: true,
9
- order: 1
10
- },
11
- seer: {
12
- id: "seer",
13
- name: "Seer",
14
- description: "Sentry's AI debugger that helps you analyze, root cause, and fix issues",
15
- defaultEnabled: true,
16
- order: 2
17
- },
18
- docs: {
19
- id: "docs",
20
- name: "Documentation",
21
- description: "Search and read Sentry SDK documentation",
22
- defaultEnabled: false,
23
- order: 3
24
- },
25
- triage: {
26
- id: "triage",
27
- name: "Triage Issues",
28
- description: "Resolve, assign, and update issues",
29
- defaultEnabled: false,
30
- order: 4
31
- },
32
- "project-management": {
33
- id: "project-management",
34
- name: "Manage Projects & Teams",
35
- description: "Create and modify projects, teams, and DSNs",
36
- defaultEnabled: false,
37
- order: 5
38
- }
39
- };
40
- const SKILLS_ARRAY = Object.values(SKILLS).sort((a, b) => a.order - b.order);
41
- const ALL_SKILLS = Object.keys(SKILLS);
42
- const DEFAULT_SKILLS = SKILLS_ARRAY.filter((s) => s.defaultEnabled).map((s) => s.id);
43
- function isValidSkill(skill) {
44
- return skill in SKILLS;
45
- }
46
- function isEnabledBySkills(grantedSkills, toolSkills) {
47
- if (!grantedSkills || toolSkills.length === 0) return false;
48
- return toolSkills.some((skill) => grantedSkills.has(skill));
49
- }
50
- function parseSkills(input) {
51
- const valid = /* @__PURE__ */ new Set();
52
- const invalid = [];
53
- if (!input) return {
54
- valid,
55
- invalid
56
- };
57
- let skills = [];
58
- if (typeof input === "string") skills = input.split(",");
59
- else if (Array.isArray(input)) skills = input.map((v) => typeof v === "string" ? v : "");
60
- for (const skill of skills) {
61
- const trimmed = String(skill).trim();
62
- if (isValidSkill(trimmed)) valid.add(trimmed);
63
- else if (trimmed) invalid.push(trimmed);
64
- }
65
- return {
66
- valid,
67
- invalid
68
- };
69
- }
70
-
71
- //#endregion
72
- //#region ../mcp-core/dist/url-utils-hSW2gkfr.js
2
+ //#region ../mcp-core/dist/url-utils-BImEGNCy.js
73
3
  /**
74
4
  * Determines if a Sentry instance is SaaS or self-hosted based on the host.
75
5
  * @param host The Sentry host (e.g., "sentry.io" or "sentry.company.com")
@@ -122,6 +52,18 @@ function getTraceUrl(host, organizationSlug, traceId) {
122
52
  return isSaas ? `https://${organizationSlug}.${webHost}/explore/traces/trace/${traceId}` : `https://${host}/organizations/${organizationSlug}/explore/traces/trace/${traceId}`;
123
53
  }
124
54
  /**
55
+ * Generates a Sentry replay URL.
56
+ * @param host The Sentry host (may include regional subdomain for API access)
57
+ * @param organizationSlug Organization identifier
58
+ * @param replayId Replay identifier
59
+ * @returns The complete replay URL
60
+ */
61
+ function getReplayUrl(host, organizationSlug, replayId) {
62
+ const isSaas = isSentryHost(host);
63
+ const webHost = isSaas ? "sentry.io" : host;
64
+ return isSaas ? `https://${organizationSlug}.${webHost}/replays/${replayId}/` : `https://${host}/organizations/${organizationSlug}/replays/${replayId}/`;
65
+ }
66
+ /**
125
67
  * Internal validation function that checks if a SENTRY_HOST value contains only hostname (no protocol).
126
68
  * Throws an error if validation fails instead of exiting the process.
127
69
  *
@@ -190,79 +132,70 @@ function validateOpenAiBaseUrlThrows(url) {
190
132
  }
191
133
 
192
134
  //#endregion
193
- //#region src/cli/resolve.ts
194
- function formatInvalidSkills(invalid, source) {
195
- const prefix = source ? `${source} provided` : "Invalid skills provided";
196
- return `Error: ${prefix}: ${invalid.join(", ")}\nAvailable skills: ${ALL_SKILLS.join(", ")}`;
197
- }
198
- function finalize(input) {
199
- if (!input.accessToken) throw new Error("Error: No access token was provided. Pass one with `--access-token` or via `SENTRY_ACCESS_TOKEN`.");
200
- let sentryHost = "sentry.io";
201
- if (input.url) sentryHost = validateAndParseSentryUrlThrows(input.url);
202
- else if (input.host) {
203
- validateSentryHostThrows(input.host);
204
- sentryHost = input.host;
205
- }
206
- let finalSkills;
207
- if (input.skills) {
208
- const { valid, invalid } = parseSkills(input.skills);
209
- if (invalid.length > 0) throw new Error(formatInvalidSkills(invalid));
210
- if (valid.size === 0) throw new Error("Error: Invalid skills provided. No valid skills found.");
211
- finalSkills = valid;
212
- } else finalSkills = new Set(ALL_SKILLS);
213
- if (input.disableSkills) {
214
- const { valid: skillsToDisable, invalid } = parseSkills(input.disableSkills);
215
- if (invalid.length > 0) throw new Error(formatInvalidSkills(invalid, "--disable-skills"));
216
- for (const skill of skillsToDisable) finalSkills.delete(skill);
217
- if (finalSkills.size === 0) throw new Error("Error: All skills have been disabled. At least one skill must remain enabled.");
218
- }
219
- const resolvedOpenAiBaseUrl = input.openaiBaseUrl ? validateOpenAiBaseUrlThrows(input.openaiBaseUrl) : void 0;
220
- const resolvedAnthropicBaseUrl = input.anthropicBaseUrl ? validateOpenAiBaseUrlThrows(input.anthropicBaseUrl) : void 0;
221
- let agentProvider = void 0;
222
- if (input.agentProvider) {
223
- const provider = input.agentProvider.toLowerCase();
224
- if (provider !== "openai" && provider !== "anthropic") throw new Error(`Error: Invalid agent provider "${input.agentProvider}". Must be "openai" or "anthropic".`);
225
- agentProvider = provider;
226
- }
227
- return {
228
- accessToken: input.accessToken,
229
- sentryHost,
230
- mcpUrl: input.mcpUrl,
231
- sentryDsn: input.sentryDsn,
232
- openaiBaseUrl: resolvedOpenAiBaseUrl,
233
- openaiModel: input.openaiModel,
234
- anthropicBaseUrl: resolvedAnthropicBaseUrl,
235
- anthropicModel: input.anthropicModel,
236
- agentProvider,
237
- finalSkills,
238
- organizationSlug: input.organizationSlug,
239
- projectSlug: input.projectSlug
240
- };
241
- }
135
+ //#region ../mcp-core/dist/scopes.js
136
+ const SCOPES = {
137
+ "org:read": "Read organization data",
138
+ "project:write": "Write project data",
139
+ "team:write": "Write team data",
140
+ "event:write": "Write event data"
141
+ };
242
142
 
243
143
  //#endregion
244
- Object.defineProperty(exports, 'ALL_SKILLS', {
144
+ //#region src/auth/constants.ts
145
+ /**
146
+ * Public OAuth app registered on sentry.io for the stdio device code flow.
147
+ * No client secret — device code grant is a public client flow.
148
+ * The Cloudflare transport uses a separate OAuth app with a secret.
149
+ * Override via SENTRY_CLIENT_ID environment variable.
150
+ * See docs/stdio-auth.md for the full credential architecture.
151
+ */
152
+ const DEFAULT_SENTRY_CLIENT_ID = "0acbeba7d07d58076dd7dbde8cea2fed8ab525ce3713bda604988009ab35d765";
153
+ const DEVICE_CODE_ENDPOINT = "/oauth/device/code/";
154
+ const TOKEN_ENDPOINT = "/oauth/token/";
155
+ const DEVICE_CODE_SCOPES = Object.keys(SCOPES).join(" ");
156
+ /** Interval increment on slow_down response (RFC 8628). */
157
+ const SLOW_DOWN_INCREMENT_SEC = 5;
158
+ /**
159
+ * OAuth endpoints live on sentry.io regardless of regional host.
160
+ * Always use this as the host for device code and token requests.
161
+ */
162
+ const OAUTH_HOST = "sentry.io";
163
+
164
+ //#endregion
165
+ Object.defineProperty(exports, 'DEFAULT_SENTRY_CLIENT_ID', {
245
166
  enumerable: true,
246
167
  get: function () {
247
- return ALL_SKILLS;
168
+ return DEFAULT_SENTRY_CLIENT_ID;
248
169
  }
249
170
  });
250
- Object.defineProperty(exports, 'SKILLS', {
171
+ Object.defineProperty(exports, 'DEVICE_CODE_ENDPOINT', {
251
172
  enumerable: true,
252
173
  get: function () {
253
- return SKILLS;
174
+ return DEVICE_CODE_ENDPOINT;
254
175
  }
255
176
  });
256
- Object.defineProperty(exports, 'finalize', {
177
+ Object.defineProperty(exports, 'DEVICE_CODE_SCOPES', {
257
178
  enumerable: true,
258
179
  get: function () {
259
- return finalize;
180
+ return DEVICE_CODE_SCOPES;
260
181
  }
261
182
  });
262
- Object.defineProperty(exports, 'formatInvalidSkills', {
183
+ Object.defineProperty(exports, 'OAUTH_HOST', {
263
184
  enumerable: true,
264
185
  get: function () {
265
- return formatInvalidSkills;
186
+ return OAUTH_HOST;
187
+ }
188
+ });
189
+ Object.defineProperty(exports, 'SLOW_DOWN_INCREMENT_SEC', {
190
+ enumerable: true,
191
+ get: function () {
192
+ return SLOW_DOWN_INCREMENT_SEC;
193
+ }
194
+ });
195
+ Object.defineProperty(exports, 'TOKEN_ENDPOINT', {
196
+ enumerable: true,
197
+ get: function () {
198
+ return TOKEN_ENDPOINT;
266
199
  }
267
200
  });
268
201
  Object.defineProperty(exports, 'getIssueUrl', {
@@ -277,16 +210,16 @@ Object.defineProperty(exports, 'getIssuesSearchUrl', {
277
210
  return getIssuesSearchUrl;
278
211
  }
279
212
  });
280
- Object.defineProperty(exports, 'getTraceUrl', {
213
+ Object.defineProperty(exports, 'getReplayUrl', {
281
214
  enumerable: true,
282
215
  get: function () {
283
- return getTraceUrl;
216
+ return getReplayUrl;
284
217
  }
285
218
  });
286
- Object.defineProperty(exports, 'isEnabledBySkills', {
219
+ Object.defineProperty(exports, 'getTraceUrl', {
287
220
  enumerable: true,
288
221
  get: function () {
289
- return isEnabledBySkills;
222
+ return getTraceUrl;
290
223
  }
291
224
  });
292
225
  Object.defineProperty(exports, 'isSentryHost', {
@@ -295,4 +228,22 @@ Object.defineProperty(exports, 'isSentryHost', {
295
228
  return isSentryHost;
296
229
  }
297
230
  });
298
- //# sourceMappingURL=resolve-CxQZsYhh.cjs.map
231
+ Object.defineProperty(exports, 'validateAndParseSentryUrlThrows', {
232
+ enumerable: true,
233
+ get: function () {
234
+ return validateAndParseSentryUrlThrows;
235
+ }
236
+ });
237
+ Object.defineProperty(exports, 'validateOpenAiBaseUrlThrows', {
238
+ enumerable: true,
239
+ get: function () {
240
+ return validateOpenAiBaseUrlThrows;
241
+ }
242
+ });
243
+ Object.defineProperty(exports, 'validateSentryHostThrows', {
244
+ enumerable: true,
245
+ get: function () {
246
+ return validateSentryHostThrows;
247
+ }
248
+ });
249
+ //# sourceMappingURL=constants-zXY4MUBL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-zXY4MUBL.cjs","names":[],"sources":["../../mcp-core/dist/url-utils-BImEGNCy.js","../../mcp-core/dist/scopes.js","../src/auth/constants.ts"],"sourcesContent":["//#region src/utils/url-utils.ts\n/**\n* Determines if a Sentry instance is SaaS or self-hosted based on the host.\n* @param host The Sentry host (e.g., \"sentry.io\" or \"sentry.company.com\")\n* @returns true if SaaS instance, false if self-hosted\n*/\nfunction isSentryHost(host) {\n\treturn host === \"sentry.io\" || host.endsWith(\".sentry.io\");\n}\n/**\n* Generates a Sentry issue URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param issueId Issue identifier (e.g., \"PROJECT-123\")\n* @returns The complete issue URL\n*/\nfunction getIssueUrl(host, organizationSlug, issueId) {\n\tconst isSaas = isSentryHost(host);\n\tconst webHost = isSaas ? \"sentry.io\" : host;\n\treturn isSaas ? `https://${organizationSlug}.${webHost}/issues/${issueId}` : `https://${host}/organizations/${organizationSlug}/issues/${issueId}`;\n}\n/**\n* Generates a Sentry issues search URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param query Optional search query\n* @param projectSlugOrId Optional project slug or ID\n* @returns The complete issues search URL\n*/\nfunction getIssuesSearchUrl(host, organizationSlug, query, projectSlugOrId) {\n\tconst isSaas = isSentryHost(host);\n\tconst webHost = isSaas ? \"sentry.io\" : host;\n\tlet url = isSaas ? `https://${organizationSlug}.${webHost}/issues/` : `https://${host}/organizations/${organizationSlug}/issues/`;\n\tconst params = new URLSearchParams();\n\tif (projectSlugOrId) params.append(\"project\", projectSlugOrId);\n\tif (query) params.append(\"query\", query);\n\tconst queryString = params.toString();\n\tif (queryString) url += `?${queryString}`;\n\treturn url;\n}\n/**\n* Generates a Sentry trace URL for performance investigation.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param traceId Trace identifier\n* @returns The complete trace URL\n*/\nfunction getTraceUrl(host, organizationSlug, traceId) {\n\tconst isSaas = isSentryHost(host);\n\tconst webHost = isSaas ? \"sentry.io\" : host;\n\treturn isSaas ? `https://${organizationSlug}.${webHost}/explore/traces/trace/${traceId}` : `https://${host}/organizations/${organizationSlug}/explore/traces/trace/${traceId}`;\n}\n/**\n* Generates a Sentry replay URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param replayId Replay identifier\n* @returns The complete replay URL\n*/\nfunction getReplayUrl(host, organizationSlug, replayId) {\n\tconst isSaas = isSentryHost(host);\n\tconst webHost = isSaas ? \"sentry.io\" : host;\n\treturn isSaas ? `https://${organizationSlug}.${webHost}/replays/${replayId}/` : `https://${host}/organizations/${organizationSlug}/replays/${replayId}/`;\n}\n/**\n* Generates a Sentry events explorer URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param query Search query\n* @param dataset Dataset type\n* @param projectSlug Optional project slug\n* @param fields Optional fields to display\n* @returns The complete events explorer URL\n*/\nfunction getEventsExplorerUrl(host, organizationSlug, query, dataset = \"spans\", projectSlug, fields) {\n\tconst isSaas = isSentryHost(host);\n\tconst webHost = isSaas ? \"sentry.io\" : host;\n\tlet url = isSaas ? `https://${organizationSlug}.${webHost}/explore/` : `https://${host}/organizations/${organizationSlug}/explore/`;\n\tconst params = new URLSearchParams();\n\tparams.append(\"query\", query);\n\tparams.append(\"dataset\", dataset);\n\tparams.append(\"layout\", \"table\");\n\tif (projectSlug) params.append(\"project\", projectSlug);\n\tif (fields && fields.length > 0) for (const field of fields) params.append(\"field\", field);\n\turl += `?${params.toString()}`;\n\treturn url;\n}\n/**\n* Internal validation function that checks if a SENTRY_HOST value contains only hostname (no protocol).\n* Throws an error if validation fails instead of exiting the process.\n*\n* @param host The hostname to validate\n* @throws {Error} If the host contains a protocol\n*/\nfunction _validateSentryHostInternal(host) {\n\tif (host.startsWith(\"http://\") || host.startsWith(\"https://\")) throw new Error(\"SENTRY_HOST should only contain a hostname (e.g., sentry.example.com). Use SENTRY_URL if you want to provide a full URL.\");\n}\n/**\n* Internal validation function that checks if a SENTRY_URL value is a valid HTTPS URL and extracts the hostname.\n* Throws an error if validation fails instead of exiting the process.\n*\n* @param url The HTTPS URL to validate and parse\n* @returns The extracted hostname from the URL\n* @throws {Error} If the URL is invalid or not HTTPS\n*/\nfunction _validateAndParseSentryUrlInternal(url) {\n\tif (!url.startsWith(\"https://\")) throw new Error(\"SENTRY_URL must be a full HTTPS URL (e.g., https://sentry.example.com).\");\n\ttry {\n\t\tconst parsedUrl = new URL(url);\n\t\treturn parsedUrl.host;\n\t} catch (error) {\n\t\tthrow new Error(\"SENTRY_URL must be a valid HTTPS URL (e.g., https://sentry.example.com).\");\n\t}\n}\n/**\n* Validates that a SENTRY_HOST value contains only hostname (no protocol).\n* Exits the process with error code 1 if validation fails (CLI behavior).\n*\n* @param host The hostname to validate\n*/\nfunction validateSentryHost(host) {\n\ttry {\n\t\t_validateSentryHostInternal(host);\n\t} catch (error) {\n\t\tconsole.error(`Error: ${error.message}`);\n\t\tprocess.exit(1);\n\t}\n}\n/**\n* Validates that a SENTRY_URL value is a valid HTTPS URL and extracts the hostname.\n* Exits the process with error code 1 if validation fails (CLI behavior).\n*\n* @param url The HTTPS URL to validate and parse\n* @returns The extracted hostname from the URL\n*/\nfunction validateAndParseSentryUrl(url) {\n\ttry {\n\t\treturn _validateAndParseSentryUrlInternal(url);\n\t} catch (error) {\n\t\tconsole.error(`Error: ${error.message}`);\n\t\tprocess.exit(1);\n\t}\n}\n/**\n* Validates that a SENTRY_HOST value contains only hostname (no protocol).\n* Throws an error instead of exiting the process (for testing).\n*\n* @param host The hostname to validate\n* @throws {Error} If the host contains a protocol\n*/\nfunction validateSentryHostThrows(host) {\n\t_validateSentryHostInternal(host);\n}\n/**\n* Validates that a SENTRY_URL value is a valid HTTPS URL and extracts the hostname.\n* Throws an error instead of exiting the process (for testing).\n*\n* @param url The HTTPS URL to validate and parse\n* @returns The extracted hostname from the URL\n* @throws {Error} If the URL is invalid or not HTTPS\n*/\nfunction validateAndParseSentryUrlThrows(url) {\n\treturn _validateAndParseSentryUrlInternal(url);\n}\n/**\n* Validates that the provided OpenAI base URL is a valid HTTP(S) URL and returns a normalized string.\n*\n* @param url The URL to validate and normalize\n* @returns The normalized URL string\n* @throws {Error} If the URL is empty, invalid, or uses an unsupported protocol\n*/\nfunction validateOpenAiBaseUrlThrows(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw new Error(\"OPENAI base URL must not be empty.\");\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch (error) {\n\t\tthrow new Error(\"OPENAI base URL must be a valid HTTP or HTTPS URL (e.g., https://example.com/v1).\", { cause: error });\n\t}\n\tif (parsed.protocol !== \"https:\" && parsed.protocol !== \"http:\") throw new Error(\"OPENAI base URL must use http or https scheme (e.g., https://example.com/v1).\");\n\treturn parsed.toString();\n}\n\n//#endregion\nexport { getEventsExplorerUrl, getIssueUrl, getIssuesSearchUrl, getReplayUrl, getTraceUrl, isSentryHost, validateAndParseSentryUrl, validateAndParseSentryUrlThrows, validateOpenAiBaseUrlThrows, validateSentryHost, validateSentryHostThrows };\n//# sourceMappingURL=url-utils-BImEGNCy.js.map","//#region src/scopes.ts\nconst SCOPES = {\n\t\"org:read\": \"Read organization data\",\n\t\"project:write\": \"Write project data\",\n\t\"team:write\": \"Write team data\",\n\t\"event:write\": \"Write event data\"\n};\n\n//#endregion\nexport { SCOPES };\n//# sourceMappingURL=scopes.js.map","import { SCOPES } from \"@sentry/mcp-core/scopes\";\nimport { isSentryHost } from \"@sentry/mcp-core/utils/url-utils\";\n\n/**\n * Public OAuth app registered on sentry.io for the stdio device code flow.\n * No client secret — device code grant is a public client flow.\n * The Cloudflare transport uses a separate OAuth app with a secret.\n * Override via SENTRY_CLIENT_ID environment variable.\n * See docs/stdio-auth.md for the full credential architecture.\n */\nexport const DEFAULT_SENTRY_CLIENT_ID =\n \"0acbeba7d07d58076dd7dbde8cea2fed8ab525ce3713bda604988009ab35d765\";\n\nexport const DEVICE_CODE_ENDPOINT = \"/oauth/device/code/\";\nexport const TOKEN_ENDPOINT = \"/oauth/token/\";\nexport const DEVICE_CODE_SCOPES = Object.keys(SCOPES).join(\" \");\n\n/** Interval increment on slow_down response (RFC 8628). */\nexport const SLOW_DOWN_INCREMENT_SEC = 5;\n\n/**\n * Whether device code auth is available for this host.\n * Supports sentry.io and regional subdomains (us.sentry.io, eu.sentry.io).\n */\nexport { isSentryHost as isSentryIo };\n\n/**\n * OAuth endpoints live on sentry.io regardless of regional host.\n * Always use this as the host for device code and token requests.\n */\nexport const OAUTH_HOST = \"sentry.io\";\n"],"mappings":";;;;;;;AAMA,SAAS,aAAa,MAAM;AAC3B,QAAO,SAAS,eAAe,KAAK,SAAS,aAAa;AAC1D;;;;;;;;AAQD,SAAS,YAAY,MAAM,kBAAkB,SAAS;CACrD,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,UAAU,SAAS,cAAc;AACvC,QAAO,UAAU,UAAU,iBAAiB,GAAG,QAAQ,UAAU,aAAa,UAAU,KAAK,iBAAiB,iBAAiB,UAAU;AACzI;;;;;;;;;AASD,SAAS,mBAAmB,MAAM,kBAAkB,OAAO,iBAAiB;CAC3E,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,UAAU,SAAS,cAAc;CACvC,IAAI,MAAM,UAAU,UAAU,iBAAiB,GAAG,QAAQ,aAAa,UAAU,KAAK,iBAAiB,iBAAiB;CACxH,MAAM,SAAS,IAAI;AACnB,KAAI,gBAAiB,QAAO,OAAO,WAAW,gBAAgB;AAC9D,KAAI,MAAO,QAAO,OAAO,SAAS,MAAM;CACxC,MAAM,cAAc,OAAO,UAAU;AACrC,KAAI,YAAa,SAAQ,GAAG;AAC5B,QAAO;AACP;;;;;;;;AAQD,SAAS,YAAY,MAAM,kBAAkB,SAAS;CACrD,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,UAAU,SAAS,cAAc;AACvC,QAAO,UAAU,UAAU,iBAAiB,GAAG,QAAQ,wBAAwB,aAAa,UAAU,KAAK,iBAAiB,iBAAiB,wBAAwB;AACrK;;;;;;;;AAQD,SAAS,aAAa,MAAM,kBAAkB,UAAU;CACvD,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,UAAU,SAAS,cAAc;AACvC,QAAO,UAAU,UAAU,iBAAiB,GAAG,QAAQ,WAAW,SAAS,MAAM,UAAU,KAAK,iBAAiB,iBAAiB,WAAW,SAAS;AACtJ;;;;;;;;AA+BD,SAAS,4BAA4B,MAAM;AAC1C,KAAI,KAAK,WAAW,UAAU,IAAI,KAAK,WAAW,WAAW,CAAE,OAAM,IAAI,MAAM;AAC/E;;;;;;;;;AASD,SAAS,mCAAmC,KAAK;AAChD,MAAK,IAAI,WAAW,WAAW,CAAE,OAAM,IAAI,MAAM;AACjD,KAAI;EACH,MAAM,YAAY,IAAI,IAAI;AAC1B,SAAO,UAAU;CACjB,SAAQ,OAAO;AACf,QAAM,IAAI,MAAM;CAChB;AACD;;;;;;;;AAqCD,SAAS,yBAAyB,MAAM;AACvC,6BAA4B,KAAK;AACjC;;;;;;;;;AASD,SAAS,gCAAgC,KAAK;AAC7C,QAAO,mCAAmC,IAAI;AAC9C;;;;;;;;AAQD,SAAS,4BAA4B,KAAK;CACzC,MAAM,UAAU,IAAI,MAAM;AAC1B,KAAI,QAAQ,WAAW,EAAG,OAAM,IAAI,MAAM;CAC1C,IAAI;AACJ,KAAI;AACH,WAAS,IAAI,IAAI;CACjB,SAAQ,OAAO;AACf,QAAM,IAAI,MAAM,qFAAqF,EAAE,OAAO,MAAO;CACrH;AACD,KAAI,OAAO,aAAa,YAAY,OAAO,aAAa,QAAS,OAAM,IAAI,MAAM;AACjF,QAAO,OAAO,UAAU;AACxB;;;;ACrLD,MAAM,SAAS;CACd,YAAY;CACZ,iBAAiB;CACjB,cAAc;CACd,eAAe;AACf;;;;;;;;;;;ACID,MAAa,2BACX;AAEF,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;AAC9B,MAAa,qBAAqB,OAAO,KAAK,OAAO,CAAC,KAAK,IAAI;;AAG/D,MAAa,0BAA0B;;;;;AAYvC,MAAa,aAAa"}
@@ -0,0 +1,154 @@
1
+ const require_chunk = require('./chunk-Cv9WC9bY.cjs');
2
+ const require_constants = require('./constants-zXY4MUBL.cjs');
3
+ const require_version = require('./version-g6exOvkr.cjs');
4
+ const require_types = require('./types-DViCeKUc.cjs');
5
+ const node_child_process = require_chunk.__toESM(require("node:child_process"));
6
+ const node_fs = require_chunk.__toESM(require("node:fs"));
7
+
8
+ //#region src/auth/device-code-flow.ts
9
+ const USER_AGENT = `sentry-mcp-server/${require_version.LIB_VERSION}`;
10
+ var DeviceCodeError = class extends Error {
11
+ constructor(message, code) {
12
+ super(message);
13
+ this.code = code;
14
+ this.name = "DeviceCodeError";
15
+ }
16
+ };
17
+ async function requestDeviceCode(clientId, host, scopes = require_constants.DEVICE_CODE_SCOPES) {
18
+ const url = `https://${host}${require_constants.DEVICE_CODE_ENDPOINT}`;
19
+ const resp = await fetch(url, {
20
+ method: "POST",
21
+ headers: {
22
+ "Content-Type": "application/x-www-form-urlencoded",
23
+ "User-Agent": USER_AGENT
24
+ },
25
+ body: new URLSearchParams({
26
+ client_id: clientId,
27
+ scope: scopes
28
+ })
29
+ });
30
+ if (!resp.ok) {
31
+ const text = await resp.text();
32
+ throw new DeviceCodeError(`Failed to request device code (HTTP ${resp.status}): ${text}`);
33
+ }
34
+ const body = await resp.json();
35
+ return require_types.DeviceCodeResponseSchema.parse(body);
36
+ }
37
+ function sleep(ms) {
38
+ return new Promise((resolve) => setTimeout(resolve, ms));
39
+ }
40
+ async function pollForToken({ deviceCode, clientId, host, interval, expiresIn }) {
41
+ const url = `https://${host}${require_constants.TOKEN_ENDPOINT}`;
42
+ const deadline = Date.now() + expiresIn * 1e3;
43
+ let pollInterval = interval;
44
+ while (Date.now() < deadline) {
45
+ await sleep(pollInterval * 1e3);
46
+ const resp = await fetch(url, {
47
+ method: "POST",
48
+ headers: {
49
+ "Content-Type": "application/x-www-form-urlencoded",
50
+ "User-Agent": USER_AGENT
51
+ },
52
+ body: new URLSearchParams({
53
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
54
+ device_code: deviceCode,
55
+ client_id: clientId
56
+ })
57
+ });
58
+ if (resp.ok) {
59
+ const body = await resp.json();
60
+ return require_types.TokenResponseSchema.parse(body);
61
+ }
62
+ const errorBody = await resp.json().catch(() => null);
63
+ const parsed = require_types.DeviceCodeErrorSchema.safeParse(errorBody);
64
+ const errorCode = parsed.success ? parsed.data.error : void 0;
65
+ switch (errorCode) {
66
+ case "authorization_pending": continue;
67
+ case "slow_down":
68
+ pollInterval += require_constants.SLOW_DOWN_INCREMENT_SEC;
69
+ continue;
70
+ case "access_denied": throw new DeviceCodeError("Authorization was denied. Please try again or provide --access-token.", errorCode);
71
+ case "expired_token": throw new DeviceCodeError("Device code expired before authorization was completed.", errorCode);
72
+ default: throw new DeviceCodeError(`Unexpected error during device code polling: ${errorCode ?? resp.statusText}`, errorCode);
73
+ }
74
+ }
75
+ throw new DeviceCodeError("Device code expired before authorization was completed.", "expired_token");
76
+ }
77
+ /**
78
+ * Write directly to stderr, bypassing console.warn which may be
79
+ * intercepted by the MCP transport layer.
80
+ */
81
+ function stderr(msg) {
82
+ process.stderr.write(`${msg}\n`);
83
+ }
84
+ function isWSL() {
85
+ try {
86
+ return node_fs.readFileSync("/proc/version", "utf-8").toLowerCase().includes("microsoft");
87
+ } catch {
88
+ return false;
89
+ }
90
+ }
91
+ function openBrowser(url) {
92
+ try {
93
+ const { platform } = process;
94
+ if (platform === "darwin") (0, node_child_process.exec)(`open ${JSON.stringify(url)}`);
95
+ else if (platform === "win32") (0, node_child_process.exec)(`start "" ${JSON.stringify(url)}`);
96
+ else if (isWSL()) (0, node_child_process.exec)(`cmd.exe /c start "" ${JSON.stringify(url)}`);
97
+ else (0, node_child_process.exec)(`xdg-open ${JSON.stringify(url)}`);
98
+ } catch {}
99
+ }
100
+ function displayDeviceCode(response) {
101
+ stderr("");
102
+ stderr(`To authorize, visit: ${response.verification_uri_complete}`);
103
+ stderr(` and enter code: ${response.user_code}`);
104
+ stderr("");
105
+ stderr("Waiting for authorization...");
106
+ openBrowser(response.verification_uri_complete);
107
+ }
108
+ async function authenticate({ clientId, host }) {
109
+ stderr("No access token provided. Starting device authorization...");
110
+ const deviceCodeResponse = await requestDeviceCode(clientId, host);
111
+ displayDeviceCode(deviceCodeResponse);
112
+ const tokenResponse = await pollForToken({
113
+ deviceCode: deviceCodeResponse.device_code,
114
+ clientId,
115
+ host,
116
+ interval: deviceCodeResponse.interval,
117
+ expiresIn: deviceCodeResponse.expires_in
118
+ });
119
+ stderr(`Successfully authenticated as ${require_types.getTokenUserLabel(tokenResponse)}`);
120
+ return tokenResponse;
121
+ }
122
+
123
+ //#endregion
124
+ Object.defineProperty(exports, 'DeviceCodeError', {
125
+ enumerable: true,
126
+ get: function () {
127
+ return DeviceCodeError;
128
+ }
129
+ });
130
+ Object.defineProperty(exports, 'authenticate', {
131
+ enumerable: true,
132
+ get: function () {
133
+ return authenticate;
134
+ }
135
+ });
136
+ Object.defineProperty(exports, 'displayDeviceCode', {
137
+ enumerable: true,
138
+ get: function () {
139
+ return displayDeviceCode;
140
+ }
141
+ });
142
+ Object.defineProperty(exports, 'pollForToken', {
143
+ enumerable: true,
144
+ get: function () {
145
+ return pollForToken;
146
+ }
147
+ });
148
+ Object.defineProperty(exports, 'requestDeviceCode', {
149
+ enumerable: true,
150
+ get: function () {
151
+ return requestDeviceCode;
152
+ }
153
+ });
154
+ //# sourceMappingURL=device-code-flow-B-sYi7io.cjs.map