DefaultJsonSchemaValidator: schema cache grows without bound (no TTL or size limit)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- java
- Bereich
- backend, performance
Rechercherichtung
Read DefaultJsonSchemaValidator.java in both the Jackson 2 and Jackson 3 modules, then inspect the existing cache tests and clearCache() behavior. Compare bounded cache policies such as a size limit or TTL and check how each behaves with repeated unique schemas. Done means cache growth is bounded while schema validation continues to work; the issue does not identify specific test files.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
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.
Affected code
mcp-json-jackson2/src/main/java/io/modelcontextprotocol/json/schema/jackson2/DefaultJsonSchemaValidator.javamcp-json-jackson3/src/main/java/io/modelcontextprotocol/json/schema/jackson3/DefaultJsonSchemaValidator.java
// TODO: Implement a strategy to purge the cache (TTL, size limit, etc.)
private final ConcurrentHashMap<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 distinctinputSchema/outputSchemamaps (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.
Related
- #1328 — incorrect cache keys (correctness); this issue is resource / lifecycle
- Dynamic tool APIs:
McpAsyncServer#addTool, etc.
Suggested direction
Content-addressed keys (fixing $id/hash issues) plus a bounded cache policy documented if needed.
- Vorherrschende Sprache
- Java
- Sterne
- 3.8k
- Forks
- 1.1k
- Ø Merge
- 1 T. 3 Std.
- Gemergte PRs (30 T.)
- 38
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/java-sdk
-
Modern `HttpServletMcpTransport` does not check `Mcp-Name` when `params.name` or `params.uri` is not a JSON stringEvtl. vergeben @starryeye hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
modelcontextprotocol/java-sdk#1352 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Unknown tool error always says "Unknown tool: invalid_tool_name" instead of the name that was calledOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
modelcontextprotocol/java-sdk#1346 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
modelcontextprotocol/java-sdk#1345 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Tool result _meta is lost when the server automatically adds text content for structured outputOffenarea/server legacy P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
modelcontextprotocol/java-sdk#1330 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Client request handlers that complete empty send no JSON-RPC responseEvtl. vergeben @1fanwang hat das vor 83 Tagen übernommen. Offenarea/client bug P2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
modelcontextprotocol/java-sdk#1124 · 6 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in modelcontextprotocol/java-sdk
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
crash
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
-
account bug course exam iris lecture
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag