@@ -19,6 +19,7 @@ import { createTitleRoutes } from './routes/title'
1919import { createSSERoutes } from './routes/sse'
2020import { createSSHRoutes } from './routes/ssh'
2121import { createNotificationRoutes } from './routes/notifications'
22+ import { createMcpOauthProxyRoutes } from './routes/mcp-oauth-proxy'
2223import { createAuthRoutes , createAuthInfoRoutes , syncAdminFromEnv } from './routes/auth'
2324import { createAuth } from './auth'
2425import { createAuthMiddleware } from './auth/middleware'
@@ -27,7 +28,7 @@ import { ensureDirectoryExists, writeFileContent, fileExists, readFileContent }
2728import { SettingsService } from './services/settings'
2829import { opencodeServerManager } from './services/opencode-single-server'
2930import { cleanupOrphanedDirectories } from './services/repo'
30- import { proxyRequest } from './services/proxy'
31+ import { proxyRequest , proxyMcpAuthStart , proxyMcpAuthAuthenticate } from './services/proxy'
3132import { NotificationService } from './services/notification'
3233import { logger } from './utils/logger'
3334import {
@@ -229,6 +230,7 @@ app.route('/api/auth', createAuthRoutes(auth))
229230app . route ( '/api/auth-info' , createAuthInfoRoutes ( auth , db ) )
230231
231232app . route ( '/api/health' , createHealthRoutes ( db ) )
233+ app . route ( '/api/mcp-oauth-proxy' , createMcpOauthProxyRoutes ( requireAuth ) )
232234
233235const protectedApi = new Hono ( )
234236protectedApi . use ( '/*' , requireAuth )
@@ -247,6 +249,18 @@ protectedApi.route('/notifications', createNotificationRoutes(notificationServic
247249
248250app . route ( '/api' , protectedApi )
249251
252+ app . post ( '/api/opencode/mcp/:name/auth' , requireAuth , async ( c ) => {
253+ const serverName = c . req . param ( 'name' )
254+ const directory = c . req . query ( 'directory' )
255+ return proxyMcpAuthStart ( serverName , directory )
256+ } )
257+
258+ app . post ( '/api/opencode/mcp/:name/auth/authenticate' , requireAuth , async ( c ) => {
259+ const serverName = c . req . param ( 'name' )
260+ const directory = c . req . query ( 'directory' )
261+ return proxyMcpAuthAuthenticate ( serverName , directory )
262+ } )
263+
250264app . all ( '/api/opencode/*' , requireAuth , async ( c ) => {
251265 const request = c . req . raw
252266 return proxyRequest ( request )
0 commit comments