For the broader developer guide covering command flow, next-action flow, history semantics, and MCP exclusion, start with Provider Command And Event Flow Guide.
This note describes how command intents are accepted by the Provider API, queued in memory, transformed into OpAMP payloads, and marked as sent.
POST /api/clients/<client_id>/commandsGET /api/commands/customprovider/src/opamp_provider/state.pyprovider/src/opamp_provider/app.pyprovider/src/opamp_provider/commands.pyprovider/src/opamp_provider/command_interface.pyprovider/src/opamp_provider/command_restart_agent.pyprovider/src/opamp_provider/command_implementations/command_chatops.pyprovider/src/opamp_provider/command_shutdown_agent.pyprovider/src/opamp_provider/command_nullcommand.pyprovider/src/opamp_provider/html/web_ui.htmlThe commands endpoint accepts an array of key/value pairs:
[
{ "key": "classifier", "value": "command" },
{ "key": "action", "value": "restart" }
]
Supported classifiers:
commandcustomcustom_commandRequired keys:
classifieractionCommandRecord stores normalized intent data:
command (currently mirrors action)classifieractionkey_value_pairsreceived_atsent_atQueue behavior:
ClientRecord.commands.next_pending_command(...).mark_command_sent(...).At provider startup (module import time), opamp_provider.commands scans command modules and discovers all concrete CommandObjectInterface implementations.
Discovery outputs:
(classifier, operation) for factory creation.isOpAMPStandard()).(classifier, operation) for reverse-FQDN lookup (custom commands).Helper APIs:
get_registered_command_keys(parameter_exclude_opamp_standard=True, includedisplayname=True)get_registered_command_fqdns()get_custom_capabilities_list()get_command_fqdn(classifier=..., operation=...)get_command_metadata(parameter_exclude_opamp_standard=True, custom_only=False)command_object_factory(classifier=..., operation=..., key_values=...)Filtering and display behavior:
parameter_exclude_opamp_standard=True returns only non-OpAMP-standard commands.parameter_exclude_opamp_standard=False returns only OpAMP-standard commands.includedisplayname=True returns a dictionary of fqdn -> displayname.includedisplayname=False returns a tuple list of (classifier, operation) keys.get_capability_fqdn() are excluded from custom capability/FQDN-oriented outputs.Any duplicate (classifier, operation) registration raises an error at startup.
Command objects implement CommandObjectInterface and now expose:
isOpAMPStandard() -> boolgetdisplayname() -> strCommand objects that provide configuration metadata also implement:
CommandParameterSchemaInterface.get_user_parameter_schema()Schema rows are JSON objects with:
parametername (string)isrequired (boolean)Dispatch happens in app.py via a mapping from (classifier, action) to builder methods.
Current mapping:
("command", "restart") -> _build_restart_command(...)("custom", "chatopcommand") -> _build_custom_command_payload(...)("custom", "shutdownagent") -> _build_custom_command_payload(...)("custom", "nullcommand") -> _build_custom_command_payload(...)("custom_command", "*") -> _build_custom_command_payload(...)If no mapping exists for the submitted classifier/action, the API rejects it with 400.
_build_restart_command(...) constructs ServerToAgent.command and sets:
command.type = CommandType_RestartThis creates a ServerToAgentCommand payload for restart.
_build_custom_command_payload(...) constructs ServerToAgent.custom_message.
For classifier=custom and action=chatopcommand, the server builds a ChatOpCommand object via the command factory and uses to_custom_message().
ChatOpCommand payload behavior:
capability is fixed to reverse-FQDN:
org.mp3monster.opamp_provider.chatopcommandtype is fixed to:
requestdata is set to UTF-8 bytes of the full key/value dictionary JSON.For classifier=custom and action=shutdownagent, the server builds a CommandShutdownAgent object via the command factory and uses to_custom_message().
CommandShutdownAgent payload behavior:
capability is fixed to reverse-FQDN:
org.mp3monster.opamp_provider.command_shutdown_agenttype is fixed to:
Shutdown Agentdata is set to UTF-8 bytes of the full key/value dictionary JSON.For classifier=custom and action=nullcommand, the server builds a CommandNullCommand
object via the command factory and uses to_custom_message().
CommandNullCommand payload behavior:
capability is fixed to reverse-FQDN:
org.mp3monster.opamp_provider.nullcommandtype is fixed to:
Null Commanddata is set to UTF-8 bytes of the full key/value dictionary JSON.Purpose note:
nullcommand exists primarily to test custom command handling end-to-end
(discovery, metadata, UI selection/configuration, queueing, and payload emission).For generic custom_command payloads, additional optional key/value pairs can be supplied:
capabilitytypedataDefaults:
capability defaults to custom_commandtype defaults to the submitted actiondata defaults to empty bytes when omittedThe client dialogue UI uses the metadata endpoint to build the custom command experience:
GET /api/commands/custom.fqdn, displayname, and schema.displayname.parametername)description text (or a default fallback when missing).isrequired/isRequired is true before enabling send.Send Command button.POST /api/clients/<client_id>/commands.Notes:
classifier, type, data) are excluded from user schema metadata and guarded by registry sanitization.On the consumer side, ChatOpsCommand.execute_action(...) dispatches local HTTP requests based on
the custom message payload:
chat_ops_port plus optional tag path.attributes are parsed into a JSON object; invalid/missing attributes resolve to {}.Content-Type: application/jsonContent-Length: <serialized byte length>CustomMessage with:
type = "failure"data = {"http_code":"...","err_msg":"..."}For both HTTP and WebSocket OpAMP paths:
_apply_command_intent(...) runs classifier/action dispatch.command or custom_message, the queued record is marked sent.Debug logging exists at payload build points:
ServerToAgent.command payloadServerToAgent.custom_message payloadclassifier, action, has_command, has_custom_message)Enable DEBUG logging in the provider runtime to see these entries.