Skip to content

Commit 01fff76

Browse files
committed
Add support for SENTRY_URL (fixes GH-29)
1 parent b4ba00d commit 01fff76

File tree

5 files changed

+5546
-4425
lines changed

5 files changed

+5546
-4425
lines changed

Diff for: README.md

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ It is based on [Cloudflare's work towards remote MCPs](https://blog.cloudflare.c
99

1010
## Getting Started
1111

12+
### Self-Hosted Sentry
13+
14+
You can override the `SENTRY_URL` env variable to set your base Sentry url:
15+
16+
```shell
17+
SENTRY_URL=https://sentry.mycompany.com
18+
```
19+
1220
### MCP Inspector
1321

1422
MCP includes an [Inspector](https://modelcontextprotocol.io/docs/tools/inspector), to easily test the service:

Diff for: src/lib/sentry-api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { z } from "zod";
22
import { logError } from "./logging";
33

4-
const API_BASE_URL = "https://sentry.io/api/0";
4+
const API_BASE_URL = new URL("/api/0", process.env.SENTRY_URL || "https://sentry.io");
55

66
export const SentryOrgSchema = z.object({
77
id: z.string(),

Diff for: src/routes/auth.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { exchangeCodeForAccessToken, getUpstreamAuthorizeUrl } from "../lib/oaut
44
import type { Props } from "../types";
55
import { SentryApiService } from "../lib/sentry-api";
66

7-
export const SENTRY_AUTH_URL = "https://sentry.io/oauth/authorize/";
8-
export const SENTRY_TOKEN_URL = "https://sentry.io/oauth/token/";
7+
export const SENTRY_AUTH_URL = "/oauth/authorize/";
8+
export const SENTRY_TOKEN_URL = "/oauth/token/";
99
// https://docs.sentry.io/api/permissions/
1010
export const SCOPES = "org:read project:read project:write team:read team:write event:read";
1111

@@ -14,6 +14,7 @@ export default new Hono<{
1414
OAUTH_PROVIDER: OAuthHelpers;
1515
SENTRY_CLIENT_ID: string;
1616
SENTRY_CLIENT_SECRET: string;
17+
SENTRY_URL: string;
1718
};
1819
}>()
1920
/**
@@ -34,7 +35,7 @@ export default new Hono<{
3435

3536
return Response.redirect(
3637
getUpstreamAuthorizeUrl({
37-
upstream_url: SENTRY_AUTH_URL,
38+
upstream_url: new URL(SENTRY_AUTH_URL, c.env.SENTRY_URL || "https://sentry.io").href,
3839
scope: SCOPES,
3940
client_id: c.env.SENTRY_CLIENT_ID,
4041
redirect_uri: new URL("/callback", c.req.url).href,
@@ -60,7 +61,7 @@ export default new Hono<{
6061

6162
// Exchange the code for an access token
6263
const [payload, errResponse] = await exchangeCodeForAccessToken({
63-
upstream_url: SENTRY_TOKEN_URL,
64+
upstream_url: new URL(SENTRY_TOKEN_URL, c.env.SENTRY_URL || "https://sentry.io").href,
6465
client_id: c.env.SENTRY_CLIENT_ID,
6566
client_secret: c.env.SENTRY_CLIENT_SECRET,
6667
code: c.req.query("code"),

0 commit comments

Comments
 (0)