Skip to content

Initial commit to move to common package#165

Open
adityamittal3107 wants to merge 2 commits into
mainfrom
feat/use-shared-mcp-auth
Open

Initial commit to move to common package#165
adityamittal3107 wants to merge 2 commits into
mainfrom
feat/use-shared-mcp-auth

Conversation

@adityamittal3107

Copy link
Copy Markdown

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the codebase to offload authentication and OAuth handling to the newly introduced @thoughtspot/mcp-auth package, allowing the removal of several local handlers, utility files, and their corresponding tests. The review feedback highlights potential runtime TypeErrors due to type mismatches of clientName (which may be a string from the package but is expected to be an object locally) in both extendProps and enrichMcpRequestProps. Additionally, a defensive check is recommended when accessing the ASSETS binding to prevent crashes in environments where it might be missing.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/index.ts
Comment on lines +85 to +92
const props: Props = {
...base,
clientName: (base.clientName ?? {
clientId: "Bearer Token client",
clientName: "Bearer Token client",
registrationDate: Date.now(),
}) as Props["clientName"],
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The base.clientName property from the package might be a string (as indicated by the type cast and comments on line 128). If it is a string, base.clientName ?? { ... } will evaluate to that string, violating the local Props["clientName"] object structure at runtime. This can cause downstream runtime TypeErrors when properties like clientName.clientId are accessed. We should defensively normalize it to the expected object structure.

Suggested change
const props: Props = {
...base,
clientName: (base.clientName ?? {
clientId: "Bearer Token client",
clientName: "Bearer Token client",
registrationDate: Date.now(),
}) as Props["clientName"],
};
const rawClientName = base.clientName;
const props: Props = {
...base,
clientName: (typeof rawClientName === "object" && rawClientName !== null
? rawClientName
: {
clientId: typeof rawClientName === "string" ? rawClientName : "Bearer Token client",
clientName: typeof rawClientName === "string" ? rawClientName : "Bearer Token client",
registrationDate: Date.now(),
}) as Props["clientName"],
};

Comment thread src/index.ts
Comment on lines +145 to +152
return {
...(baseProps as Props),
apiVersion,
apiRequestedVersion: requestedApiVersion
? normalizeRequestedApiVersionForAnalytics(requestedApiVersion)
: undefined,
apiVersionMode,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to extendProps, baseProps.clientName might be a string at runtime depending on the OAuth provider's payload. Casting baseProps as Props directly without normalizing clientName can lead to runtime TypeErrors when downstream code expects clientName to be an object. Let's defensively normalize it here as well.

const rawClientName = (baseProps as any)?.clientName;
		return {
			...(baseProps as Props),
			clientName: (typeof rawClientName === "object" && rawClientName !== null
				? rawClientName
				: {
						clientId: typeof rawClientName === "string" ? rawClientName : "Bearer Token client",
						clientName: typeof rawClientName === "string" ? rawClientName : "Bearer Token client",
						registrationDate: Date.now(),
				  }) as Props["clientName"],
			apiVersion,
			apiRequestedVersion: requestedApiVersion
				? normalizeRequestedApiVersionForAnalytics(requestedApiVersion)
				: undefined,
			apiVersionMode,
		};

Comment thread src/index.ts
Comment on lines +156 to +158
app.get("/", async (c) => {
return c.env.ASSETS!.fetch("/index.html");
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If the Cloudflare Workers environment is not configured with the ASSETS binding (e.g., during certain local testing setups or alternative deployment targets), accessing c.env.ASSETS!.fetch will throw a runtime TypeError. We should add a defensive check to handle this gracefully.

app.get("/", async (c) => {
			if (!c.env.ASSETS) {
				return c.text("Assets binding is missing", 500);
			}
			return c.env.ASSETS.fetch("/index.html");
		});

@adityamittal3107 adityamittal3107 force-pushed the feat/use-shared-mcp-auth branch from d398462 to 4205ee4 Compare June 25, 2026 06:16
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
aditya-mcp-server 4205ee4 Jun 25 2026, 06:17 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
mcp-server 4205ee4 Jun 25 2026, 06:18 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant