@@ -30,6 +30,7 @@ def __init__(
3030 port : int = 3000 ,
3131 timeout_keep_alive : int = 600 ,
3232 timeout_graceful_shutdown : int = 120 ,
33+ config = None ,
3334 ):
3435 """
3536 Initialize the HTTP transport.
@@ -39,11 +40,13 @@ def __init__(
3940 port: Port number to listen on
4041 timeout_keep_alive: Keep-alive timeout in seconds (default: 600 for LLM connections)
4142 timeout_graceful_shutdown: Graceful shutdown timeout in seconds (default: 120)
43+ config: Optional configuration object for security manager
4244 """
4345 self .host = host
4446 self .port = port
4547 self .timeout_keep_alive = timeout_keep_alive
4648 self .timeout_graceful_shutdown = timeout_graceful_shutdown
49+ self .config = config
4750 self .logger = get_logger (f"{ __name__ } .HttpTransport" )
4851 self ._session_manager = None
4952 self ._server = None
@@ -174,6 +177,50 @@ async def wrapped_handle_request(scope, receive, send):
174177 session_manager .handle_request = wrapped_handle_request
175178 return session_manager
176179
180+ def _create_health_endpoints (self ):
181+ """Create ASGI app for health check and security endpoints."""
182+ from starlette .applications import Starlette
183+ from starlette .responses import JSONResponse
184+ from starlette .routing import Route
185+ from utils .security import KonfluxDevLakeSecurityManager
186+
187+ # Create a minimal config object if not provided
188+ if self .config is None :
189+
190+ class MinimalConfig :
191+ allowed_ips = []
192+ api_keys = {}
193+
194+ config = MinimalConfig ()
195+ else :
196+ config = self .config
197+
198+ security_manager = KonfluxDevLakeSecurityManager (config )
199+
200+ async def health_check (request ):
201+ """Health check endpoint."""
202+ return JSONResponse (
203+ {
204+ "status" : "healthy" ,
205+ "service" : "konflux-devlake-mcp-server" ,
206+ "transport" : "http" ,
207+ }
208+ )
209+
210+ async def security_stats (request ):
211+ """Security statistics endpoint."""
212+ stats = security_manager .get_security_stats ()
213+ return JSONResponse (stats )
214+
215+ app = Starlette (
216+ routes = [
217+ Route ("/health" , health_check , methods = ["GET" ]),
218+ Route ("/security/stats" , security_stats , methods = ["GET" ]),
219+ ]
220+ )
221+
222+ return app
223+
177224 def _create_mcp_app (self , app ):
178225 """Create ASGI app that handles MCP requests with improved error handling."""
179226 from starlette .responses import Response
0 commit comments