You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug description
When connecting or reconnecting multiple MCP clients, the heap size increases until it reaches the maximum limit. Just to clarify, the MCP server works well when only one client is connected.
Please keep in mind that the MCP server is protected by OAuth 2.0, as defined in the MCP specification [1], and therefore it acts as an OAuth 2.0 resource server [2]. Typically, a short-lived access token is used, making client reconnection a common scenario.
To simplify the test case, I just use the official MCP inspector npm exec @modelcontextprotocol/inspector
Click the reconnect button multiple times. Each time you do, you'll see the heap size increase indefinitely (simulating multiple client connections or reconnections).
You will how the heap is increasing and the the error:
And in Java VisualVM, the heap increases until it reaches the maximum.
Expected behavior
I would like a way to configure or close idle connections, or at least prevent the heap size from increasing, since this is just the reconnection of the MCP client—no operations are being performed.
The text was updated successfully, but these errors were encountered:
embesozzi
changed the title
java.lang.OutOfMemoryError when handling multiple MCP client connections or reconnections
MCP Server java.lang.OutOfMemoryError when handling multiple MCP client connections or reconnections
May 25, 2025
Uh oh!
There was an error while loading. Please reload this page.
Bug description
When connecting or reconnecting multiple MCP clients, the heap size increases until it reaches the maximum limit. Just to clarify, the MCP server works well when only one client is connected.
Please keep in mind that the MCP server is protected by OAuth 2.0, as defined in the MCP specification [1], and therefore it acts as an OAuth 2.0 resource server [2]. Typically, a short-lived access token is used, making client reconnection a common scenario.
[1] https://modelcontextprotocol.io/specification/2025-03-26
[2] https://docs.spring.io/spring-security/reference/servlet/oauth2/resource-server/jwt.html
Environment
Steps to reproduce
npm exec @modelcontextprotocol/inspector
Expected behavior
I would like a way to configure or close idle connections, or at least prevent the heap size from increasing, since this is just the reconnection of the MCP client—no operations are being performed.
The text was updated successfully, but these errors were encountered: