@digestseo/mcp-gsc 0.3.1 → 0.4.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.
@@ -0,0 +1,39 @@
1
+ import authenticatedWorker, { mcpApiHandler, type Env } from './index';
2
+
3
+ export { GscMcpAgent, PendingAuthState, ToolRateLimiter } from './index';
4
+
5
+ type EntrypointEnv = Env & {
6
+ GLAMA_INSPECTION_MODE?: string;
7
+ };
8
+
9
+ type WorkerHandler = {
10
+ fetch(
11
+ request: Request,
12
+ env: EntrypointEnv,
13
+ ctx: ExecutionContext,
14
+ ): Response | Promise<Response>;
15
+ };
16
+
17
+ const inspectionWorker = mcpApiHandler as WorkerHandler;
18
+
19
+ const oauthWorker = authenticatedWorker as unknown as WorkerHandler;
20
+
21
+ /**
22
+ * Glama's release builder cannot complete an interactive OAuth flow, but it
23
+ * needs to initialize the MCP endpoint and call tools/list for static
24
+ * inspection. The bypass is deliberately opt-in, exact-value gated, and
25
+ * limited to /mcp. Tool handlers still have no authenticated agent props, so
26
+ * data-bearing calls fail closed.
27
+ */
28
+ export default {
29
+ fetch(request: Request, env: EntrypointEnv, ctx: ExecutionContext) {
30
+ const inspectionEnabled = env.GLAMA_INSPECTION_MODE === 'true';
31
+ const isMcpEndpoint = new URL(request.url).pathname === '/mcp';
32
+
33
+ if (inspectionEnabled && isMcpEndpoint) {
34
+ return inspectionWorker.fetch(request, env, ctx);
35
+ }
36
+
37
+ return oauthWorker.fetch(request, env, ctx);
38
+ },
39
+ };