Record Class SyncResourceRegistration

java.lang.Object
java.lang.Record
org.springframework.ai.mcp.modern.SyncResourceRegistration
Record Components:
resource - the definition returned by resources/list
handler - the handler for resources/read of resource.uri()

public record SyncResourceRegistration(io.modelcontextprotocol.modern.McpSchema.Resource resource, io.modelcontextprotocol.modern.server.feature.McpSyncResource handler) extends Record
A listed resource together with the McpSyncResource that reads it. The SDK's McpSyncResource carries no definition, because resources/read also serves URIs that only match a template; a catalogue of static resources needs the pairing.
Since:
2.1.0
Author:
Christian Tzolov
  • Constructor Summary

    Constructors
    Constructor
    Description
    SyncResourceRegistration(io.modelcontextprotocol.modern.McpSchema.Resource resource, io.modelcontextprotocol.modern.server.feature.McpSyncResource handler)
    Creates an instance of a SyncResourceRegistration record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    io.modelcontextprotocol.modern.server.feature.McpSyncResource
    Returns the value of the handler record component.
    final int
    Returns a hash code value for this object.
    of(io.modelcontextprotocol.modern.McpSchema.Resource resource, io.modelcontextprotocol.modern.McpSchema.ClientCapabilities requiredCapabilities, io.modelcontextprotocol.modern.server.feature.McpSyncResource.Handler handler)
    Pairs a resource with a handler that only works with clients declaring requiredCapabilities.
    of(io.modelcontextprotocol.modern.McpSchema.Resource resource, io.modelcontextprotocol.modern.server.feature.McpSyncResource.Handler handler)
    Pairs a resource with a handler that requires no client capabilities.
    io.modelcontextprotocol.modern.McpSchema.Resource
    Returns the value of the resource record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SyncResourceRegistration

      public SyncResourceRegistration(io.modelcontextprotocol.modern.McpSchema.Resource resource, io.modelcontextprotocol.modern.server.feature.McpSyncResource handler)
      Creates an instance of a SyncResourceRegistration record class.
      Parameters:
      resource - the value for the resource record component
      handler - the value for the handler record component
  • Method Details

    • of

      public static SyncResourceRegistration of(io.modelcontextprotocol.modern.McpSchema.Resource resource, io.modelcontextprotocol.modern.server.feature.McpSyncResource.Handler handler)
      Pairs a resource with a handler that requires no client capabilities.
      Since:
      2.1.0
    • of

      public static SyncResourceRegistration of(io.modelcontextprotocol.modern.McpSchema.Resource resource, io.modelcontextprotocol.modern.McpSchema.ClientCapabilities requiredCapabilities, io.modelcontextprotocol.modern.server.feature.McpSyncResource.Handler handler)
      Pairs a resource with a handler that only works with clients declaring requiredCapabilities. A read from any other client is rejected with -32021 without running the handler.
      Since:
      2.1.0
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • resource

      public io.modelcontextprotocol.modern.McpSchema.Resource resource()
      Returns the value of the resource record component.
      Returns:
      the value of the resource record component
    • handler

      public io.modelcontextprotocol.modern.server.feature.McpSyncResource handler()
      Returns the value of the handler record component.
      Returns:
      the value of the handler record component