@@ -252,17 +252,17 @@ export function initTools(server: McpServer) {
252252 name : z . string ( ) . nullable ( ) . optional ( ) ,
253253 } )
254254
255- const timeout = setTimeout ( ( ) => {
256- void server . server
257- . notification ( {
258- method : 'notifications/message' ,
259- params : {
260- level : 'warning' ,
261- data : 'Device authorization timed out' ,
262- } ,
263- } )
264- . catch ( ( ) => { } )
265- } , deviceResponse . expires_in * 1000 )
255+ const timeout = setTimeout ( ( ) => {
256+ void server . server
257+ . notification ( {
258+ method : 'notifications/message' ,
259+ params : {
260+ level : 'warning' ,
261+ data : 'Device authorization timed out' ,
262+ } ,
263+ } )
264+ . catch ( ( ) => { } )
265+ } , deviceResponse . expires_in * 1000 )
266266
267267 try {
268268 const tokenSet = await client . pollDeviceAuthorizationGrant (
@@ -271,16 +271,16 @@ export function initTools(server: McpServer) {
271271 )
272272 clearTimeout ( timeout )
273273
274- if ( ! tokenSet ) {
275- await server . server . notification ( {
276- method : 'notifications/message' ,
277- params : {
278- level : 'error' ,
279- data : 'No token set' ,
280- } ,
281- } )
282- return
283- }
274+ if ( ! tokenSet ) {
275+ await server . server . notification ( {
276+ method : 'notifications/message' ,
277+ params : {
278+ level : 'error' ,
279+ data : 'No token set' ,
280+ } ,
281+ } )
282+ return
283+ }
284284
285285 const protectedResourceResponse = await client . fetchProtectedResource (
286286 config ,
@@ -289,17 +289,17 @@ export function initTools(server: McpServer) {
289289 'GET' ,
290290 )
291291 const userinfoRaw = await protectedResourceResponse . json ( )
292- const userinfoResult = UserInfoSchema . safeParse ( userinfoRaw )
293- if ( ! userinfoResult . success ) {
294- await server . server . notification ( {
295- method : 'notifications/message' ,
296- params : {
297- level : 'error' ,
298- data : `Failed to parse user info: ${ userinfoResult . error . message } ` ,
299- } ,
300- } )
301- return
302- }
292+ const userinfoResult = UserInfoSchema . safeParse ( userinfoRaw )
293+ if ( ! userinfoResult . success ) {
294+ await server . server . notification ( {
295+ method : 'notifications/message' ,
296+ params : {
297+ level : 'error' ,
298+ data : `Failed to parse user info: ${ userinfoResult . error . message } ` ,
299+ } ,
300+ } )
301+ return
302+ }
303303 const userinfo = userinfoResult . data
304304
305305 await setAuthInfo ( {
@@ -309,16 +309,16 @@ export function initTools(server: McpServer) {
309309 name : userinfo . name ,
310310 } )
311311
312- await getUserInfo ( { forceFresh : true } )
312+ await getUserInfo ( { forceFresh : true } )
313313
314- await server . server . notification ( {
315- method : 'notifications/message' ,
316- params : {
317- level : 'info' ,
318- data : 'Authentication successful' ,
319- } ,
320- } )
321- } catch ( error ) {
314+ await server . server . notification ( {
315+ method : 'notifications/message' ,
316+ params : {
317+ level : 'info' ,
318+ data : 'Authentication successful' ,
319+ } ,
320+ } )
321+ } catch ( error ) {
322322 clearTimeout ( timeout )
323323 throw error
324324 }
0 commit comments