Package dev.relism.flash.ext.mcp
Class McpResource
java.lang.Object
dev.relism.flash.ext.mcp.McpResource
Base class for a single MCP resource — one class per resource, mirroring
McpTool.
Declare metadata with @Resource, cache services in onInit(),
implement read() for the hot path.
@Resource(uri = "config://app-settings", description = "Application settings", mimeType = "application/json")
public class AppSettingsResource extends McpResource {
@Override public ResourceContents read() {
return TextResourceContents.of(uri(), "application/json", settingsJson());
}
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidbind(dev.relism.flash.extension.FlashContext ctx) Called once by the framework after instantiation, before the firstresources/read.protected <T> Optional<T> protected voidonInit()protected <T> Optional<T> abstract ResourceContentsread()Invoked on every matchingresources/readrequest (hot path).protected <T> Tprotected final Stringuri()URI declared via@Resource, cached at bind time.
-
Constructor Details
-
McpResource
public McpResource()
-
-
Method Details
-
bind
public final void bind(dev.relism.flash.extension.FlashContext ctx) Called once by the framework after instantiation, before the firstresources/read. Infrastructure method — do not call from user code. -
onInit
protected void onInit() -
require
-
find
-
optional
-
uri
URI declared via@Resource, cached at bind time. -
read
Invoked on every matchingresources/readrequest (hot path).- Throws:
Exception
-