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