Skip to content

Commit d501b2b

Browse files
feat(MK8S-196): always inject userData+getToken into context, drop authRequired
1 parent 0a6377d commit d501b2b

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

shell-ui/src/auth/AuthProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function defaultDexConnectorMetadataService(connectorId: string) {
5353
return DexDefaultConnectorMetadataService;
5454
}
5555

56-
export function getAbsoluteRedirectUrl(redirectUrl?: string) {
56+
function getAbsoluteRedirectUrl(redirectUrl?: string) {
5757
if (!redirectUrl) {
5858
return window.location.href;
5959
}

shell-ui/src/mcp/MCPRegistrar.tsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const _InternalMCPRegistrar = ({
2222
mcpToolsModuleInfo: FederatedModuleInfo;
2323
selfConfiguration: Record<string, unknown>;
2424
}) => {
25-
const { getToken } = useAuth();
25+
const { getToken, userData } = useAuth();
2626

2727
useEffect(() => {
2828
if (!navigator.modelContext) return;
@@ -36,22 +36,9 @@ export const _InternalMCPRegistrar = ({
3636
description: tool.description,
3737
inputSchema: tool.inputSchema,
3838
execute: async (params: unknown, client: ModelContextClient) => {
39-
if (tool.authRequired) {
40-
const token = await getToken();
41-
if (!token) {
42-
return {
43-
success: false,
44-
error: {
45-
code: 'AUTH_REQUIRED',
46-
message:
47-
'You must log in to the browser window prior to performing this action.',
48-
},
49-
};
50-
}
51-
}
52-
5339
const context: ToolContext = {
5440
getToken,
41+
userData,
5542
selfConfiguration,
5643
};
5744

@@ -70,7 +57,7 @@ export const _InternalMCPRegistrar = ({
7057
navigator.modelContext?.unregisterTool?.(name),
7158
);
7259
};
73-
}, [moduleExports, mcpToolsModuleInfo, getToken, selfConfiguration]);
60+
}, [moduleExports, mcpToolsModuleInfo, getToken, userData, selfConfiguration]);
7461

7562
return null;
7663
};

shell-ui/src/mcp/types.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,23 @@
55
* app-specific context derived from selfConfiguration.
66
*/
77

8+
export type UserData = {
9+
token: string;
10+
username: string;
11+
groups: string[];
12+
email: string;
13+
id: string;
14+
};
15+
816
export type ToolContext = {
917
/**
1018
* Always returns the latest token — safe to call multiple times during
1119
* long-running tool executions where the token may be silently renewed
1220
* by oidc-client-ts in the background.
1321
*/
14-
getToken: () => Promise<string>;
22+
getToken: () => Promise<string | null>;
23+
/** Authenticated user information. Undefined if the user is not logged in. */
24+
userData: UserData | undefined;
1525
/**
1626
* Raw selfConfiguration from the app's runtime WebFinger.
1727
* Micro-frontends cast this to their own known config shape to extract endpoints etc.
@@ -43,8 +53,6 @@ export type MCPToolDefinition<
4353
description: string;
4454
/** JSON Schema Draft 7 object describing the tool's input parameters (excluding context) */
4555
inputSchema: Record<string, unknown>;
46-
/** When true, shell-ui will resolve a token and inject ToolContext before calling execute() */
47-
authRequired: boolean;
4856
execute: (
4957
params: TParams & { context: ToolContext },
5058
client: ModelContextClient,

0 commit comments

Comments
 (0)