@sentry/mcp-server 0.34.0 → 0.36.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.
- package/dist/auth/constants.cjs +1 -1
- package/dist/auth/constants.js +1 -1
- package/dist/auth/device-code-flow.cjs +3 -3
- package/dist/auth/device-code-flow.d.ts +1 -1
- package/dist/auth/device-code-flow.js +4 -4
- package/dist/auth/resolve-token.cjs +4 -4
- package/dist/auth/resolve-token.d.ts +1 -1
- package/dist/auth/resolve-token.js +6 -6
- package/dist/auth/token-cache.d.ts +1 -1
- package/dist/auth/token-cache.js +1 -1
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/types.js +1 -1
- package/dist/{auth-A9SbZrVW.js → auth-CRgAEwzo.js} +7 -7
- package/dist/{auth-A9SbZrVW.js.map → auth-CRgAEwzo.js.map} +1 -1
- package/dist/{auth-BFtSFR07.cjs → auth-D8TSQ4oy.cjs} +4 -4
- package/dist/{auth-BFtSFR07.cjs.map → auth-D8TSQ4oy.cjs.map} +1 -1
- package/dist/blob-utils-6d2dcrax.js +3 -0
- package/dist/blob-utils-B_m4t9Jw.cjs +3 -0
- package/dist/blob-utils-Cle0aVpg-6ww8NFf5.js +4692 -0
- package/dist/blob-utils-Cle0aVpg-6ww8NFf5.js.map +1 -0
- package/dist/blob-utils-Cle0aVpg-hsHMwzjW.cjs +4709 -0
- package/dist/blob-utils-Cle0aVpg-hsHMwzjW.cjs.map +1 -0
- package/dist/chunk-CunrlGP7.js +37 -0
- package/dist/cli/commands/auth.cjs +5 -5
- package/dist/cli/commands/auth.js +8 -8
- package/dist/cli/parse.d.ts +1 -1
- package/dist/cli/parse.d.ts.map +1 -1
- package/dist/cli/parse.js +1 -1
- package/dist/cli/resolve.cjs +2 -2
- package/dist/cli/resolve.d.ts +1 -1
- package/dist/cli/resolve.js +2 -2
- package/dist/cli/types.d.ts +1 -1
- package/dist/cli/usage.js +1 -1
- package/dist/{config-YHBj037H-DRbUBG2X.js → config-9W1R-AgS-DQqdqWsA.js} +2 -2
- package/dist/config-9W1R-AgS-DQqdqWsA.js.map +1 -0
- package/dist/{config-YHBj037H-DI-vM9pT.cjs → config-9W1R-AgS-i6Wokc_9.cjs} +2 -2
- package/dist/config-9W1R-AgS-i6Wokc_9.cjs.map +1 -0
- package/dist/config-CMn1JPkk.cjs +7 -0
- package/dist/{config-Bnslg67w.js → config-CNbv1NHi.js} +1 -1
- package/dist/{constants-CR1eH5g2.js → constants-DGLkHYpN.js} +25 -4
- package/dist/constants-DGLkHYpN.js.map +1 -0
- package/dist/{constants-DxEbVScP.cjs → constants-n6iE6tnq.cjs} +36 -3
- package/dist/constants-n6iE6tnq.cjs.map +1 -0
- package/dist/{device-code-flow-DmHR9gAX.cjs → device-code-flow-DpBK3Ta8.cjs} +3 -3
- package/dist/{device-code-flow-DmHR9gAX.cjs.map → device-code-flow-DpBK3Ta8.cjs.map} +1 -1
- package/dist/{device-code-flow-C5A4Ubww.js → device-code-flow-E2NU5-6y.js} +4 -4
- package/dist/{device-code-flow-C5A4Ubww.js.map → device-code-flow-E2NU5-6y.js.map} +1 -1
- package/dist/index.cjs +5251 -1383
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5252 -1383
- package/dist/index.js.map +1 -1
- package/dist/{parse-BSFxOAQG.js → parse-CjQzHya6.js} +1 -1
- package/dist/{parse-BSFxOAQG.js.map → parse-CjQzHya6.js.map} +1 -1
- package/dist/{resolve-BOBiWoGW.cjs → resolve-8yBa_PAl.cjs} +3 -3
- package/dist/resolve-8yBa_PAl.cjs.map +1 -0
- package/dist/{resolve-rfTy87TT.js → resolve-FA_uxRo8.js} +3 -3
- package/dist/resolve-FA_uxRo8.js.map +1 -0
- package/dist/{resolve-token-BBveHRyr.js → resolve-token-74r8iwMZ.js} +5 -5
- package/dist/{resolve-token-BBveHRyr.js.map → resolve-token-74r8iwMZ.js.map} +1 -1
- package/dist/{resolve-token-D3Ti8TJ_.cjs → resolve-token-Is-MZ02B.cjs} +3 -3
- package/dist/{resolve-token-D3Ti8TJ_.cjs.map → resolve-token-Is-MZ02B.cjs.map} +1 -1
- package/dist/{stdio-MUSHk0bq.js → stdio-D9nJL1b3.js} +17 -8
- package/dist/stdio-D9nJL1b3.js.map +1 -0
- package/dist/{stdio-CNiKUCkA.cjs → stdio-zkywG2E1.cjs} +17 -8
- package/dist/stdio-zkywG2E1.cjs.map +1 -0
- package/dist/{token-YhriRz-K.js → token-BZUr25tZ.js} +4 -3
- package/dist/{token-YhriRz-K.js.map → token-BZUr25tZ.js.map} +1 -1
- package/dist/{token-cache-DHBN2ixb.js → token-cache-BxoAFS6B.js} +1 -1
- package/dist/{token-cache-DHBN2ixb.js.map → token-cache-BxoAFS6B.js.map} +1 -1
- package/dist/token-error-CBmJNKLY.js +43 -0
- package/dist/{token-error-Df8A7mgb.js.map → token-error-CBmJNKLY.js.map} +1 -1
- package/dist/{token-util-Dnkz6ExF.js → token-util-CyoHfXBG.js} +3 -2
- package/dist/{token-util-Dnkz6ExF.js.map → token-util-CyoHfXBG.js.map} +1 -1
- package/dist/token-util-DER1G2YU.js +4 -0
- package/dist/transports/stdio.cjs +2 -2
- package/dist/transports/stdio.d.cts +9 -5
- package/dist/transports/stdio.d.cts.map +1 -1
- package/dist/transports/stdio.d.ts +9 -5
- package/dist/transports/stdio.d.ts.map +1 -1
- package/dist/transports/stdio.js +2 -2
- package/dist/{types-BdLzKRyK.d.ts → types-B6xU9-uZ.d.ts} +1 -1
- package/dist/{types-BdLzKRyK.d.ts.map → types-B6xU9-uZ.d.ts.map} +1 -1
- package/dist/{types-nsyASfJr.js → types-CRcGDSCR.js} +1 -1
- package/dist/{types-nsyASfJr.js.map → types-CRcGDSCR.js.map} +1 -1
- package/dist/{types-C0xriI9T.d.ts → types-CX5R989g.d.ts} +1 -1
- package/dist/{types-C0xriI9T.d.ts.map → types-CX5R989g.d.ts.map} +1 -1
- package/dist/{usage-CyXue87B.js → usage-BvMOKdze.js} +1 -1
- package/dist/{usage-CyXue87B.js.map → usage-BvMOKdze.js.map} +1 -1
- package/dist/{version-B6ykl6YN.cjs → version-0F5BJUB4.cjs} +3 -3
- package/dist/version-0F5BJUB4.cjs.map +1 -0
- package/dist/version-BT_3sqKh.js +7 -0
- package/dist/version-BT_3sqKh.js.map +1 -0
- package/package.json +6 -6
- package/dist/blob-utils-B9a20TSV.js +0 -3
- package/dist/blob-utils-CGHZbDNh-CN3juEJQ.cjs +0 -66
- package/dist/blob-utils-CGHZbDNh-CN3juEJQ.cjs.map +0 -1
- package/dist/blob-utils-CGHZbDNh-Dhzb2_wT.js +0 -54
- package/dist/blob-utils-CGHZbDNh-Dhzb2_wT.js.map +0 -1
- package/dist/blob-utils-dQmZRlIb.cjs +0 -3
- package/dist/config-IA5hZFjI.cjs +0 -7
- package/dist/config-YHBj037H-DI-vM9pT.cjs.map +0 -1
- package/dist/config-YHBj037H-DRbUBG2X.js.map +0 -1
- package/dist/constants-CR1eH5g2.js.map +0 -1
- package/dist/constants-DxEbVScP.cjs.map +0 -1
- package/dist/resolve-BOBiWoGW.cjs.map +0 -1
- package/dist/resolve-rfTy87TT.js.map +0 -1
- package/dist/stdio-CNiKUCkA.cjs.map +0 -1
- package/dist/stdio-MUSHk0bq.js.map +0 -1
- package/dist/token-error-Df8A7mgb.js +0 -77
- package/dist/token-util-7XgZqk3d.js +0 -4
- package/dist/version-B6ykl6YN.cjs.map +0 -1
- package/dist/version-DsnkzOWJ.js +0 -7
- package/dist/version-DsnkzOWJ.js.map +0 -1
|
@@ -25,7 +25,7 @@ function normalizeEventsDataset(dataset) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
//#region ../mcp-core/dist/url-utils-
|
|
28
|
+
//#region ../mcp-core/dist/url-utils-CBQKJaBu.js
|
|
29
29
|
/**
|
|
30
30
|
* Determines if a Sentry instance is SaaS or self-hosted based on the host.
|
|
31
31
|
* @param host The Sentry host (e.g., "sentry.io" or "sentry.company.com")
|
|
@@ -173,6 +173,16 @@ function getIssueUrl(host, organizationSlug, issueId, protocol = "https") {
|
|
|
173
173
|
return getSentryWebBaseUrl(host, organizationSlug, `/issues/${issueId}`, protocol);
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
|
+
* Generates a Sentry preprod snapshot URL.
|
|
177
|
+
* @param host The Sentry host (may include regional subdomain for API access)
|
|
178
|
+
* @param organizationSlug Organization identifier
|
|
179
|
+
* @param snapshotId Preprod snapshot artifact ID
|
|
180
|
+
* @returns The complete snapshot URL
|
|
181
|
+
*/
|
|
182
|
+
function getPreprodSnapshotUrl(host, organizationSlug, snapshotId, protocol = "https") {
|
|
183
|
+
return getSentryWebBaseUrl(host, organizationSlug, `/preprod/snapshots/${snapshotId}/`, protocol);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
176
186
|
* Generates a Sentry cron monitor URL.
|
|
177
187
|
* @param host The Sentry host (may include regional subdomain for API access)
|
|
178
188
|
* @param organizationSlug Organization identifier
|
|
@@ -190,7 +200,8 @@ function getMonitorUrl(host, organizationSlug, monitorSlug, protocol = "https")
|
|
|
190
200
|
* @returns The complete release URL
|
|
191
201
|
*/
|
|
192
202
|
function getReleaseUrl(host, organizationSlug, releaseVersion, protocol = "https") {
|
|
193
|
-
|
|
203
|
+
const encodedReleaseVersion = encodeURIComponent(releaseVersion);
|
|
204
|
+
return getSentryWebBaseUrl(host, organizationSlug, `/releases/${encodedReleaseVersion}/`, protocol);
|
|
194
205
|
}
|
|
195
206
|
/**
|
|
196
207
|
* Generates a Sentry issues search URL.
|
|
@@ -255,6 +266,16 @@ function getTraceUrl(host, organizationSlug, traceId, protocol = "https") {
|
|
|
255
266
|
function getReplayUrl(host, organizationSlug, replayId, protocol = "https") {
|
|
256
267
|
return getSentryWebBaseUrl(host, organizationSlug, `/explore/replays/${replayId}/`, protocol);
|
|
257
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Generates a Sentry AI conversation URL.
|
|
271
|
+
* @param host The Sentry host
|
|
272
|
+
* @param organizationSlug Organization identifier
|
|
273
|
+
* @param conversationId AI conversation identifier
|
|
274
|
+
* @returns The complete AI conversation URL
|
|
275
|
+
*/
|
|
276
|
+
function getAIConversationUrl(host, organizationSlug, conversationId, protocol = "https") {
|
|
277
|
+
return getSentryWebBaseUrl(host, organizationSlug, `/explore/conversations/${conversationId}/`, protocol);
|
|
278
|
+
}
|
|
258
279
|
function getProfileUrl(host, organizationSlug, projectSlug, profileId, protocol = "https") {
|
|
259
280
|
return getSentryWebBaseUrl(host, organizationSlug, `/explore/profiling/profile/${projectSlug}/${profileId}/flamegraph/`, protocol);
|
|
260
281
|
}
|
|
@@ -406,6 +427,12 @@ Object.defineProperty(exports, 'TOKEN_ENDPOINT', {
|
|
|
406
427
|
return TOKEN_ENDPOINT;
|
|
407
428
|
}
|
|
408
429
|
});
|
|
430
|
+
Object.defineProperty(exports, 'getAIConversationUrl', {
|
|
431
|
+
enumerable: true,
|
|
432
|
+
get: function () {
|
|
433
|
+
return getAIConversationUrl;
|
|
434
|
+
}
|
|
435
|
+
});
|
|
409
436
|
Object.defineProperty(exports, 'getContinuousProfileUrl', {
|
|
410
437
|
enumerable: true,
|
|
411
438
|
get: function () {
|
|
@@ -430,6 +457,12 @@ Object.defineProperty(exports, 'getMonitorUrl', {
|
|
|
430
457
|
return getMonitorUrl;
|
|
431
458
|
}
|
|
432
459
|
});
|
|
460
|
+
Object.defineProperty(exports, 'getPreprodSnapshotUrl', {
|
|
461
|
+
enumerable: true,
|
|
462
|
+
get: function () {
|
|
463
|
+
return getPreprodSnapshotUrl;
|
|
464
|
+
}
|
|
465
|
+
});
|
|
433
466
|
Object.defineProperty(exports, 'getProfileUrl', {
|
|
434
467
|
enumerable: true,
|
|
435
468
|
get: function () {
|
|
@@ -514,4 +547,4 @@ Object.defineProperty(exports, 'validateSentryHostThrows', {
|
|
|
514
547
|
return validateSentryHostThrows;
|
|
515
548
|
}
|
|
516
549
|
});
|
|
517
|
-
//# sourceMappingURL=constants-
|
|
550
|
+
//# sourceMappingURL=constants-n6iE6tnq.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-n6iE6tnq.cjs","names":[],"sources":["../../mcp-core/dist/events-datasets-DTs4kChz.js","../../mcp-core/dist/url-utils-CBQKJaBu.js","../../mcp-core/dist/scopes.js","../src/auth/constants.ts"],"sourcesContent":["//#region src/utils/events-datasets.ts\nconst PUBLIC_EVENTS_DATASETS = [\n\t\"spans\",\n\t\"errors\",\n\t\"logs\",\n\t\"metrics\",\n\t\"profiles\"\n];\nfunction isMetricsDataset(dataset) {\n\treturn dataset === \"metrics\" || dataset === \"tracemetrics\";\n}\nfunction isProfilesDataset(dataset) {\n\treturn dataset === \"profiles\";\n}\n/**\n* Sentry's product-facing Explore schemas already call this dataset \"metrics\",\n* but the current `/events/` and `/trace-items/attributes/` APIs still expect\n* the legacy `tracemetrics` identifier. Keep MCP aligned with the UI-facing\n* schema and swap only at the transport boundary until the upstream API name\n* catches up.\n*/\nfunction normalizeEventsDataset(dataset) {\n\treturn dataset === \"metrics\" ? \"tracemetrics\" : dataset;\n}\n\n//#endregion\nexport { PUBLIC_EVENTS_DATASETS, isMetricsDataset, isProfilesDataset, normalizeEventsDataset };\n//# sourceMappingURL=events-datasets-DTs4kChz.js.map","import { isMetricsDataset, isProfilesDataset } from \"./events-datasets-DTs4kChz.js\";\n\n//#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}\nfunction deriveSelectedFields(fields, aggregateFunctions, groupByFields) {\n\tif (fields && fields.length > 0) return fields;\n\treturn Array.from(new Set([...groupByFields ?? [], ...aggregateFunctions ?? []]));\n}\nfunction getSentryWebBaseUrl(host, organizationSlug, path, protocol = \"https\") {\n\tconst isSaas = isSentryHost(host);\n\tconst webHost = isSaas ? \"sentry.io\" : host;\n\treturn isSaas ? `${protocol}://${organizationSlug}.${webHost}${path}` : `${protocol}://${host}/organizations/${organizationSlug}${path}`;\n}\nfunction normalizeTraceMetric(metric) {\n\tif (!metric?.name || !metric.type) return null;\n\treturn {\n\t\tname: metric.name,\n\t\ttype: metric.type,\n\t\tunit: metric.unit && metric.unit !== \"-\" ? metric.unit : void 0\n\t};\n}\nfunction extractTraceMetricFromAggregate(field) {\n\tconst match = field.match(/^[^(]+\\((.*)\\)$/);\n\tif (!match) return null;\n\tconst args = match[1].split(\",\").map((arg) => arg.trim()).filter((arg) => arg.length > 0);\n\tif (args.length < 4) return null;\n\treturn normalizeTraceMetric({\n\t\tname: args[1],\n\t\ttype: args[2],\n\t\tunit: args[3]\n\t});\n}\nfunction extractTraceMetricFromQuery(query) {\n\tconst extractValue = (field) => {\n\t\tconst quotedMatch = query.match(new RegExp(`${field}:\"([^\"]+)\"`, \"i\"));\n\t\tif (quotedMatch?.[1]) return quotedMatch[1];\n\t\tconst unquotedMatch = query.match(new RegExp(`${field}:([^\\\\s]+)`, \"i\"));\n\t\treturn unquotedMatch?.[1] ?? null;\n\t};\n\treturn normalizeTraceMetric({\n\t\tname: extractValue(\"metric\\\\.name\") ?? \"\",\n\t\ttype: extractValue(\"metric\\\\.type\") ?? \"\",\n\t\tunit: extractValue(\"metric\\\\.unit\") ?? void 0\n\t});\n}\nfunction dedupeTraceMetrics(metrics) {\n\tconst deduped = /* @__PURE__ */ new Map();\n\tfor (const metric of metrics) {\n\t\tconst normalizedMetric = normalizeTraceMetric(metric);\n\t\tif (!normalizedMetric) continue;\n\t\tconst key = `${normalizedMetric.name}|${normalizedMetric.type}|${normalizedMetric.unit ?? \"\"}`;\n\t\tdeduped.set(key, normalizedMetric);\n\t}\n\treturn [...deduped.values()];\n}\nfunction buildMetricQueryState(params) {\n\treturn JSON.stringify({\n\t\tmetric: params.metric,\n\t\tquery: params.query,\n\t\taggregateFields: [...params.yAxes.map((yAxis) => ({ yAxes: [yAxis] })), ...(params.groupByFields ?? []).map((field) => ({ groupBy: field }))],\n\t\taggregateSortBys: params.aggregateSortBys ?? [],\n\t\tmode: params.mode\n\t});\n}\nfunction getTraceMetricsExploreUrl(host, organizationSlug, options, protocol = \"https\") {\n\tconst { query, projectId, statsPeriod, start, end, sort, aggregateFunctions, groupByFields, traceMetrics } = options;\n\tconst urlParams = new URLSearchParams();\n\tif (projectId) urlParams.set(\"project\", projectId);\n\tif (start && end) {\n\t\turlParams.set(\"start\", start);\n\t\turlParams.set(\"end\", end);\n\t} else urlParams.set(\"statsPeriod\", statsPeriod || \"24h\");\n\tconst aggregateFields = aggregateFunctions ?? [];\n\tconst aggregateGroupByFields = groupByFields ?? [];\n\tconst isAggregateQuery = aggregateFields.length > 0;\n\tconst sortField = sort?.startsWith(\"-\") ? sort.slice(1) : sort;\n\tconst sortKind = sort?.startsWith(\"-\") ? \"desc\" : \"asc\";\n\tif (isAggregateQuery) {\n\t\tconst metricQueries = /* @__PURE__ */ new Map();\n\t\tfor (const aggregateField of aggregateFields) {\n\t\t\tconst metric = extractTraceMetricFromAggregate(aggregateField);\n\t\t\tif (!metric) continue;\n\t\t\tconst key = `${metric.name}|${metric.type}|${metric.unit ?? \"\"}`;\n\t\t\tconst existing = metricQueries.get(key);\n\t\t\tif (existing) existing.yAxes.push(aggregateField);\n\t\t\telse metricQueries.set(key, {\n\t\t\t\tmetric,\n\t\t\t\tyAxes: [aggregateField]\n\t\t\t});\n\t\t}\n\t\tfor (const { metric, yAxes } of metricQueries.values()) {\n\t\t\tconst aggregateSortBys = sortField && (yAxes.includes(sortField) || aggregateGroupByFields.includes(sortField)) ? [{\n\t\t\t\tfield: sortField,\n\t\t\t\tkind: sortKind\n\t\t\t}] : [];\n\t\t\turlParams.append(\"metric\", buildMetricQueryState({\n\t\t\t\tmetric,\n\t\t\t\tquery,\n\t\t\t\tmode: \"aggregate\",\n\t\t\t\tyAxes,\n\t\t\t\tgroupByFields: aggregateGroupByFields,\n\t\t\t\taggregateSortBys\n\t\t\t}));\n\t\t}\n\t} else {\n\t\tconst sampleMetrics = dedupeTraceMetrics([...traceMetrics ?? [], extractTraceMetricFromQuery(query)]);\n\t\tfor (const metric of sampleMetrics) urlParams.append(\"metric\", buildMetricQueryState({\n\t\t\tmetric,\n\t\t\tquery,\n\t\t\tmode: \"samples\",\n\t\t\tyAxes: [\"sum(value)\"],\n\t\t\taggregateSortBys: [{\n\t\t\t\tfield: \"sum(value)\",\n\t\t\t\tkind: \"desc\"\n\t\t\t}]\n\t\t}));\n\t}\n\treturn `${getSentryWebBaseUrl(host, organizationSlug, \"/explore/metrics/\", protocol)}?${urlParams.toString()}`;\n}\nfunction getProfilingExplorerUrl(host, organizationSlug, options, protocol = \"https\") {\n\tconst { query, projectId, statsPeriod, start, end, sort, fields, aggregateFunctions, groupByFields } = options;\n\tconst urlParams = new URLSearchParams();\n\tif (query) urlParams.set(\"query\", query);\n\tif (projectId) urlParams.set(\"project\", projectId);\n\tif (sort) urlParams.set(\"sort\", sort);\n\tfor (const field of deriveSelectedFields(fields, aggregateFunctions, groupByFields)) urlParams.append(\"field\", field);\n\tif (start && end) {\n\t\turlParams.set(\"start\", start);\n\t\turlParams.set(\"end\", end);\n\t} else urlParams.set(\"statsPeriod\", statsPeriod || \"24h\");\n\treturn `${getSentryWebBaseUrl(host, organizationSlug, \"/explore/profiling/\", protocol)}?${urlParams.toString()}`;\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, protocol = \"https\") {\n\treturn getSentryWebBaseUrl(host, organizationSlug, `/issues/${issueId}`, protocol);\n}\n/**\n* Generates a Sentry preprod snapshot URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param snapshotId Preprod snapshot artifact ID\n* @returns The complete snapshot URL\n*/\nfunction getPreprodSnapshotUrl(host, organizationSlug, snapshotId, protocol = \"https\") {\n\treturn getSentryWebBaseUrl(host, organizationSlug, `/preprod/snapshots/${snapshotId}/`, protocol);\n}\n/**\n* Generates a Sentry cron monitor URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param monitorSlug Monitor slug, optionally prefixed with project slug (e.g. \"my-project/my-monitor\")\n* @returns The complete monitor URL\n*/\nfunction getMonitorUrl(host, organizationSlug, monitorSlug, protocol = \"https\") {\n\treturn getSentryWebBaseUrl(host, organizationSlug, `/crons/${monitorSlug}/`, protocol);\n}\n/**\n* Generates a Sentry release URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param releaseVersion Release version identifier\n* @returns The complete release URL\n*/\nfunction getReleaseUrl(host, organizationSlug, releaseVersion, protocol = \"https\") {\n\tconst encodedReleaseVersion = encodeURIComponent(releaseVersion);\n\treturn getSentryWebBaseUrl(host, organizationSlug, `/releases/${encodedReleaseVersion}/`, protocol);\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, protocol = \"https\") {\n\tlet url = getSentryWebBaseUrl(host, organizationSlug, \"/issues/\", protocol);\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 replay search URL.\n* @param host The Sentry host (may include regional subdomain for API access)\n* @param organizationSlug Organization identifier\n* @param options Replay search options\n* @returns The complete replay search URL\n*/\nfunction getReplaysSearchUrl(host, organizationSlug, options = {}, protocol = \"https\") {\n\tconst { query, projectSlugOrId, environment, sort, statsPeriod, start, end } = options;\n\tlet url = getSentryWebBaseUrl(host, organizationSlug, \"/explore/replays/\", protocol);\n\tconst params = new URLSearchParams();\n\tif (projectSlugOrId) params.append(\"project\", projectSlugOrId);\n\tif (query) params.append(\"query\", query);\n\tif (environment) {\n\t\tconst environments = Array.isArray(environment) ? environment : [environment];\n\t\tfor (const value of environments) params.append(\"environment\", value);\n\t}\n\tif (sort) params.append(\"sort\", sort);\n\tif (start && end) {\n\t\tparams.append(\"start\", start);\n\t\tparams.append(\"end\", end);\n\t} else if (statsPeriod) params.append(\"statsPeriod\", statsPeriod);\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, protocol = \"https\") {\n\treturn getSentryWebBaseUrl(host, organizationSlug, `/explore/traces/trace/${traceId}`, protocol);\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, protocol = \"https\") {\n\treturn getSentryWebBaseUrl(host, organizationSlug, `/explore/replays/${replayId}/`, protocol);\n}\n/**\n* Generates a Sentry AI conversation URL.\n* @param host The Sentry host\n* @param organizationSlug Organization identifier\n* @param conversationId AI conversation identifier\n* @returns The complete AI conversation URL\n*/\nfunction getAIConversationUrl(host, organizationSlug, conversationId, protocol = \"https\") {\n\treturn getSentryWebBaseUrl(host, organizationSlug, `/explore/conversations/${conversationId}/`, protocol);\n}\nfunction getProfileUrl(host, organizationSlug, projectSlug, profileId, protocol = \"https\") {\n\treturn getSentryWebBaseUrl(host, organizationSlug, `/explore/profiling/profile/${projectSlug}/${profileId}/flamegraph/`, protocol);\n}\nfunction getContinuousProfileUrl(host, organizationSlug, projectSlug, options, protocol = \"https\") {\n\tconst url = new URL(getSentryWebBaseUrl(host, organizationSlug, `/explore/profiling/profile/${projectSlug}/flamegraph/`, protocol));\n\turl.searchParams.set(\"profilerId\", options.profilerId);\n\turl.searchParams.set(\"start\", options.start);\n\turl.searchParams.set(\"end\", options.end);\n\treturn url.toString();\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\", projectSlugOrId, fields, explorerOptions, protocol = \"https\") {\n\tif (isMetricsDataset(dataset)) {\n\t\tconst derivedAggregateFunctions = explorerOptions?.aggregateFunctions ?? fields?.filter((field) => field.includes(\"(\") && field.includes(\")\"));\n\t\tconst derivedGroupByFields = explorerOptions?.groupByFields ?? fields?.filter((field) => !field.includes(\"(\") && !field.includes(\")\"));\n\t\treturn getTraceMetricsExploreUrl(host, organizationSlug, {\n\t\t\t...explorerOptions,\n\t\t\tquery,\n\t\t\tprojectId: projectSlugOrId,\n\t\t\taggregateFunctions: derivedAggregateFunctions,\n\t\t\tgroupByFields: derivedGroupByFields\n\t\t}, protocol);\n\t}\n\tif (isProfilesDataset(dataset)) {\n\t\tconst derivedAggregateFunctions = explorerOptions?.aggregateFunctions ?? fields?.filter((field) => field.includes(\"(\") && field.includes(\")\"));\n\t\tconst derivedGroupByFields = explorerOptions?.groupByFields ?? fields?.filter((field) => !field.includes(\"(\") && !field.includes(\")\"));\n\t\treturn getProfilingExplorerUrl(host, organizationSlug, {\n\t\t\tquery,\n\t\t\tprojectId: projectSlugOrId,\n\t\t\tfields,\n\t\t\tsort: explorerOptions?.sort,\n\t\t\tstatsPeriod: explorerOptions?.statsPeriod,\n\t\t\tstart: explorerOptions?.start,\n\t\t\tend: explorerOptions?.end,\n\t\t\taggregateFunctions: derivedAggregateFunctions,\n\t\t\tgroupByFields: derivedGroupByFields\n\t\t}, protocol);\n\t}\n\tlet url = getSentryWebBaseUrl(host, organizationSlug, \"/explore/\", protocol);\n\tconst params = new URLSearchParams();\n\tparams.append(\"query\", query);\n\tparams.append(\"dataset\", dataset);\n\tparams.append(\"layout\", \"table\");\n\tif (projectSlugOrId) params.append(\"project\", projectSlugOrId);\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 { getAIConversationUrl, getContinuousProfileUrl, getEventsExplorerUrl, getIssueUrl, getIssuesSearchUrl, getMonitorUrl, getPreprodSnapshotUrl, getProfileUrl, getProfilingExplorerUrl, getReleaseUrl, getReplayUrl, getReplaysSearchUrl, getTraceMetricsExploreUrl, getTraceUrl, isSentryHost, validateAndParseSentryUrl, validateAndParseSentryUrlThrows, validateOpenAiBaseUrlThrows, validateSentryHost, validateSentryHostThrows };\n//# sourceMappingURL=url-utils-CBQKJaBu.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":";;AACA,MAAM,yBAAyB;CAC9B;CACA;CACA;CACA;CACA;AACA;AACD,SAAS,iBAAiB,SAAS;AAClC,Q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AI,OAAO,aAAa,YAAY,OAAO,aAAa,QAAS,OAAM,IAAI,MAAM;AACjF,QAAO,OAAO,UAAU;AACxB;;;;ACpZD,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,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-Cv9WC9bY.cjs');
|
|
2
|
-
const require_constants = require('./constants-
|
|
3
|
-
const require_version = require('./version-
|
|
2
|
+
const require_constants = require('./constants-n6iE6tnq.cjs');
|
|
3
|
+
const require_version = require('./version-0F5BJUB4.cjs');
|
|
4
4
|
const require_types = require('./types-CxTPg1vE.cjs');
|
|
5
5
|
const node_child_process = require_chunk.__toESM(require("node:child_process"));
|
|
6
6
|
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
@@ -151,4 +151,4 @@ Object.defineProperty(exports, 'requestDeviceCode', {
|
|
|
151
151
|
return requestDeviceCode;
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
|
-
//# sourceMappingURL=device-code-flow-
|
|
154
|
+
//# sourceMappingURL=device-code-flow-DpBK3Ta8.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-code-flow-
|
|
1
|
+
{"version":3,"file":"device-code-flow-DpBK3Ta8.cjs","names":["LIB_VERSION","message: string","code?: string","clientId: string","host: string","scopes: string","DEVICE_CODE_SCOPES","DEVICE_CODE_ENDPOINT","ms: number","TOKEN_ENDPOINT","SLOW_DOWN_INCREMENT_SEC","msg: string","url: string","response: DeviceCodeResponse"],"sources":["../src/auth/device-code-flow.ts"],"sourcesContent":["import { exec } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport { LIB_VERSION } from \"@sentry/mcp-core/version\";\nimport {\n DEVICE_CODE_ENDPOINT,\n DEVICE_CODE_SCOPES,\n SLOW_DOWN_INCREMENT_SEC,\n TOKEN_ENDPOINT,\n} from \"./constants\";\nimport {\n DeviceCodeResponseSchema,\n DeviceCodeErrorSchema,\n TokenResponseSchema,\n getTokenUserLabel,\n type DeviceCodeResponse,\n type TokenResponse,\n} from \"./types\";\n\nconst USER_AGENT = `sentry-mcp-server/${LIB_VERSION}`;\n\nexport class DeviceCodeError extends Error {\n constructor(\n message: string,\n public readonly code?: string,\n ) {\n super(message);\n this.name = \"DeviceCodeError\";\n }\n}\n\nexport async function requestDeviceCode(\n clientId: string,\n host: string,\n scopes: string = DEVICE_CODE_SCOPES,\n): Promise<DeviceCodeResponse> {\n const url = `https://${host}${DEVICE_CODE_ENDPOINT}`;\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"User-Agent\": USER_AGENT,\n },\n body: new URLSearchParams({\n client_id: clientId,\n scope: scopes,\n }),\n });\n\n if (!resp.ok) {\n const text = await resp.text();\n throw new DeviceCodeError(\n `Failed to request device code (HTTP ${resp.status}): ${text}`,\n );\n }\n\n const body = await resp.json();\n return DeviceCodeResponseSchema.parse(body);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport async function pollForToken({\n deviceCode,\n clientId,\n host,\n interval,\n expiresIn,\n}: {\n deviceCode: string;\n clientId: string;\n host: string;\n interval: number;\n expiresIn: number;\n}): Promise<TokenResponse> {\n const url = `https://${host}${TOKEN_ENDPOINT}`;\n const deadline = Date.now() + expiresIn * 1000;\n let pollInterval = interval;\n\n while (Date.now() < deadline) {\n await sleep(pollInterval * 1000);\n\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"User-Agent\": USER_AGENT,\n },\n body: new URLSearchParams({\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n device_code: deviceCode,\n client_id: clientId,\n }),\n });\n\n if (resp.ok) {\n const body = await resp.json();\n return TokenResponseSchema.parse(body);\n }\n\n const errorBody = await resp.json().catch(() => null);\n const parsed = DeviceCodeErrorSchema.safeParse(errorBody);\n const errorCode = parsed.success ? parsed.data.error : undefined;\n\n switch (errorCode) {\n case \"authorization_pending\":\n // Keep polling at current interval\n continue;\n case \"slow_down\":\n pollInterval += SLOW_DOWN_INCREMENT_SEC;\n continue;\n case \"access_denied\":\n throw new DeviceCodeError(\n \"Authorization was denied. Please try again or provide --access-token.\",\n errorCode,\n );\n case \"expired_token\":\n throw new DeviceCodeError(\n \"Device code expired before authorization was completed.\",\n errorCode,\n );\n default:\n throw new DeviceCodeError(\n `Unexpected error during device code polling: ${errorCode ?? resp.statusText}`,\n errorCode,\n );\n }\n }\n\n throw new DeviceCodeError(\n \"Device code expired before authorization was completed.\",\n \"expired_token\",\n );\n}\n\n/**\n * Write directly to stderr, bypassing console.warn which may be\n * intercepted by the MCP transport layer.\n */\nfunction stderr(msg: string): void {\n process.stderr.write(`${msg}\\n`);\n}\n\nfunction isWSL(): boolean {\n try {\n return fs\n .readFileSync(\"/proc/version\", \"utf-8\")\n .toLowerCase()\n .includes(\"microsoft\");\n } catch {\n return false;\n }\n}\n\nfunction openBrowser(url: string): void {\n try {\n const { platform } = process;\n if (platform === \"darwin\") {\n exec(`open ${JSON.stringify(url)}`);\n } else if (platform === \"win32\") {\n exec(`start \"\" ${JSON.stringify(url)}`);\n } else if (isWSL()) {\n // WSL: invoke cmd.exe to open the default browser.\n exec(`cmd.exe /c start \"\" ${JSON.stringify(url)}`);\n } else {\n exec(`xdg-open ${JSON.stringify(url)}`);\n }\n } catch {\n // Best-effort — ignore errors (headless, etc.)\n }\n}\n\nexport function displayDeviceCode(response: DeviceCodeResponse): void {\n stderr(\"\");\n stderr(`To authorize, visit: ${response.verification_uri_complete}`);\n stderr(` and enter code: ${response.user_code}`);\n stderr(\"\");\n stderr(\"Waiting for authorization...\");\n\n openBrowser(response.verification_uri_complete);\n}\n\nexport async function authenticate({\n clientId,\n host,\n}: {\n clientId: string;\n host: string;\n}): Promise<TokenResponse> {\n stderr(\"No access token provided. Starting device authorization...\");\n\n const deviceCodeResponse = await requestDeviceCode(clientId, host);\n displayDeviceCode(deviceCodeResponse);\n\n const tokenResponse = await pollForToken({\n deviceCode: deviceCodeResponse.device_code,\n clientId,\n host,\n interval: deviceCodeResponse.interval,\n expiresIn: deviceCodeResponse.expires_in,\n });\n\n stderr(`Successfully authenticated as ${getTokenUserLabel(tokenResponse)}`);\n return tokenResponse;\n}\n"],"mappings":";;;;;;;;AAkBA,MAAM,cAAc,oBAAoBA;AAExC,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACEC,SACgBC,MAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;CACb;AACF;AAED,eAAsB,kBACpBC,UACAC,MACAC,SAAiBC,sCACY;CAC7B,MAAM,OAAO,UAAU,OAAOC;CAC9B,MAAM,OAAO,MAAM,MAAM,KAAK;EAC5B,QAAQ;EACR,SAAS;GACP,gBAAgB;GAChB,cAAc;EACf;EACD,MAAM,IAAI,gBAAgB;GACxB,WAAW;GACX,OAAO;EACR;CACF,EAAC;AAEF,MAAK,KAAK,IAAI;EACZ,MAAM,OAAO,MAAM,KAAK,MAAM;AAC9B,QAAM,IAAI,iBACP,sCAAsC,KAAK,OAAO,KAAK;CAE3D;CAED,MAAM,OAAO,MAAM,KAAK,MAAM;AAC9B,QAAO,uCAAyB,MAAM,KAAK;AAC5C;AAED,SAAS,MAAMC,IAA2B;AACxC,QAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAG;AACxD;AAED,eAAsB,aAAa,EACjC,YACA,UACA,MACA,UACA,WAOD,EAA0B;CACzB,MAAM,OAAO,UAAU,OAAOC;CAC9B,MAAM,WAAW,KAAK,KAAK,GAAG,YAAY;CAC1C,IAAI,eAAe;AAEn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CAEP;AACF;AAED,SAAgB,kBAAkBC,UAAoC;AACpE,QAAO,GAAG;AACV,SAAQ,uBAAuB,SAAS,4BAA4B;AACpE,SAAQ,oBAAoB,SAAS,YAAY;AACjD,QAAO,GAAG;AACV,QAAO,+BAA+B;AAEtC,aAAY,SAAS,0BAA0B;AAChD;AAED,eAAsB,aAAa,EACjC,UACA,MAID,EAA0B;AACzB,QAAO,6DAA6D;CAEpE,MAAM,qBAAqB,MAAM,kBAAkB,UAAU,KAAK;AAClE,mBAAkB,mBAAmB;CAErC,MAAM,gBAAgB,MAAM,aAAa;EACvC,YAAY,mBAAmB;EAC/B;EACA;EACA,UAAU,mBAAmB;EAC7B,WAAW,mBAAmB;CAC/B,EAAC;AAEF,SAAQ,gCAAgC,gCAAkB,cAAc,GAAG;AAC3E,QAAO;AACR"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DEVICE_CODE_ENDPOINT, DEVICE_CODE_SCOPES, SLOW_DOWN_INCREMENT_SEC, TOKEN_ENDPOINT } from "./constants-
|
|
2
|
-
import { LIB_VERSION } from "./version-
|
|
3
|
-
import { DeviceCodeErrorSchema, DeviceCodeResponseSchema, TokenResponseSchema, getTokenUserLabel } from "./types-
|
|
1
|
+
import { DEVICE_CODE_ENDPOINT, DEVICE_CODE_SCOPES, SLOW_DOWN_INCREMENT_SEC, TOKEN_ENDPOINT } from "./constants-DGLkHYpN.js";
|
|
2
|
+
import { LIB_VERSION } from "./version-BT_3sqKh.js";
|
|
3
|
+
import { DeviceCodeErrorSchema, DeviceCodeResponseSchema, TokenResponseSchema, getTokenUserLabel } from "./types-CRcGDSCR.js";
|
|
4
4
|
import { exec } from "node:child_process";
|
|
5
5
|
import * as fs from "node:fs";
|
|
6
6
|
|
|
@@ -121,4 +121,4 @@ async function authenticate({ clientId, host }) {
|
|
|
121
121
|
|
|
122
122
|
//#endregion
|
|
123
123
|
export { DeviceCodeError, authenticate, displayDeviceCode, pollForToken, requestDeviceCode };
|
|
124
|
-
//# sourceMappingURL=device-code-flow-
|
|
124
|
+
//# sourceMappingURL=device-code-flow-E2NU5-6y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-code-flow-
|
|
1
|
+
{"version":3,"file":"device-code-flow-E2NU5-6y.js","names":["message: string","code?: string","clientId: string","host: string","scopes: string","ms: number","msg: string","url: string","response: DeviceCodeResponse"],"sources":["../src/auth/device-code-flow.ts"],"sourcesContent":["import { exec } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport { LIB_VERSION } from \"@sentry/mcp-core/version\";\nimport {\n DEVICE_CODE_ENDPOINT,\n DEVICE_CODE_SCOPES,\n SLOW_DOWN_INCREMENT_SEC,\n TOKEN_ENDPOINT,\n} from \"./constants\";\nimport {\n DeviceCodeResponseSchema,\n DeviceCodeErrorSchema,\n TokenResponseSchema,\n getTokenUserLabel,\n type DeviceCodeResponse,\n type TokenResponse,\n} from \"./types\";\n\nconst USER_AGENT = `sentry-mcp-server/${LIB_VERSION}`;\n\nexport class DeviceCodeError extends Error {\n constructor(\n message: string,\n public readonly code?: string,\n ) {\n super(message);\n this.name = \"DeviceCodeError\";\n }\n}\n\nexport async function requestDeviceCode(\n clientId: string,\n host: string,\n scopes: string = DEVICE_CODE_SCOPES,\n): Promise<DeviceCodeResponse> {\n const url = `https://${host}${DEVICE_CODE_ENDPOINT}`;\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"User-Agent\": USER_AGENT,\n },\n body: new URLSearchParams({\n client_id: clientId,\n scope: scopes,\n }),\n });\n\n if (!resp.ok) {\n const text = await resp.text();\n throw new DeviceCodeError(\n `Failed to request device code (HTTP ${resp.status}): ${text}`,\n );\n }\n\n const body = await resp.json();\n return DeviceCodeResponseSchema.parse(body);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport async function pollForToken({\n deviceCode,\n clientId,\n host,\n interval,\n expiresIn,\n}: {\n deviceCode: string;\n clientId: string;\n host: string;\n interval: number;\n expiresIn: number;\n}): Promise<TokenResponse> {\n const url = `https://${host}${TOKEN_ENDPOINT}`;\n const deadline = Date.now() + expiresIn * 1000;\n let pollInterval = interval;\n\n while (Date.now() < deadline) {\n await sleep(pollInterval * 1000);\n\n const resp = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"User-Agent\": USER_AGENT,\n },\n body: new URLSearchParams({\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\",\n device_code: deviceCode,\n client_id: clientId,\n }),\n });\n\n if (resp.ok) {\n const body = await resp.json();\n return TokenResponseSchema.parse(body);\n }\n\n const errorBody = await resp.json().catch(() => null);\n const parsed = DeviceCodeErrorSchema.safeParse(errorBody);\n const errorCode = parsed.success ? parsed.data.error : undefined;\n\n switch (errorCode) {\n case \"authorization_pending\":\n // Keep polling at current interval\n continue;\n case \"slow_down\":\n pollInterval += SLOW_DOWN_INCREMENT_SEC;\n continue;\n case \"access_denied\":\n throw new DeviceCodeError(\n \"Authorization was denied. Please try again or provide --access-token.\",\n errorCode,\n );\n case \"expired_token\":\n throw new DeviceCodeError(\n \"Device code expired before authorization was completed.\",\n errorCode,\n );\n default:\n throw new DeviceCodeError(\n `Unexpected error during device code polling: ${errorCode ?? resp.statusText}`,\n errorCode,\n );\n }\n }\n\n throw new DeviceCodeError(\n \"Device code expired before authorization was completed.\",\n \"expired_token\",\n );\n}\n\n/**\n * Write directly to stderr, bypassing console.warn which may be\n * intercepted by the MCP transport layer.\n */\nfunction stderr(msg: string): void {\n process.stderr.write(`${msg}\\n`);\n}\n\nfunction isWSL(): boolean {\n try {\n return fs\n .readFileSync(\"/proc/version\", \"utf-8\")\n .toLowerCase()\n .includes(\"microsoft\");\n } catch {\n return false;\n }\n}\n\nfunction openBrowser(url: string): void {\n try {\n const { platform } = process;\n if (platform === \"darwin\") {\n exec(`open ${JSON.stringify(url)}`);\n } else if (platform === \"win32\") {\n exec(`start \"\" ${JSON.stringify(url)}`);\n } else if (isWSL()) {\n // WSL: invoke cmd.exe to open the default browser.\n exec(`cmd.exe /c start \"\" ${JSON.stringify(url)}`);\n } else {\n exec(`xdg-open ${JSON.stringify(url)}`);\n }\n } catch {\n // Best-effort — ignore errors (headless, etc.)\n }\n}\n\nexport function displayDeviceCode(response: DeviceCodeResponse): void {\n stderr(\"\");\n stderr(`To authorize, visit: ${response.verification_uri_complete}`);\n stderr(` and enter code: ${response.user_code}`);\n stderr(\"\");\n stderr(\"Waiting for authorization...\");\n\n openBrowser(response.verification_uri_complete);\n}\n\nexport async function authenticate({\n clientId,\n host,\n}: {\n clientId: string;\n host: string;\n}): Promise<TokenResponse> {\n stderr(\"No access token provided. Starting device authorization...\");\n\n const deviceCodeResponse = await requestDeviceCode(clientId, host);\n displayDeviceCode(deviceCodeResponse);\n\n const tokenResponse = await pollForToken({\n deviceCode: deviceCodeResponse.device_code,\n clientId,\n host,\n interval: deviceCodeResponse.interval,\n expiresIn: deviceCodeResponse.expires_in,\n });\n\n stderr(`Successfully authenticated as ${getTokenUserLabel(tokenResponse)}`);\n return tokenResponse;\n}\n"],"mappings":";;;;;;;AAkBA,MAAM,cAAc,oBAAoB;AAExC,IAAa,kBAAb,cAAqC,MAAM;CACzC,YACEA,SACgBC,MAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;CACb;AACF;AAED,eAAsB,kBACpBC,UACAC,MACAC,SAAiB,oBACY;CAC7B,MAAM,OAAO,UAAU,OAAO;CAC9B,MAAM,OAAO,MAAM,MAAM,KAAK;EAC5B,QAAQ;EACR,SAAS;GACP,gBAAgB;GAChB,cAAc;EACf;EACD,MAAM,IAAI,gBAAgB;GACxB,WAAW;GACX,OAAO;EACR;CACF,EAAC;AAEF,MAAK,KAAK,IAAI;EACZ,MAAM,OAAO,MAAM,KAAK,MAAM;AAC9B,QAAM,IAAI,iBACP,sCAAsC,KAAK,OAAO,KAAK;C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