Package io.modelcontextprotocol.server
Record Class McpServerFeatures.SyncResourceRegistration
java.lang.Object
java.lang.Record
io.modelcontextprotocol.server.McpServerFeatures.SyncResourceRegistration
- Record Components:
resource- The resource definition including name, description, and MIME typereadHandler- The function that handles resource read requests
- Enclosing class:
- McpServerFeatures
@Deprecated
public static record McpServerFeatures.SyncResourceRegistration(McpSchema.Resource resource, Function<McpSchema.ReadResourceRequest,McpSchema.ReadResourceResult> readHandler)
extends Record
Deprecated.
Registration 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
Example resource registration:
new McpServerFeatures.SyncResourceRegistration(
new Resource("docs", "Documentation files", "text/markdown"),
request -> {
String content = readFile(request.getPath());
return new ReadResourceResult(content);
}
)
-
Constructor Summary
ConstructorsConstructorDescriptionSyncResourceRegistration(McpSchema.Resource resource, Function<McpSchema.ReadResourceRequest, McpSchema.ReadResourceResult> readHandler) Deprecated.Creates an instance of aSyncResourceRegistrationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanDeprecated.Indicates whether some other object is "equal to" this one.final inthashCode()Deprecated.Returns a hash code value for this object.Deprecated.Returns the value of thereadHandlerrecord component.resource()Deprecated.Returns the value of theresourcerecord component.Deprecated.final StringtoString()Deprecated.Returns a string representation of this record class.
-
Constructor Details
-
SyncResourceRegistration
public SyncResourceRegistration(McpSchema.Resource resource, Function<McpSchema.ReadResourceRequest, McpSchema.ReadResourceResult> readHandler) Deprecated.Creates an instance of aSyncResourceRegistrationrecord class.- Parameters:
resource- the value for theresourcerecord componentreadHandler- the value for thereadHandlerrecord component
-
-
Method Details
-
toSpecification
Deprecated. -
toString
Deprecated.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()Deprecated.Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Deprecated.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
Deprecated.Returns the value of theresourcerecord component.- Returns:
- the value of the
resourcerecord component
-
readHandler
Deprecated.Returns the value of thereadHandlerrecord component.- Returns:
- the value of the
readHandlerrecord component
-
McpServerFeatures.SyncResourceSpecification.