@sentry/mcp-server 0.31.0 → 0.33.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 +4 -4
- package/dist/auth/device-code-flow.d.cts +1 -1
- package/dist/auth/device-code-flow.d.cts.map +1 -1
- package/dist/auth/device-code-flow.d.ts +1 -1
- package/dist/auth/device-code-flow.d.ts.map +1 -1
- package/dist/auth/device-code-flow.js +4 -4
- package/dist/auth/resolve-token.cjs +5 -5
- package/dist/auth/resolve-token.d.cts +1 -1
- package/dist/auth/resolve-token.d.ts +1 -1
- package/dist/auth/resolve-token.js +5 -5
- package/dist/auth/token-cache.d.cts +1 -1
- package/dist/auth/token-cache.d.ts +1 -1
- package/dist/auth/types.cjs +2 -1
- package/dist/auth/types.d.cts +2 -2
- package/dist/auth/types.d.ts +2 -2
- package/dist/auth/types.js +2 -2
- package/dist/{auth-BIb4PBnL.js → auth-BJo6H1uD.js} +6 -6
- package/dist/{auth-BIb4PBnL.js.map → auth-BJo6H1uD.js.map} +1 -1
- package/dist/{auth-BK5LL8QY.cjs → auth-UwueZrbT.cjs} +6 -6
- package/dist/{auth-BK5LL8QY.cjs.map → auth-UwueZrbT.cjs.map} +1 -1
- package/dist/cli/commands/auth.cjs +7 -7
- package/dist/cli/commands/auth.js +7 -7
- package/dist/cli/parse.cjs +1 -1
- package/dist/cli/parse.d.cts +1 -1
- package/dist/cli/parse.d.cts.map +1 -1
- 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.cts +1 -1
- package/dist/cli/resolve.d.cts.map +1 -1
- package/dist/cli/resolve.d.ts +1 -1
- package/dist/cli/resolve.d.ts.map +1 -1
- package/dist/cli/resolve.js +2 -2
- package/dist/cli/types.d.cts +1 -1
- package/dist/cli/types.d.ts +1 -1
- package/dist/cli/usage.cjs +1 -1
- package/dist/cli/usage.js +1 -1
- package/dist/{config-BYPjNBPX-Bqwc8iZW.cjs → config-CSIYxVpS-ClZCOpEv.cjs} +287 -14
- package/dist/config-CSIYxVpS-ClZCOpEv.cjs.map +1 -0
- package/dist/{config-BYPjNBPX-7d8TAxBc.js → config-CSIYxVpS-cfJbXQHs.js} +282 -15
- package/dist/config-CSIYxVpS-cfJbXQHs.js.map +1 -0
- package/dist/config-gtQq2u0M.cjs +7 -0
- package/dist/config-k-CwrU2A.js +3 -0
- package/dist/constants-DjY87Pdc.js +367 -0
- package/dist/constants-DjY87Pdc.js.map +1 -0
- package/dist/constants-wVeitIuo.cjs +517 -0
- package/dist/constants-wVeitIuo.cjs.map +1 -0
- package/dist/{device-code-flow-DmgeS5QN.js → device-code-flow-BJxgQqnk.js} +5 -5
- package/dist/device-code-flow-BJxgQqnk.js.map +1 -0
- package/dist/{device-code-flow-CpGZ3Eqv.cjs → device-code-flow-BMOB5yEt.cjs} +5 -5
- package/dist/device-code-flow-BMOB5yEt.cjs.map +1 -0
- package/dist/index.cjs +4252 -2127
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4247 -2122
- package/dist/index.js.map +1 -1
- package/dist/{parse-BC0czE2L.js → parse-B7klESpr.js} +4 -1
- package/dist/parse-B7klESpr.js.map +1 -0
- package/dist/{parse-CBlXTQfk.cjs → parse-BR-mFmYz.cjs} +4 -1
- package/dist/parse-BR-mFmYz.cjs.map +1 -0
- package/dist/{resolve-D0W2gbu8.js → resolve-BrniID8M.js} +7 -3
- package/dist/resolve-BrniID8M.js.map +1 -0
- package/dist/{resolve-BfYJ9Cqy.cjs → resolve-C24qYHAk.cjs} +7 -3
- package/dist/resolve-C24qYHAk.cjs.map +1 -0
- package/dist/{resolve-token-C2eTEtoo.cjs → resolve-token-ZTTdPX3U.cjs} +4 -4
- package/dist/{resolve-token-C2eTEtoo.cjs.map → resolve-token-ZTTdPX3U.cjs.map} +1 -1
- package/dist/{resolve-token-pfPBO9EK.js → resolve-token-xrdqUeT7.js} +4 -4
- package/dist/{resolve-token-pfPBO9EK.js.map → resolve-token-xrdqUeT7.js.map} +1 -1
- package/dist/{stdio-B08zZS4X.cjs → stdio-CMTtwTjK.cjs} +2 -2
- package/dist/{stdio-B08zZS4X.cjs.map → stdio-CMTtwTjK.cjs.map} +1 -1
- package/dist/{stdio-CUhyR_jH.js → stdio-CrPIATQh.js} +2 -2
- package/dist/{stdio-CUhyR_jH.js.map → stdio-CrPIATQh.js.map} +1 -1
- package/dist/transports/stdio.cjs +2 -2
- package/dist/transports/stdio.d.cts +1 -1
- package/dist/transports/stdio.js +2 -2
- package/dist/{types-rlmLVpNO.d.cts → types-BHd78Leq.d.cts} +6 -2
- package/dist/types-BHd78Leq.d.cts.map +1 -0
- package/dist/{types-ClEPUb_D.d.cts → types-BJpeKPWI.d.cts} +8 -7
- package/dist/types-BJpeKPWI.d.cts.map +1 -0
- package/dist/{types-C8FoyqMN.js → types-C336ZSwF.js} +7 -4
- package/dist/types-C336ZSwF.js.map +1 -0
- package/dist/{types-BN426G4g.d.ts → types-DDkgkRP9.d.ts} +8 -7
- package/dist/types-DDkgkRP9.d.ts.map +1 -0
- package/dist/{types-CX4uOY82.d.ts → types-DEixQGjv.d.ts} +6 -2
- package/dist/types-DEixQGjv.d.ts.map +1 -0
- package/dist/{types-xUmfecYm.cjs → types-DViCeKUc.cjs} +12 -3
- package/dist/types-DViCeKUc.cjs.map +1 -0
- package/dist/{usage-DRK6TiDr.cjs → usage-5IJewEUC.cjs} +7 -4
- package/dist/usage-5IJewEUC.cjs.map +1 -0
- package/dist/{usage-DB-MGezA.js → usage-CJXm-LBM.js} +7 -4
- package/dist/usage-CJXm-LBM.js.map +1 -0
- package/dist/version-C-VwoRFq.js +7 -0
- package/dist/version-C-VwoRFq.js.map +1 -0
- package/dist/{version-Ca7qUBih.cjs → version-CG1gvrBK.cjs} +3 -3
- package/dist/version-CG1gvrBK.cjs.map +1 -0
- package/package.json +5 -5
- package/dist/config--FiEKpQR.js +0 -3
- package/dist/config-BYPjNBPX-7d8TAxBc.js.map +0 -1
- package/dist/config-BYPjNBPX-Bqwc8iZW.cjs.map +0 -1
- package/dist/config-DU03TDiU.cjs +0 -7
- package/dist/constants-Ciwj7kb9.js +0 -153
- package/dist/constants-Ciwj7kb9.js.map +0 -1
- package/dist/constants-DmV1Benp.cjs +0 -231
- package/dist/constants-DmV1Benp.cjs.map +0 -1
- package/dist/device-code-flow-CpGZ3Eqv.cjs.map +0 -1
- package/dist/device-code-flow-DmgeS5QN.js.map +0 -1
- package/dist/parse-BC0czE2L.js.map +0 -1
- package/dist/parse-CBlXTQfk.cjs.map +0 -1
- package/dist/resolve-BfYJ9Cqy.cjs.map +0 -1
- package/dist/resolve-D0W2gbu8.js.map +0 -1
- package/dist/types-BN426G4g.d.ts.map +0 -1
- package/dist/types-C8FoyqMN.js.map +0 -1
- package/dist/types-CX4uOY82.d.ts.map +0 -1
- package/dist/types-ClEPUb_D.d.cts.map +0 -1
- package/dist/types-rlmLVpNO.d.cts.map +0 -1
- package/dist/types-xUmfecYm.cjs.map +0 -1
- package/dist/usage-DB-MGezA.js.map +0 -1
- package/dist/usage-DRK6TiDr.cjs.map +0 -1
- package/dist/version-CYYpU4RZ.js +0 -7
- package/dist/version-CYYpU4RZ.js.map +0 -1
- package/dist/version-Ca7qUBih.cjs.map +0 -1
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
//#region ../mcp-core/dist/events-datasets-Cu37u43g.js
|
|
2
|
+
const PUBLIC_EVENTS_DATASETS = [
|
|
3
|
+
"spans",
|
|
4
|
+
"errors",
|
|
5
|
+
"logs",
|
|
6
|
+
"metrics",
|
|
7
|
+
"profiles"
|
|
8
|
+
];
|
|
9
|
+
function isMetricsDataset(dataset) {
|
|
10
|
+
return dataset === "metrics" || dataset === "tracemetrics";
|
|
11
|
+
}
|
|
12
|
+
function isProfilesDataset(dataset) {
|
|
13
|
+
return dataset === "profiles";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Sentry's product-facing Explore schemas already call this dataset "metrics",
|
|
17
|
+
* but the current `/events/` and `/trace-items/attributes/` APIs still expect
|
|
18
|
+
* the legacy `tracemetrics` identifier. Keep MCP aligned with the UI-facing
|
|
19
|
+
* schema and swap only at the transport boundary until the upstream API name
|
|
20
|
+
* catches up.
|
|
21
|
+
*/
|
|
22
|
+
function normalizeEventsDataset(dataset) {
|
|
23
|
+
return dataset === "metrics" ? "tracemetrics" : dataset;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region ../mcp-core/dist/url-utils-IhqQI_zS.js
|
|
28
|
+
/**
|
|
29
|
+
* Determines if a Sentry instance is SaaS or self-hosted based on the host.
|
|
30
|
+
* @param host The Sentry host (e.g., "sentry.io" or "sentry.company.com")
|
|
31
|
+
* @returns true if SaaS instance, false if self-hosted
|
|
32
|
+
*/
|
|
33
|
+
function isSentryHost(host) {
|
|
34
|
+
return host === "sentry.io" || host.endsWith(".sentry.io");
|
|
35
|
+
}
|
|
36
|
+
function deriveSelectedFields(fields, aggregateFunctions, groupByFields) {
|
|
37
|
+
if (fields && fields.length > 0) return fields;
|
|
38
|
+
return Array.from(new Set([...groupByFields ?? [], ...aggregateFunctions ?? []]));
|
|
39
|
+
}
|
|
40
|
+
function getSentryWebBaseUrl(host, organizationSlug, path, protocol = "https") {
|
|
41
|
+
const isSaas = isSentryHost(host);
|
|
42
|
+
const webHost = isSaas ? "sentry.io" : host;
|
|
43
|
+
return isSaas ? `${protocol}://${organizationSlug}.${webHost}${path}` : `${protocol}://${host}/organizations/${organizationSlug}${path}`;
|
|
44
|
+
}
|
|
45
|
+
function normalizeTraceMetric(metric) {
|
|
46
|
+
if (!metric?.name || !metric.type) return null;
|
|
47
|
+
return {
|
|
48
|
+
name: metric.name,
|
|
49
|
+
type: metric.type,
|
|
50
|
+
unit: metric.unit && metric.unit !== "-" ? metric.unit : void 0
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function extractTraceMetricFromAggregate(field) {
|
|
54
|
+
const match = field.match(/^[^(]+\((.*)\)$/);
|
|
55
|
+
if (!match) return null;
|
|
56
|
+
const args = match[1].split(",").map((arg) => arg.trim()).filter((arg) => arg.length > 0);
|
|
57
|
+
if (args.length < 4) return null;
|
|
58
|
+
return normalizeTraceMetric({
|
|
59
|
+
name: args[1],
|
|
60
|
+
type: args[2],
|
|
61
|
+
unit: args[3]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function extractTraceMetricFromQuery(query) {
|
|
65
|
+
const extractValue = (field) => {
|
|
66
|
+
const quotedMatch = query.match(new RegExp(`${field}:"([^"]+)"`, "i"));
|
|
67
|
+
if (quotedMatch?.[1]) return quotedMatch[1];
|
|
68
|
+
const unquotedMatch = query.match(new RegExp(`${field}:([^\\s]+)`, "i"));
|
|
69
|
+
return unquotedMatch?.[1] ?? null;
|
|
70
|
+
};
|
|
71
|
+
return normalizeTraceMetric({
|
|
72
|
+
name: extractValue("metric\\.name") ?? "",
|
|
73
|
+
type: extractValue("metric\\.type") ?? "",
|
|
74
|
+
unit: extractValue("metric\\.unit") ?? void 0
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function dedupeTraceMetrics(metrics) {
|
|
78
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
79
|
+
for (const metric of metrics) {
|
|
80
|
+
const normalizedMetric = normalizeTraceMetric(metric);
|
|
81
|
+
if (!normalizedMetric) continue;
|
|
82
|
+
const key = `${normalizedMetric.name}|${normalizedMetric.type}|${normalizedMetric.unit ?? ""}`;
|
|
83
|
+
deduped.set(key, normalizedMetric);
|
|
84
|
+
}
|
|
85
|
+
return [...deduped.values()];
|
|
86
|
+
}
|
|
87
|
+
function buildMetricQueryState(params) {
|
|
88
|
+
return JSON.stringify({
|
|
89
|
+
metric: params.metric,
|
|
90
|
+
query: params.query,
|
|
91
|
+
aggregateFields: [...params.yAxes.map((yAxis) => ({ yAxes: [yAxis] })), ...(params.groupByFields ?? []).map((field) => ({ groupBy: field }))],
|
|
92
|
+
aggregateSortBys: params.aggregateSortBys ?? [],
|
|
93
|
+
mode: params.mode
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function getTraceMetricsExploreUrl(host, organizationSlug, options, protocol = "https") {
|
|
97
|
+
const { query, projectId, statsPeriod, start, end, sort, aggregateFunctions, groupByFields, traceMetrics } = options;
|
|
98
|
+
const urlParams = new URLSearchParams();
|
|
99
|
+
if (projectId) urlParams.set("project", projectId);
|
|
100
|
+
if (start && end) {
|
|
101
|
+
urlParams.set("start", start);
|
|
102
|
+
urlParams.set("end", end);
|
|
103
|
+
} else urlParams.set("statsPeriod", statsPeriod || "24h");
|
|
104
|
+
const aggregateFields = aggregateFunctions ?? [];
|
|
105
|
+
const aggregateGroupByFields = groupByFields ?? [];
|
|
106
|
+
const isAggregateQuery = aggregateFields.length > 0;
|
|
107
|
+
const sortField = sort?.startsWith("-") ? sort.slice(1) : sort;
|
|
108
|
+
const sortKind = sort?.startsWith("-") ? "desc" : "asc";
|
|
109
|
+
if (isAggregateQuery) {
|
|
110
|
+
const metricQueries = /* @__PURE__ */ new Map();
|
|
111
|
+
for (const aggregateField of aggregateFields) {
|
|
112
|
+
const metric = extractTraceMetricFromAggregate(aggregateField);
|
|
113
|
+
if (!metric) continue;
|
|
114
|
+
const key = `${metric.name}|${metric.type}|${metric.unit ?? ""}`;
|
|
115
|
+
const existing = metricQueries.get(key);
|
|
116
|
+
if (existing) existing.yAxes.push(aggregateField);
|
|
117
|
+
else metricQueries.set(key, {
|
|
118
|
+
metric,
|
|
119
|
+
yAxes: [aggregateField]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
for (const { metric, yAxes } of metricQueries.values()) {
|
|
123
|
+
const aggregateSortBys = sortField && (yAxes.includes(sortField) || aggregateGroupByFields.includes(sortField)) ? [{
|
|
124
|
+
field: sortField,
|
|
125
|
+
kind: sortKind
|
|
126
|
+
}] : [];
|
|
127
|
+
urlParams.append("metric", buildMetricQueryState({
|
|
128
|
+
metric,
|
|
129
|
+
query,
|
|
130
|
+
mode: "aggregate",
|
|
131
|
+
yAxes,
|
|
132
|
+
groupByFields: aggregateGroupByFields,
|
|
133
|
+
aggregateSortBys
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
const sampleMetrics = dedupeTraceMetrics([...traceMetrics ?? [], extractTraceMetricFromQuery(query)]);
|
|
138
|
+
for (const metric of sampleMetrics) urlParams.append("metric", buildMetricQueryState({
|
|
139
|
+
metric,
|
|
140
|
+
query,
|
|
141
|
+
mode: "samples",
|
|
142
|
+
yAxes: ["sum(value)"],
|
|
143
|
+
aggregateSortBys: [{
|
|
144
|
+
field: "sum(value)",
|
|
145
|
+
kind: "desc"
|
|
146
|
+
}]
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
return `${getSentryWebBaseUrl(host, organizationSlug, "/explore/metrics/", protocol)}?${urlParams.toString()}`;
|
|
150
|
+
}
|
|
151
|
+
function getProfilingExplorerUrl(host, organizationSlug, options, protocol = "https") {
|
|
152
|
+
const { query, projectId, statsPeriod, start, end, sort, fields, aggregateFunctions, groupByFields } = options;
|
|
153
|
+
const urlParams = new URLSearchParams();
|
|
154
|
+
if (query) urlParams.set("query", query);
|
|
155
|
+
if (projectId) urlParams.set("project", projectId);
|
|
156
|
+
if (sort) urlParams.set("sort", sort);
|
|
157
|
+
for (const field of deriveSelectedFields(fields, aggregateFunctions, groupByFields)) urlParams.append("field", field);
|
|
158
|
+
if (start && end) {
|
|
159
|
+
urlParams.set("start", start);
|
|
160
|
+
urlParams.set("end", end);
|
|
161
|
+
} else urlParams.set("statsPeriod", statsPeriod || "24h");
|
|
162
|
+
return `${getSentryWebBaseUrl(host, organizationSlug, "/explore/profiling/", protocol)}?${urlParams.toString()}`;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Generates a Sentry issue URL.
|
|
166
|
+
* @param host The Sentry host (may include regional subdomain for API access)
|
|
167
|
+
* @param organizationSlug Organization identifier
|
|
168
|
+
* @param issueId Issue identifier (e.g., "PROJECT-123")
|
|
169
|
+
* @returns The complete issue URL
|
|
170
|
+
*/
|
|
171
|
+
function getIssueUrl(host, organizationSlug, issueId, protocol = "https") {
|
|
172
|
+
return getSentryWebBaseUrl(host, organizationSlug, `/issues/${issueId}`, protocol);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Generates a Sentry cron monitor URL.
|
|
176
|
+
* @param host The Sentry host (may include regional subdomain for API access)
|
|
177
|
+
* @param organizationSlug Organization identifier
|
|
178
|
+
* @param monitorSlug Monitor slug, optionally prefixed with project slug (e.g. "my-project/my-monitor")
|
|
179
|
+
* @returns The complete monitor URL
|
|
180
|
+
*/
|
|
181
|
+
function getMonitorUrl(host, organizationSlug, monitorSlug, protocol = "https") {
|
|
182
|
+
return getSentryWebBaseUrl(host, organizationSlug, `/crons/${monitorSlug}/`, protocol);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Generates a Sentry release URL.
|
|
186
|
+
* @param host The Sentry host (may include regional subdomain for API access)
|
|
187
|
+
* @param organizationSlug Organization identifier
|
|
188
|
+
* @param releaseVersion Release version identifier
|
|
189
|
+
* @returns The complete release URL
|
|
190
|
+
*/
|
|
191
|
+
function getReleaseUrl(host, organizationSlug, releaseVersion, protocol = "https") {
|
|
192
|
+
return getSentryWebBaseUrl(host, organizationSlug, `/releases/${releaseVersion}/`, protocol);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Generates a Sentry issues search URL.
|
|
196
|
+
* @param host The Sentry host (may include regional subdomain for API access)
|
|
197
|
+
* @param organizationSlug Organization identifier
|
|
198
|
+
* @param query Optional search query
|
|
199
|
+
* @param projectSlugOrId Optional project slug or ID
|
|
200
|
+
* @returns The complete issues search URL
|
|
201
|
+
*/
|
|
202
|
+
function getIssuesSearchUrl(host, organizationSlug, query, projectSlugOrId, protocol = "https") {
|
|
203
|
+
let url = getSentryWebBaseUrl(host, organizationSlug, "/issues/", protocol);
|
|
204
|
+
const params = new URLSearchParams();
|
|
205
|
+
if (projectSlugOrId) params.append("project", projectSlugOrId);
|
|
206
|
+
if (query) params.append("query", query);
|
|
207
|
+
const queryString = params.toString();
|
|
208
|
+
if (queryString) url += `?${queryString}`;
|
|
209
|
+
return url;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Generates a Sentry replay search URL.
|
|
213
|
+
* @param host The Sentry host (may include regional subdomain for API access)
|
|
214
|
+
* @param organizationSlug Organization identifier
|
|
215
|
+
* @param options Replay search options
|
|
216
|
+
* @returns The complete replay search URL
|
|
217
|
+
*/
|
|
218
|
+
function getReplaysSearchUrl(host, organizationSlug, options = {}, protocol = "https") {
|
|
219
|
+
const { query, projectSlugOrId, environment, sort, statsPeriod, start, end } = options;
|
|
220
|
+
let url = getSentryWebBaseUrl(host, organizationSlug, "/explore/replays/", protocol);
|
|
221
|
+
const params = new URLSearchParams();
|
|
222
|
+
if (projectSlugOrId) params.append("project", projectSlugOrId);
|
|
223
|
+
if (query) params.append("query", query);
|
|
224
|
+
if (environment) {
|
|
225
|
+
const environments = Array.isArray(environment) ? environment : [environment];
|
|
226
|
+
for (const value of environments) params.append("environment", value);
|
|
227
|
+
}
|
|
228
|
+
if (sort) params.append("sort", sort);
|
|
229
|
+
if (start && end) {
|
|
230
|
+
params.append("start", start);
|
|
231
|
+
params.append("end", end);
|
|
232
|
+
} else if (statsPeriod) params.append("statsPeriod", statsPeriod);
|
|
233
|
+
const queryString = params.toString();
|
|
234
|
+
if (queryString) url += `?${queryString}`;
|
|
235
|
+
return url;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Generates a Sentry trace URL for performance investigation.
|
|
239
|
+
* @param host The Sentry host (may include regional subdomain for API access)
|
|
240
|
+
* @param organizationSlug Organization identifier
|
|
241
|
+
* @param traceId Trace identifier
|
|
242
|
+
* @returns The complete trace URL
|
|
243
|
+
*/
|
|
244
|
+
function getTraceUrl(host, organizationSlug, traceId, protocol = "https") {
|
|
245
|
+
return getSentryWebBaseUrl(host, organizationSlug, `/explore/traces/trace/${traceId}`, protocol);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Generates a Sentry replay URL.
|
|
249
|
+
* @param host The Sentry host (may include regional subdomain for API access)
|
|
250
|
+
* @param organizationSlug Organization identifier
|
|
251
|
+
* @param replayId Replay identifier
|
|
252
|
+
* @returns The complete replay URL
|
|
253
|
+
*/
|
|
254
|
+
function getReplayUrl(host, organizationSlug, replayId, protocol = "https") {
|
|
255
|
+
return getSentryWebBaseUrl(host, organizationSlug, `/explore/replays/${replayId}/`, protocol);
|
|
256
|
+
}
|
|
257
|
+
function getProfileUrl(host, organizationSlug, projectSlug, profileId, protocol = "https") {
|
|
258
|
+
return getSentryWebBaseUrl(host, organizationSlug, `/explore/profiling/profile/${projectSlug}/${profileId}/flamegraph/`, protocol);
|
|
259
|
+
}
|
|
260
|
+
function getContinuousProfileUrl(host, organizationSlug, projectSlug, options, protocol = "https") {
|
|
261
|
+
const url = new URL(getSentryWebBaseUrl(host, organizationSlug, `/explore/profiling/profile/${projectSlug}/flamegraph/`, protocol));
|
|
262
|
+
url.searchParams.set("profilerId", options.profilerId);
|
|
263
|
+
url.searchParams.set("start", options.start);
|
|
264
|
+
url.searchParams.set("end", options.end);
|
|
265
|
+
return url.toString();
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Internal validation function that checks if a SENTRY_HOST value contains only hostname (no protocol).
|
|
269
|
+
* Throws an error if validation fails instead of exiting the process.
|
|
270
|
+
*
|
|
271
|
+
* @param host The hostname to validate
|
|
272
|
+
* @throws {Error} If the host contains a protocol
|
|
273
|
+
*/
|
|
274
|
+
function _validateSentryHostInternal(host) {
|
|
275
|
+
if (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.");
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Internal validation function that checks if a SENTRY_URL value is a valid HTTPS URL and extracts the hostname.
|
|
279
|
+
* Throws an error if validation fails instead of exiting the process.
|
|
280
|
+
*
|
|
281
|
+
* @param url The HTTPS URL to validate and parse
|
|
282
|
+
* @returns The extracted hostname from the URL
|
|
283
|
+
* @throws {Error} If the URL is invalid or not HTTPS
|
|
284
|
+
*/
|
|
285
|
+
function _validateAndParseSentryUrlInternal(url) {
|
|
286
|
+
if (!url.startsWith("https://")) throw new Error("SENTRY_URL must be a full HTTPS URL (e.g., https://sentry.example.com).");
|
|
287
|
+
try {
|
|
288
|
+
const parsedUrl = new URL(url);
|
|
289
|
+
return parsedUrl.host;
|
|
290
|
+
} catch (error) {
|
|
291
|
+
throw new Error("SENTRY_URL must be a valid HTTPS URL (e.g., https://sentry.example.com).");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Validates that a SENTRY_HOST value contains only hostname (no protocol).
|
|
296
|
+
* Throws an error instead of exiting the process (for testing).
|
|
297
|
+
*
|
|
298
|
+
* @param host The hostname to validate
|
|
299
|
+
* @throws {Error} If the host contains a protocol
|
|
300
|
+
*/
|
|
301
|
+
function validateSentryHostThrows(host) {
|
|
302
|
+
_validateSentryHostInternal(host);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Validates that a SENTRY_URL value is a valid HTTPS URL and extracts the hostname.
|
|
306
|
+
* Throws an error instead of exiting the process (for testing).
|
|
307
|
+
*
|
|
308
|
+
* @param url The HTTPS URL to validate and parse
|
|
309
|
+
* @returns The extracted hostname from the URL
|
|
310
|
+
* @throws {Error} If the URL is invalid or not HTTPS
|
|
311
|
+
*/
|
|
312
|
+
function validateAndParseSentryUrlThrows(url) {
|
|
313
|
+
return _validateAndParseSentryUrlInternal(url);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Validates that the provided OpenAI base URL is a valid HTTP(S) URL and returns a normalized string.
|
|
317
|
+
*
|
|
318
|
+
* @param url The URL to validate and normalize
|
|
319
|
+
* @returns The normalized URL string
|
|
320
|
+
* @throws {Error} If the URL is empty, invalid, or uses an unsupported protocol
|
|
321
|
+
*/
|
|
322
|
+
function validateOpenAiBaseUrlThrows(url) {
|
|
323
|
+
const trimmed = url.trim();
|
|
324
|
+
if (trimmed.length === 0) throw new Error("OPENAI base URL must not be empty.");
|
|
325
|
+
let parsed;
|
|
326
|
+
try {
|
|
327
|
+
parsed = new URL(trimmed);
|
|
328
|
+
} catch (error) {
|
|
329
|
+
throw new Error("OPENAI base URL must be a valid HTTP or HTTPS URL (e.g., https://example.com/v1).", { cause: error });
|
|
330
|
+
}
|
|
331
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") throw new Error("OPENAI base URL must use http or https scheme (e.g., https://example.com/v1).");
|
|
332
|
+
return parsed.toString();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region ../mcp-core/dist/scopes.js
|
|
337
|
+
const SCOPES = {
|
|
338
|
+
"org:read": "Read organization data",
|
|
339
|
+
"project:write": "Write project data",
|
|
340
|
+
"team:write": "Write team data",
|
|
341
|
+
"event:write": "Write event data"
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/auth/constants.ts
|
|
346
|
+
/**
|
|
347
|
+
* Public OAuth app registered on sentry.io for the stdio device code flow.
|
|
348
|
+
* No client secret — device code grant is a public client flow.
|
|
349
|
+
* The Cloudflare transport uses a separate OAuth app with a secret.
|
|
350
|
+
* Override via SENTRY_CLIENT_ID environment variable.
|
|
351
|
+
* See docs/stdio-auth.md for the full credential architecture.
|
|
352
|
+
*/
|
|
353
|
+
const DEFAULT_SENTRY_CLIENT_ID = "0acbeba7d07d58076dd7dbde8cea2fed8ab525ce3713bda604988009ab35d765";
|
|
354
|
+
const DEVICE_CODE_ENDPOINT = "/oauth/device/code/";
|
|
355
|
+
const TOKEN_ENDPOINT = "/oauth/token/";
|
|
356
|
+
const DEVICE_CODE_SCOPES = Object.keys(SCOPES).join(" ");
|
|
357
|
+
/** Interval increment on slow_down response (RFC 8628). */
|
|
358
|
+
const SLOW_DOWN_INCREMENT_SEC = 5;
|
|
359
|
+
/**
|
|
360
|
+
* OAuth endpoints live on sentry.io regardless of regional host.
|
|
361
|
+
* Always use this as the host for device code and token requests.
|
|
362
|
+
*/
|
|
363
|
+
const OAUTH_HOST = "sentry.io";
|
|
364
|
+
|
|
365
|
+
//#endregion
|
|
366
|
+
export { DEFAULT_SENTRY_CLIENT_ID, DEVICE_CODE_ENDPOINT, DEVICE_CODE_SCOPES, OAUTH_HOST, PUBLIC_EVENTS_DATASETS, SLOW_DOWN_INCREMENT_SEC, TOKEN_ENDPOINT, getContinuousProfileUrl, getIssueUrl, getIssuesSearchUrl, getMonitorUrl, getProfileUrl, getProfilingExplorerUrl, getReleaseUrl, getReplayUrl, getReplaysSearchUrl, getTraceMetricsExploreUrl, getTraceUrl, isMetricsDataset, isProfilesDataset, isSentryHost, normalizeEventsDataset, validateAndParseSentryUrlThrows, validateOpenAiBaseUrlThrows, validateSentryHostThrows };
|
|
367
|
+
//# sourceMappingURL=constants-DjY87Pdc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-DjY87Pdc.js","names":[],"sources":["../../mcp-core/dist/events-datasets-Cu37u43g.js","../../mcp-core/dist/url-utils-IhqQI_zS.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-Cu37u43g.js.map","import { isMetricsDataset, isProfilesDataset } from \"./events-datasets-Cu37u43g.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 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\treturn getSentryWebBaseUrl(host, organizationSlug, `/releases/${releaseVersion}/`, 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}\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 { getContinuousProfileUrl, getEventsExplorerUrl, getIssueUrl, getIssuesSearchUrl, getMonitorUrl, getProfileUrl, getProfilingExplorerUrl, getReleaseUrl, getReplayUrl, getReplaysSearchUrl, getTraceMetricsExploreUrl, getTraceUrl, isSentryHost, validateAndParseSentryUrl, validateAndParseSentryUrlThrows, validateOpenAiBaseUrlThrows, validateSentryHost, validateSentryHostThrows };\n//# sourceMappingURL=url-utils-IhqQI_zS.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,QAAO,YAAY,aAAa,YAAY;AAC5C;AACD,SAAS,kBAAkB,SAAS;AACnC,QAAO,YAAY;AACnB;;;;;;;;AAQD,SAAS,uBAAuB,SAAS;AACxC,QAAO,YAAY,YAAY,iBAAiB;AAChD;;;;;;;;;ACfD,SAAS,aAAa,MAAM;AAC3B,QAAO,SAAS,eAAe,KAAK,SAAS,aAAa;AAC1D;AACD,SAAS,qBAAqB,QAAQ,oBAAoB,eAAe;AACxE,KAAI,UAAU,OAAO,SAAS,EAAG,QAAO;AACxC,QAAO,MAAM,KAAK,IAAI,IAAI,CAAC,GAAG,iBAAiB,CAAE,GAAE,GAAG,sBAAsB,CAAE,CAAC,GAAE;AACjF;AACD,SAAS,oBAAoB,MAAM,kBAAkB,MAAM,WAAW,SAAS;CAC9E,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,UAAU,SAAS,cAAc;AACvC,QAAO,YAAY,SAAS,KAAK,iBAAiB,GAAG,UAAU,YAAY,SAAS,KAAK,KAAK,iBAAiB,mBAAmB;AAClI;AACD,SAAS,qBAAqB,QAAQ;AACrC,MAAK,QAAQ,SAAS,OAAO,KAAM,QAAO;AAC1C,QAAO;EACN,MAAM,OAAO;EACb,MAAM,OAAO;EACb,MAAM,OAAO,QAAQ,OAAO,SAAS,MAAM,OAAO,YAAY;CAC9D;AACD;AACD,SAAS,gCAAgC,OAAO;CAC/C,MAAM,QAAQ,MAAM,MAAM,kBAAkB;AAC5C,MAAK,MAAO,QAAO;CACnB,MAAM,OAAO,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,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