Agent CLI Commands | Medplum

The Medplum CLI provides several commands for managing and interacting with agents. This document describes the available commands and their usage. See more about installing and using the Medplum CLI here.

Status Command

Get the status of one or more agents.

medplum agent status [agentIds...] [options]

Arguments

Options

Example

# Get status for specific agents
medplum agent status 123e4567-e89b-12d3-a456-426614174000 123e4567-e89b-12d3-a456-426614174001

# Get status using search criteria
medplum agent status --criteria "Agent?name=Test Agent"

# Get status in JSON format
medplum agent status --criteria "Agent?name=Test Agent" --output json

Ping Command

Ping a host from a specified agent.

medplum agent ping <ipOrDomain> <agentId> [options]

Arguments

Options

Example

# Ping using specific agent
medplum agent ping example.com 123e4567-e89b-12d3-a456-426614174000

# Ping using search criteria
medplum agent ping example.com --criteria "Agent?name=Test Agent"

# Ping multiple times
medplum agent ping example.com --criteria "Agent?name=Test Agent" --count 5

Push Command

Push a message to a target device via a specified agent.

medplum agent push <deviceId> <message> <agentId> [options]

Arguments

Options

Example

# Push message using specific agent
medplum agent push device123 "Hello World" 123e4567-e89b-12d3-a456-426614174000

# Push message using search criteria
medplum agent push device123 "Hello World" --criteria "Agent?name=Test Agent"

# Push message without waiting for response
medplum agent push device123 "Hello World" --criteria "Agent?name=Test Agent" --no-wait

Reload Config Command

Reload the configuration for one or more agents.

medplum agent reload-config [agentIds...] [options]

Arguments

Example

# Reload config for specific agents
medplum agent reload-config 123e4567-e89b-12d3-a456-426614174000 123e4567-e89b-12d3-a456-426614174001

# Reload config using search criteria
medplum agent reload-config --criteria "Agent?name=Test Agent"

Upgrade Command

Upgrade the version for one or more agents.

medplum agent upgrade [agentIds...] [options]

Arguments

Options

Example

# Upgrade specific agents to latest version
medplum agent upgrade 123e4567-e89b-12d3-a456-426614174000 123e4567-e89b-12d3-a456-426614174001

# Upgrade using search criteria
medplum agent upgrade --criteria "Agent?name=Test Agent"

# Upgrade to specific version
medplum agent upgrade --criteria "Agent?name=Test Agent" --version 1.2.3

Stats Command

Get runtime statistics for one or more agents.

medplum agent stats [agentIds...] [options]

Arguments

Example

# Get stats for specific agents
medplum agent stats 123e4567-e89b-12d3-a456-426614174000 123e4567-e89b-12d3-a456-426614174001

# Get stats using search criteria
medplum agent stats --criteria "Agent?name=Test Agent"

# Get stats in JSON format
medplum agent stats --criteria "Agent?name=Test Agent" --output json

Common Options

All commands support the following common options:

Error Handling

The CLI provides detailed error messages when operations fail. Common error scenarios include:

When using the --output json option, errors are returned in a structured format that can be parsed programmatically.