Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/mcp-core/src/utils/url-utils.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { isSentryHost as isSharedSentryHost } from "@sentry/toolkit-core/sentry-host";
import { isSentryHost } from "@sentry/toolkit-core/sentry-host";
import type { SentryProtocol } from "../types";
import {
type EventsDataset,
isMetricsDataset,
isProfilesDataset,
} from "./events-datasets";

/** Keep the MCP utility export for its existing consumers. */
export function isSentryHost(host: string): boolean {
return isSharedSentryHost(host);
}

/** Hosts that use the public SaaS control host and organization web subdomains. */
export function isPublicSentryHost(host: string): boolean {
return isSentryHost(host) && !host.endsWith(".my.sentry.io");
Expand Down
7 changes: 0 additions & 7 deletions packages/mcp-server/src/auth/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SCOPES } from "@sentry/mcp-core/scopes";
import { isSentryHost } from "@sentry/mcp-core/utils/url-utils";

/**
* Public OAuth app registered on sentry.io for the stdio device code flow.
Expand All @@ -15,12 +14,6 @@ export const DEVICE_CODE_ENDPOINT = "/oauth/device/code/";
export const TOKEN_ENDPOINT = "/oauth/token/";
export const DEVICE_CODE_SCOPES = Object.keys(SCOPES).join(" ");

/**
* Whether device code auth is available for this host.
* Supports sentry.io and regional subdomains (us.sentry.io, eu.sentry.io).
*/
export { isSentryHost as isSentryIo };

/**
* OAuth endpoints live on sentry.io regardless of regional host.
* Always use this as the host for device code and token requests.
Expand Down
5 changes: 3 additions & 2 deletions packages/mcp-server/src/auth/resolve-token.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isSentryHost } from "@sentry/toolkit-core/sentry-host";
import type { PartiallyResolvedConfig, ResolvedConfig } from "../cli/types";
import { isSentryIo, OAUTH_HOST } from "./constants";
import { OAUTH_HOST } from "./constants";
import { authenticate } from "./device-code-flow";
import { readCachedToken, writeCachedToken } from "./token-cache";
import { toCachedToken } from "./types";
Expand All @@ -26,7 +27,7 @@ export async function resolveAccessToken(
return withToken(partial, partial.accessToken);
}

if (!isSentryIo(partial.sentryHost)) {
if (!isSentryHost(partial.sentryHost)) {
throw new Error(
"Error: No access token was provided. Device code authentication is only supported for sentry.io.\n" +
"Pass one with `--access-token` or via `SENTRY_ACCESS_TOKEN`.",
Expand Down
9 changes: 3 additions & 6 deletions packages/mcp-server/src/cli/commands/auth.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { isSentryHost } from "@sentry/toolkit-core/sentry-host";
import { parseEnv } from "../parse";
import { resolveHost } from "../resolve";
import {
DEFAULT_SENTRY_CLIENT_ID,
isSentryIo,
OAUTH_HOST,
} from "../../auth/constants";
import { DEFAULT_SENTRY_CLIENT_ID, OAUTH_HOST } from "../../auth/constants";
import { authenticate } from "../../auth/device-code-flow";
import {
readCachedToken,
Expand Down Expand Up @@ -46,7 +43,7 @@ function resolveAuthContext(argv: string[]): AuthContext {
async function login(argv: string[]): Promise<void> {
const { sentryHost, clientId } = resolveAuthContext(argv);

if (!isSentryIo(sentryHost)) {
if (!isSentryHost(sentryHost)) {
console.error(
"Error: Device code authentication is only supported for sentry.io.",
);
Expand Down
2 changes: 1 addition & 1 deletion packages/mcp-server/src/cli/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
parseSkills,
type Skill,
} from "@sentry/mcp-core/skills";
import { isSentryHost } from "@sentry/toolkit-core/sentry-host";
import {
isSentryHost,
validateAndParseSentryUrlThrows,
validateOpenAiBaseUrlThrows,
validateSentryHostThrows,
Expand Down
Loading