Skip to content

Conversation

terylt
Copy link
Collaborator

@terylt terylt commented Sep 16, 2025

🐞 Bug Summary

Briefly describe the issue or unexpected behavior.

The max retry code was accidentally removed from the external plugin MCP client. However, it also had a small bug, which caused it to error out on MCPGateway startup when an external plugin. The issue was that the final session connection was being done in the context of the initial temporary connection. As a result, the async exit stack which manages the connection was being unravelled in a bad order.


🧩 Affected Component

Select the area of the project impacted:

  • mcpgateway - API
  • mcpgateway - UI (admin panel)
  • mcpgateway.wrapper - stdio wrapper
  • Federation or Transports
  • CLI, Makefiles, or shell scripts
  • Container setup (Docker/Podman/Compose)
  • Other (explain below)

🔁 Steps to Reproduce

  1. Configure an external plugin in the MCP Gateway.
  2. Start up the server with plugins enabled.
  3. The server should immediately crash.

🤔 Expected Behavior

The server should start as expected.


📓 Logs / Error Output

2025-09-15 10:38:08,344 - mcpgateway.services.gateway_service - INFO - Gateway service shutdown complete
2025-09-15 10:38:08,344 - mcpgateway.services.prompt_service - INFO - Prompt service shutdown complete
2025-09-15 10:38:08,345 - mcpgateway.services.resource_service - INFO - Resource service shutdown complete
2025-09-15 10:38:08,345 - mcpgateway.services.tool_service - INFO - Tool service shutdown complete
2025-09-15 10:38:08,345 - mcpgateway.transports.streamablehttp_transport - INFO - Stopping Streamable HTTP Session Manager...
2025-09-15 10:38:08,346 - mcpgateway - INFO - Shutdown complete
2025-09-15 10:38:08,351 - uvicorn.error - ERROR -   + Exception Group Traceback (most recent call last):
  |   File "/Users/t/.venv/mcpgateway/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 "/Users/t/.venv/mcpgateway/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 776, in __aexit__
    |     raise exc_val
    |   File "/Users/t/.venv/mcpgateway/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 744, in __aexit__
    |     await self._on_completed_fut
    | asyncio.exceptions.CancelledError: Cancelled by cancel scope 1302defd0
    | 
    | During handling of the above exception, another exception occurred:
    | 
    | Traceback (most recent call last):
    |   File "/Users/t/.venv/mcpgateway/lib/python3.13/site-packages/mcp/client/streamable_http.py", line 502, in streamablehttp_client
    |     yield (
    |     ...<3 lines>...
    |     )
    |   File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/contextlib.py", line 751, in __aexit__
    |     cb_suppress = await cb(*exc_details)

🧠 Environment Info

You can retrieve most of this from the /version endpoint.

Key Value
Version or commit 0.6.0
Runtime Python 3.13, Gunicorn
Platform / OS macOS
Container none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants