Package org.apache.juneau.examples.mcp
Class NoteStore
java.lang.Object
org.apache.juneau.examples.mcp.NoteStore
The example's entire "domain": a tiny in-memory map of note title → note body.
Every MCP surface the ExampleMcpServer exposes (tools, prompt, resources, resource
template, completions) is just a thin wrapper over this one object, so a reader can see the
whole scenario at a glance without wading through business logic. It is deliberately trivial;
the interesting part is the MCP wiring, not the storage.
Access is synchronized because subscription/tool handlers can run on different threads
(the held-open SSE pump, concurrent HTTP requests). A LinkedHashMap keeps listing
order stable so the demo output is deterministic.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
SCHEME
URI scheme used to address a single note, e.g.note:///groceries.- See Also:
-
-
Constructor Details
-
NoteStore
public NoteStore()
-
-
Method Details
-
put
Stores (or replaces) a note.- Parameters:
title- The note title (its key). Must not benull .body- The note body. Must not benull .
-
get
Returns the body of a note.- Parameters:
title- The note title. Can benull .- Returns:
- The body, or
null if no such note exists.
-
remove
Removes a note.- Parameters:
title- The note title. Can benull .- Returns:
true if a note was actually removed.
-
titles
Returns a snapshot of all note titles, in insertion order.- Returns:
- An immutable, point-in-time copy of the titles. Never
null .
-
uriFor
Builds the canonical resource URI for a note title (e.g.note:///groceries).- Parameters:
title- The note title.- Returns:
- The resource URI.
-