PluginTool
Record in Oadm.Sdk.Plugins · Oadm.Sdk.dll
One tool of a core plugin (SDK 0.13.0, ICorePlugin.Tools): a step a program, such as an assistant, may take in the plugin without its page, described once so that a caller can read what it takes and what it answers. The tool knows nothing of the channel that calls it; the host lists it only while the plugin is on and the caller’s role has its permission, checks the arguments against the input schema, and calls the plugin’s own ICorePlugin.InvokeAsync with the caller (the methods PluginTool.Method, PluginTool.PreviewMethod and PluginTool.RunMethod), so every rule of the plugin’s page applies.
public sealed record PluginTool(string Name, string Title, string Description)Parameters
Name: What the tool does, in lower case words with underscores (“certificates”, “certificate_create”); the host adds the plugin’s area in front.Title: The name for a person (“Certificate list”).Description: One to three short sentences: what the tool does and when to call it. Never a text of a device or a user.
Properties
Section titled “Properties”string? Area { get; init; }The area of this tool’s name instead of the plugin’s ICorePlugin.ToolArea, lower case words with underscores: VAPIX Commander’s request tool is oadm_device_request. Null: the plugin’s area. A name a host tool has is never taken over.
Changes
Section titled “Changes”bool Changes { get; init; }The tool changes something: the host makes two tools of it, <name>_preview (calls PluginTool.PreviewMethod, which checks everything and never writes) and <name>_run (takes only the handle of a preview and calls PluginTool.RunMethod, which checks everything again).
Description
Section titled “Description”string Description { get; init; }One to three short sentences: what the tool does and when to call it. Never a text of a device or a user.
Destructive
Section titled “Destructive”bool Destructive { get; init; }A change that removes something or cannot be taken back (an honest hint for the caller).
DeviceFilter
Section titled “DeviceFilter”bool DeviceFilter { get; init; }The tool works on devices the caller chooses: the host adds filter (the device filter of the host’s device tools, with the assistant’s selection) to the input, finds the matching devices of the caller’s view (at most PluginTool.MaxDevices, by address) and hands the plugin device_ids and devices_total instead of the filter (read them with PluginToolDevices.Of). The input type has no property of these names.
Idempotent
Section titled “Idempotent”bool? Idempotent { get; init; }Calling again with the same arguments changes nothing more; default true for a read, false for a change.
InputSchema
Section titled “InputSchema”string? InputSchema { get; init; }The input as JSON Schema text instead of PluginTool.InputType: an object with additionalProperties: false.
InputType
Section titled “InputType”Type? InputType { get; init; }The record of the arguments. The host exports its JSON Schema with the plugin’s PluginTool.JsonOptions (descriptions and validation attributes become the schema’s words; objects take no other properties; text, number and list have a bound). Null together with PluginTool.InputSchema: the tool takes no argument. A type with a secret property is never offered.
JsonOptions
Section titled “JsonOptions”JsonSerializerOptions? JsonOptions { get; init; }The serializer options of the input and output types (their names and enum texts); null: PluginJson.CreateOptions.
Method
Section titled “Method”string Method { get; }The method of ICorePlugin.InvokeAsync a read calls, and the run of a change: tool.<name>.
string Name { get; init; }What the tool does, in lower case words with underscores (“certificates”, “certificate_create”); the host adds the plugin’s area in front.
OutputSchema
Section titled “OutputSchema”string? OutputSchema { get; init; }The answer as JSON Schema text instead of PluginTool.OutputType.
OutputType
Section titled “OutputType”Type? OutputType { get; init; }The record of the answer (a JSON object) of PluginTool.Method for a read, of PluginTool.PreviewMethod for a change (the plan the host adds handle and expires to, so the type has no property of these names).
bool Paged { get; init; }A list: the host adds limit (1 to PluginTool.MaxRows, default PluginTool.DefaultRows) and cursor to the input, reads the cursor and hands the plugin limit and after (the sort key of the last row of the page before, see PluginToolPage); the answer’s next (the sort key of the last row, null at the end) becomes next_cursor. The output type has total and next.
Permission
Section titled “Permission”string? Permission { get; init; }A right of the plugin (a key of ICorePlugin.Permissions, or PermissionKeys.Show) the caller needs on top of what the plugin asks for the method (ICorePlugin.RequiredRole, ICorePlugin.RequiredPermission); null: the method’s own rule is the permission.
PreviewMethod
Section titled “PreviewMethod”string PreviewMethod { get; }The method of the preview of a change: tool.<name>.preview. It never writes.
ReturnsFile
Section titled “ReturnsFile”bool ReturnsFile { get; init; }The answer may hand the caller a file (SDK 0.13.0): a property file of type PluginToolFile (null when there is none) names one of the plugin’s downloads (ICorePluginDownloads) and its payload. The host never passes the bytes through the answer: it replaces file with a file reference the caller turns into a one-time download link (an agent) or a file card with Save (the assistant). The bytes are read only then, through PluginService.Download as the caller (the download’s permission, device group and audit). Never a backup, a private key or a PKCS#12 file, except a key backup protected with a password from the secret channel (PKI’s CA key backup).
RunMethod
Section titled “RunMethod”string RunMethod { get; }The method of the run of a change (the same as PluginTool.Method).
RunOutputSchema
Section titled “RunOutputSchema”string? RunOutputSchema { get; init; }The answer of PluginTool.RunMethod as JSON Schema text instead of PluginTool.RunOutputType.
RunOutputType
Section titled “RunOutputType”Type? RunOutputType { get; init; }The record of the answer of PluginTool.RunMethod (a change).
Secrets
Section titled “Secrets”IReadOnlyList<PluginToolSecret> Secrets { get; init; }Secrets the run of a change may need (SDK 0.13.0, docs/spec/mcp.md “Secrets”): a password, a shared secret. They never pass through a model or an argument. The preview’s plan chooses which the run needs with PluginToolPlan.SecretsNeeded (some of these, or secrets it names itself, such as one per saved command); a plan that names none needs all of these. The host declares them on the preview’s handle, the person enters them in their own shell or the assistant’s card, the preview method checks each entered value (a field error at secrets.<name> refuses it), and the run gets them in PluginToolInput<TArgs>.Secrets. A change only; at most 8 per preview.
TaskPlugin
Section titled “TaskPlugin”string? TaskPlugin { get; init; }The id of a task plugin of the same package whose dialog reads what this tool reads: the host lists the tool only for a caller with at least one permission of that task, like the reads of its dialog (TaskService.Query). A page call reaches the method without this check, so the plugin checks it again with ICallContext.Has. Null: none.
string Title { get; init; }The name for a person (“Certificate list”).
Methods
Section titled “Methods”bool Calls(string method)True when method is one of this tool’s methods.
CreateJsonOptions
Section titled “CreateJsonOptions”static JsonSerializerOptions CreateJsonOptions()New serializer options in the style of the host’s own tools: names in snake_case (“next_cursor”), enums by their snake_case name, nulls written, names read in any case. Keep them in a static field of the plugin (PluginJson.CreateOptions).
IsPreviewMethod
Section titled “IsPreviewMethod”static bool IsPreviewMethod(string? method)True when method only reads or previews (never writes): every tool method but the run of a change.
IsToolMethod
Section titled “IsToolMethod”static bool IsToolMethod(string? method)True when method belongs to a tool of the host (a plugin names its tool methods with it).
Fields
Section titled “Fields”DefaultRows
Section titled “DefaultRows”const int DefaultRows = 50Rows of a list by default (PluginTool.Paged).
MaxDevices
Section titled “MaxDevices”const int MaxDevices = 500Devices a tool with PluginTool.DeviceFilter gets at most (the first by address; PluginToolDevices.Total says how many matched).
MaxNameLength
Section titled “MaxNameLength”const int MaxNameLength = 40The longest name.
MaxRows
Section titled “MaxRows”const int MaxRows = 200Rows of a list at most (PluginTool.Paged).