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
{{ message }}
Repository navigation
DefaultJsonSchemaValidator: schema cache grows without bound (no TTL or size limit) #1344
DefaultJsonSchemaValidator keeps compiled NetworkNT Schema instances in a ConcurrentHashMap forever. There is an explicit TODO to add eviction; nothing purges entries on tool/schema updates or long-running servers.
// TODO: Implement a strategy to purge the cache (TTL, size limit, etc.)privatefinalConcurrentHashMap<String, Schema> schemaCache;
clearCache() exists for tests but is not wired into server lifecycle or dynamic tool registration.
Steps to reproduce
Run a server that repeatedly addTool / updates tools with distinct inputSchema / outputSchema maps (or stress-test the validator in a loop with unique schemas).
Monitor heap or call getCacheSize() on a test instance.
Observe cache size monotonically increases; entries are never removed.
Expected behavior
Bounded memory for schema compilation cache, for example:
max entries + LRU, and/or
TTL, and/or
invalidation when tools/schemas are removed or replaced
Actual behavior
Every distinct cache key retains a compiled Schema for the JVM lifetime.
Impact
Long-lived MCP servers with dynamic tool catalogs or many unique schemas may accumulate unbounded native/heap pressure over days or weeks.
Activity
coder-jeffery commentedon Nov 18, 2026
hi, I’m very interested in the MCP Java SDK; may I fix this issue?