@@ -108,6 +108,17 @@ export default function IntegrationList({
108108 setShowEnvConfig ( true ) ;
109109 }
110110 return ;
111+ }
112+
113+ if ( item . key === "Google Gmail MCP" ) {
114+ const mcp = createMcpFromItem ( item , 15 ) ;
115+ if ( isSelectMode ) {
116+ onShowEnvConfig ?.( mcp ) ;
117+ } else {
118+ setActiveMcp ( mcp ) ;
119+ setShowEnvConfig ( true ) ;
120+ }
121+ return ;
111122 }
112123
113124 if ( installed [ item . key ] ) return ;
@@ -199,6 +210,64 @@ export default function IntegrationList({
199210 console . log ( "[IntegrationList onConnect] Polling timeout" ) ;
200211 return ;
201212 }
213+ } else if ( mcp . key === "Google Gmail MCP" ) {
214+ console . log (
215+ "[IntegrationList onConnect] Google Gmail detected, starting auth flow"
216+ ) ;
217+
218+ // Trigger install/authorization
219+ const gmailItem = items . find ( ( item ) => item . key === "Google Gmail MCP" ) ;
220+ try {
221+ if ( gmailItem && gmailItem . onInstall ) {
222+ await gmailItem . onInstall ( ) ;
223+ } else {
224+ await fetchPost ( "/install/tool/google_gmail" ) ;
225+ }
226+ } catch ( _ ) { }
227+
228+ // Select mode: poll OAuth status
229+ if ( isSelectMode ) {
230+ console . log (
231+ "[IntegrationList onConnect] Starting OAuth status polling"
232+ ) ;
233+
234+ const start = Date . now ( ) ;
235+ const timeoutMs = 5 * 60 * 1000 ; // 5 minutes
236+ while ( Date . now ( ) - start < timeoutMs ) {
237+ try {
238+ const statusRes : any = await fetchGet (
239+ "/oauth/status/google_gmail"
240+ ) ;
241+ console . log (
242+ "[IntegrationList onConnect] OAuth status:" ,
243+ statusRes ?. status
244+ ) ;
245+
246+ if ( statusRes ?. status === "success" ) {
247+ console . log (
248+ "[IntegrationList onConnect] Success! Closing dialog"
249+ ) ;
250+ await fetchInstalled ( ) ;
251+ onClose ( ) ;
252+ return ;
253+ }
254+ if (
255+ statusRes ?. status === "failed" ||
256+ statusRes ?. status === "cancelled"
257+ ) {
258+ console . log (
259+ "[IntegrationList onConnect] Failed/cancelled, keeping dialog open"
260+ ) ;
261+ return ;
262+ }
263+ } catch ( err ) {
264+ console . log ( "[IntegrationList onConnect] Polling error:" , err ) ;
265+ }
266+ await new Promise ( ( r ) => setTimeout ( r , 1500 ) ) ;
267+ }
268+ console . log ( "[IntegrationList onConnect] Polling timeout" ) ;
269+ return ;
270+ }
202271 }
203272
204273 // Select mode: add to tools and close
0 commit comments