PluginPageTools<TOwner>
Class in Oadm.Sdk.Plugins · Oadm.Sdk.dll
Page methods of a core plugin offered as tools (SDK 0.13.0, docs/spec/mcp.md “Plugins”): each entry wraps one method of the plugin’s page with a typed, strict input (the record TArgs; its JSON Schema is the tool’s input), so a caller does on the page what a user does, with the page’s own checks and rights. A change is a preview that runs the page’s validation and never writes, and a run that validates again and calls the page’s code with the caller. A read, or a start the page does without asking (a check, a scan), is one tool. Never a way to call any page method: only the entries declared here are tools.
public sealed class PluginPageTools<TOwner>Type parameters
TOwner: What the handlers work on (the plugin or its service), handed toPluginPageTools<TOwner>.InvokeAsync.
Parameters
json: The serializer options of the arguments and answers; null:PluginTool.CreateJsonOptions.
Keep one instance in a static field of the plugin and hand its PluginPageTools<TOwner>.Tools to ICorePlugin.Tools. In the plugin’s rules (ICorePlugin.RequiredRole, ICorePlugin.RequiredPermission, ICorePlugin.RequiresAllDevices, ICorePlugin.IsAudited) read a tool method as its page method (PluginPageTools<TOwner>.RulesMethodOf), so a tool has exactly the rights of the page; a preview is never audited (PluginTool.IsPreviewMethod).
Constructors
Section titled “Constructors”PluginPageTools
Section titled “PluginPageTools”PluginPageTools(JsonSerializerOptions? json = null)Page methods of a core plugin offered as tools (SDK 0.13.0, docs/spec/mcp.md “Plugins”): each entry wraps one method of the plugin’s page with a typed, strict input (the record TArgs; its JSON Schema is the tool’s input), so a caller does on the page what a user does, with the page’s own checks and rights. A change is a preview that runs the page’s validation and never writes, and a run that validates again and calls the page’s code with the caller. A read, or a start the page does without asking (a check, a scan), is one tool. Never a way to call any page method: only the entries declared here are tools.
Parameters
json: The serializer options of the arguments and answers; null:PluginTool.CreateJsonOptions.
Type parameters
TOwner: What the handlers work on (the plugin or its service), handed toPluginPageTools<TOwner>.InvokeAsync.
Keep one instance in a static field of the plugin and hand its PluginPageTools<TOwner>.Tools to ICorePlugin.Tools. In the plugin’s rules (ICorePlugin.RequiredRole, ICorePlugin.RequiredPermission, ICorePlugin.RequiresAllDevices, ICorePlugin.IsAudited) read a tool method as its page method (PluginPageTools<TOwner>.RulesMethodOf), so a tool has exactly the rights of the page; a preview is never audited (PluginTool.IsPreviewMethod).
Properties
Section titled “Properties”JsonSerializerOptions Json { get; }The serializer options of every tool here.
IReadOnlyList<PluginTool> Tools { get; }The tools, in the order they were added.
Methods
Section titled “Methods”Change
Section titled “Change”PluginPageTools<TOwner> Change<TArgs, TPlan, TResult>(PluginTool tool, string pageMethod, Func<TOwner, ICallContext, PluginToolInput<TArgs>, CancellationToken, Task<TPlan>> check, Func<TOwner, ICallContext, PluginToolInput<TArgs>, TPlan, CancellationToken, Task<TResult>> run)A change: the host offers <name>_preview and <name>_run. The preview calls check, the page’s validation, which answers the plan and never writes. The run calls check again and then run, the page’s code, with the caller and the plan. Let the plan derive from PluginToolPlan so the confirmation card counts what changes.
Parameters
tool: The tool’s name, title (“Delete reader”) and description;PluginTool.Destructivefor a delete.pageMethod: The page method whose rules the tool has (the onerundoes).check: Validates the arguments as the page does and answers what the run will do; never writes. Field errors:PluginToolInputException; another refusal:InvalidOperationExceptionwith the page’s text.run: Does it, as the page does.
Handles
Section titled “Handles”bool Handles(string? method)True when method is a method of a tool here (a read, a preview or a run).
InvokeAsync
Section titled “InvokeAsync”Task<string> InvokeAsync(TOwner owner, ICallContext caller, string method, string? payloadJson, CancellationToken ct)Answers a tool method: reads the arguments (no text reads like {}, broken JSON is refused), checks their validation attributes (a field error per property, in the JSON names), and calls the handler with the caller. Field errors come back as PluginToolErrors.Answer.
PageMethodOf
Section titled “PageMethodOf”string? PageMethodOf(string? method)The page method whose rules a tool method has; null when method is no tool here.
PluginPageTools<TOwner> Read<TArgs, TAnswer>(PluginTool tool, string pageMethod, Func<TOwner, ICallContext, PluginToolInput<TArgs>, CancellationToken, Task<TAnswer>> read)A read, or a start the page does without asking (a check, a read of devices): one tool tool.<name> that calls read with the caller. tool gives name, title and description (and PluginTool.Permission, PluginTool.DeviceFilter, PluginTool.Paged); input and output come from the type arguments.
Parameters
tool: The tool’s name, title and description.pageMethod: The page method whose rules the tool has.read: Answers the call; throwsPluginToolInputExceptionfor an invalid argument,InvalidOperationExceptionwith the page’s text for any other refusal.
RulesMethodOf
Section titled “RulesMethodOf”string RulesMethodOf(string method)The method to apply the plugin’s rules to: the page method of a tool method here, else method itself.
ToolOf
Section titled “ToolOf”PluginTool? ToolOf(string? method)The tool of a method here; null when there is none.