Skip to content

Instantly share code, notes, and snippets.

@djzager
Created May 28, 2025 20:11
Show Gist options
  • Save djzager/a33b5248f4d796b19aaca04d984016fa to your computer and use it in GitHub Desktop.
Save djzager/a33b5248f4d796b19aaca04d984016fa to your computer and use it in GitHub Desktop.

Here is me trying to run the client:

➜  npx ts-node src/client.ts
(node:14600) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Connecting to server at http://localhost:8000/sse...
Disconnected from MCP server
Error connecting to MCP server: Error: SSE error: TypeError: terminated: other side closed

Uh-oh, that's no good, check the port-forward to see if the server crashed:

➜  kubectl port-forward -n konveyor-kai-solution-server service/kai-mcp-solution-server 8000:8000
Forwarding from 127.0.0.1:8000 -> 8000
Forwarding from [::1]:8000 -> 8000
Handling connection for 8000

Well it didn't die, so poke it again:

➜  npx ts-node src/client.ts
(node:14600) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Connecting to server at http://localhost:8000/sse...
Disconnected from MCP server
Error connecting to MCP server: Error: SSE error: TypeError: terminated: other side closed

Hmmm:

➜  kubectl port-forward -n konveyor-kai-solution-server service/kai-mcp-solution-server 8000:8000
Forwarding from 127.0.0.1:8000 -> 8000
Forwarding from [::1]:8000 -> 8000
Handling connection for 8000



Handling connection for 8000
E0528 16:05:30.351379   14577 portforward.go:424] "Unhandled Error" err=<
        an error occurred forwarding 8000 -> 8000: error forwarding port 8000 to pod c7bbb046968d34a41a6b7e23205adc9f34ef8d6ad47b9bd647346b18e5a3d551, uid : exit status 1: 2025/05/28 20:05:30 socat[196152] E connect(5, AF=2 127.0.0.1:8000, 16): Connection refused
 >
error: lost connection to pod

Now it's dead, let us check the logs:

➜  k logs -n konveyor-kai-solution-server pod/kai-mcp-solution-server-5895cbd4f-vvr5t -f
INFO:     Started server process [1]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
Starting MCP Solution Server with sse transport
Listening on 0.0.0.0:8000
INFO:     127.0.0.1:54896 - "GET /sse HTTP/1.1" 200 OK
ERROR:    Exception in ASGI application
  + Exception Group Traceback (most recent call last):
  |   File "/usr/local/lib/python3.13/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
  |     result = await app(  # type: ignore[func-returns-value]
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |         self.scope, self.receive, self.send
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |     )
  |     ^
  |   File "/usr/local/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
  |     return await self.app(scope, receive, send)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/local/lib/python3.13/site-packages/starlette/applications.py", line 112, in __call__
  |     await self.middleware_stack(scope, receive, send)
  |   File "/usr/local/lib/python3.13/site-packages/starlette/middleware/errors.py", line 187, in __call__
  |     raise exc
  |   File "/usr/local/lib/python3.13/site-packages/starlette/middleware/errors.py", line 165, in __call__
  |     await self.app(scope, receive, _send)
  |   File "/usr/local/lib/python3.13/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
  |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  |   File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
  |     raise exc
  |   File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
  |     await app(scope, receive, sender)
  |   File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 714, in __call__
  |     await self.middleware_stack(scope, receive, send)
  |   File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 734, in app
  |     await route.handle(scope, receive, send)
  |   File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 288, in handle
  |     await self.app(scope, receive, send)
  |   File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 76, in app
  |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  |   File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
  |     raise exc
  |   File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
  |     await app(scope, receive, sender)
  |   File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 73, in app
  |     response = await f(request)
  |                ^^^^^^^^^^^^^^^^
  |   File "/usr/local/lib/python3.13/site-packages/mcp/server/fastmcp/server.py", line 745, in sse_endpoint
  |     return await handle_sse(request.scope, request.receive, request._send)  # type: ignore[reportPrivateUsage]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/usr/local/lib/python3.13/site-packages/mcp/server/fastmcp/server.py", line 678, in handle_sse
  |     async with sse.connect_sse(
  |                ~~~~~~~~~~~~~~~^
  |         scope,
  |         ^^^^^^
  |         receive,
  |         ^^^^^^^^
  |         send,
  |         ^^^^^
  |     ) as streams:
  |     ^
  |   File "/usr/local/lib/python3.13/contextlib.py", line 235, in __aexit__
  |     await self.gen.athrow(value)
  |   File "/usr/local/lib/python3.13/site-packages/mcp/server/sse.py", line 146, in connect_sse
  |     async with anyio.create_task_group() as tg:
  |                ~~~~~~~~~~~~~~~~~~~~~~~^^
  |   File "/usr/local/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
  |     raise BaseExceptionGroup(
  |         "unhandled errors in a TaskGroup", self._exceptions
  |     ) from None
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/usr/local/lib/python3.13/site-packages/mcp/server/sse.py", line 165, in connect_sse
    |     yield (read_stream, write_stream)
    |   File "/usr/local/lib/python3.13/site-packages/mcp/server/fastmcp/server.py", line 683, in handle_sse
    |     await self._mcp_server.run(
    |     ...<3 lines>...
    |     )
    |   File "/usr/local/lib/python3.13/site-packages/mcp/server/lowlevel/server.py", line 496, in run
    |     lifespan_context = await stack.enter_async_context(self.lifespan(self))
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/usr/local/lib/python3.13/contextlib.py", line 668, in enter_async_context
    |     result = await _enter(cm)
    |              ^^^^^^^^^^^^^^^^
    |   File "/usr/local/lib/python3.13/contextlib.py", line 214, in __aenter__
    |     return await anext(self.gen)
    |            ^^^^^^^^^^^^^^^^^^^^^
    |   File "/usr/local/lib/python3.13/site-packages/mcp/server/fastmcp/server.py", line 130, in wrap
    |     async with lifespan(app) as context:
    |                ~~~~~~~~^^^^^
    |   File "/usr/local/lib/python3.13/contextlib.py", line 214, in __aenter__
    |     return await anext(self.gen)
    |            ^^^^^^^^^^^^^^^^^^^^^
    |   File "/app/main.py", line 18, in lifespan
    |     conn_pool.initialize()
    |     ~~~~~~~~~~~~~~~~~~~~^^
    |   File "/app/kai_solutions_dao.py", line 50, in initialize
    |     self.connection = sqlite3.connect(db_path)
    |                       ~~~~~~~~~~~~~~~^^^^^^^^^
    | sqlite3.OperationalError: unable to open database file
    +------------------------------------
INFO:     Shutting down
INFO:     Waiting for application shutdown.
INFO:     Application shutdown complete.
INFO:     Finished server process [1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment