@@ -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 */
107108const 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
126130const { start, close } = await createPermissionBasedMcpServer ( {
0 commit comments