Package io.modelcontextprotocol.server
Record Class McpStatelessServerFeatures.SyncResourceSpecification
java.lang.Object
java.lang.Record
io.modelcontextprotocol.server.McpStatelessServerFeatures.SyncResourceSpecification
- Record Components:
resource- The resource definition including name, description, and MIME typereadHandler- The function that handles resource read requests. The function's argument is aMcpSchema.ReadResourceRequest.
- Enclosing class:
- McpStatelessServerFeatures
public static record McpStatelessServerFeatures.SyncResourceSpecification(McpSchema.Resource resource, BiFunction<McpTransportContext,McpSchema.ReadResourceRequest,McpSchema.ReadResourceResult> readHandler)
extends Record
Specification of a resource with its synchronous handler function. Resources
provide context to AI models by exposing data such as:
- File contents
- Database records
- API responses
- System information
- Application state
-
Constructor Summary
ConstructorsConstructorDescriptionSyncResourceSpecification(McpSchema.Resource resource, BiFunction<McpTransportContext, McpSchema.ReadResourceRequest, McpSchema.ReadResourceResult> readHandler) Creates an instance of aSyncResourceSpecificationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thereadHandlerrecord component.resource()Returns the value of theresourcerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SyncResourceSpecification
public SyncResourceSpecification(McpSchema.Resource resource, BiFunction<McpTransportContext, McpSchema.ReadResourceRequest, McpSchema.ReadResourceResult> readHandler) Creates an instance of aSyncResourceSpecificationrecord class.- Parameters:
resource- the value for theresourcerecord componentreadHandler- the value for thereadHandlerrecord component
-
-
Method Details
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
resource
Returns the value of theresourcerecord component.- Returns:
- the value of the
resourcerecord component
-
readHandler
public BiFunction<McpTransportContext,McpSchema.ReadResourceRequest, readHandler()McpSchema.ReadResourceResult> Returns the value of thereadHandlerrecord component.- Returns:
- the value of the
readHandlerrecord component
-