MCPcopy Create free account
hub / github.com/IBM/mcp-cli / process_request

Method process_request

src/mcp_cli/apps/host.py:320–359  ·  view source on GitHub ↗
(
            connection: ServerConnection, request: Request
        )

Source from the content-addressed store, hash-verified

318
319 # HTTP handler — serves the host page and app HTML
320 def process_request(
321 connection: ServerConnection, request: Request
322 ) -> Response | None:
323 # Strip query string for path matching (?embedded=1 etc.)
324 path = request.path.split("?", 1)[0]
325
326 if path == "/" or path == "":
327 return Response(
328 http.HTTPStatus.OK,
329 "OK",
330 websockets.Headers(
331 {
332 "Content-Type": "text/html; charset=utf-8",
333 "Content-Length": str(len(host_page_bytes)),
334 }
335 ),
336 host_page_bytes,
337 )
338 if path == "/app":
339 return Response(
340 http.HTTPStatus.OK,
341 "OK",
342 websockets.Headers(
343 {
344 "Content-Type": "text/html; charset=utf-8",
345 "Content-Length": str(len(app_html_bytes)),
346 }
347 ),
348 app_html_bytes,
349 )
350 if path != "/ws":
351 body = b"Not Found"
352 return Response(
353 http.HTTPStatus.NOT_FOUND,
354 "Not Found",
355 websockets.Headers({"Content-Length": str(len(body))}),
356 body,
357 )
358 # Return None to proceed with WebSocket upgrade for /ws
359 return None
360
361 # Store the initial tool result on the bridge so it is pushed
362 # only after the app sends ui/notifications/initialized.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected