Class NoteStore

java.lang.Object
org.apache.juneau.examples.mcp.NoteStore

public final class NoteStore extends Object
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 Details

  • Constructor Details

  • Method Details

    • put

      public void put(String title, String body)
      Stores (or replaces) a note.
      Parameters:
      title - The note title (its key). Must not be null.
      body - The note body. Must not be null.
    • get

      public String get(String title)
      Returns the body of a note.
      Parameters:
      title - The note title. Can be null.
      Returns:
      The body, or null if no such note exists.
    • remove

      public boolean remove(String title)
      Removes a note.
      Parameters:
      title - The note title. Can be null.
      Returns:
      true if a note was actually removed.
    • titles

      public List<String> titles()
      Returns a snapshot of all note titles, in insertion order.
      Returns:
      An immutable, point-in-time copy of the titles. Never null.
    • uriFor

      public static String uriFor(String title)
      Builds the canonical resource URI for a note title (e.g. note:///groceries).
      Parameters:
      title - The note title.
      Returns:
      The resource URI.