Skip to content

Commit f9e16f4

Browse files
committed
feat: permission server smoke tests
1 parent b59b29f commit f9e16f4

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/permissions/PermissionResolver.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ export class PermissionResolver {
146146
);
147147
return null;
148148
} catch (error) {
149+
// Log message only, not full stack trace (this is expected fallback behavior)
150+
const message = error instanceof Error ? error.message : String(error);
149151
console.warn(
150-
`Permission resolver failed for client ${clientId}:`,
151-
error
152+
`Permission resolver declined client ${clientId} (${message}), trying fallback`
152153
);
153154
return null;
154155
}

tests/smoke-e2e/permission-config-server-demo.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,32 @@ const staticPermissionMap: Record<string, string[]> = {
9999

100100
/**
101101
* Resolver function for dynamic permission logic.
102-
* This is called when a client is not found in the static map.
102+
* This is called FIRST, before checking the static map.
103+
* Return a valid array to use those permissions, or throw an error to fall back to static map.
103104
*
104105
* @param clientId - The client identifier
105-
* @returns Array of allowed toolset names
106+
* @returns Array of allowed toolset names, or throws to trigger fallback
106107
*/
107108
const permissionResolver = (clientId: string): string[] => {
108109
console.log(`Resolver called for client: ${clientId}`);
109110

110111
// Example: Grant permissions based on client ID patterns
111112
if (clientId.startsWith("admin-")) {
113+
console.log(`Matched admin-* pattern`);
112114
return ["admin", "user", "analytics"];
113115
}
114116
if (clientId.startsWith("analyst-")) {
117+
console.log(`Matched analyst-* pattern`);
115118
return ["user", "analytics"];
116119
}
117120
if (clientId.startsWith("user-")) {
121+
console.log(`Matched user-* pattern`);
118122
return ["user"];
119123
}
120124

121-
// Unknown pattern - will fall back to default permissions
122-
console.log(`No pattern match for ${clientId}, using default permissions`);
123-
return [];
125+
// No pattern match - throw error to fall back to static map or default permissions
126+
console.log(`No pattern match for ${clientId}, falling back to static map`);
127+
throw new Error(`No resolver pattern match for ${clientId}`);
124128
};
125129

126130
const { start, close } = await createPermissionBasedMcpServer({

0 commit comments

Comments
 (0)