Modern CLI for XNAT neuroimaging server administration
Project description
xnatctl
A modern CLI for XNAT neuroimaging server administration.
Features
- Resource-centric commands:
xnatctl <resource> <action> [args] - Profile-based configuration: YAML config with multiple server profiles
- Consistent output:
--output json|tableand--quieton all commands - Parallel operations: Batch uploads/downloads with progress tracking
- Session authentication: Token caching with
auth login - Pure HTTP: Direct REST API calls with httpx (no pyxnat dependency)
Installation
Standalone Binary (no Python required)
Pre-built binaries are available for Linux, macOS, and Windows. The install script auto-detects your OS and architecture:
# One-line install (latest release, auto-detects platform)
curl -fsSL https://github.com/rickyltwong/xnatctl/raw/main/install.sh | bash
# Install a specific version
XNATCTL_VERSION=v0.1.0 curl -fsSL https://github.com/rickyltwong/xnatctl/raw/main/install.sh | bash
# Custom install directory (default: ~/.local/bin)
XNATCTL_INSTALL_DIR=/usr/local/bin curl -fsSL https://github.com/rickyltwong/xnatctl/raw/main/install.sh | bash
Or download manually from GitHub Releases:
| Platform | Asset |
|---|---|
| Linux (x86_64) | xnatctl-linux-amd64.tar.gz |
| macOS (x86_64) | xnatctl-darwin-amd64.tar.gz |
| Windows (x86_64) | xnatctl-windows-amd64.zip |
# Linux / macOS
tar -xzf xnatctl-<platform>-amd64.tar.gz
chmod +x xnatctl
mv xnatctl ~/.local/bin/
# Windows (PowerShell)
Expand-Archive xnatctl-windows-amd64.zip -DestinationPath .
Move-Item xnatctl.exe C:\Users\<you>\AppData\Local\bin\
Python Package
# From PyPI (recommended)
pip install xnatctl
# With uv
uv pip install xnatctl
# For DICOM utilities (optional)
pip install "xnatctl[dicom]"
# From source
pip install git+https://github.com/rickyltwong/xnatctl.git
Docker
docker run --rm ghcr.io/rickyltwong/xnatctl:main --help
Quick Start
# Create config file
xnatctl config init --url https://xnat.example.org
# Authenticate
xnatctl auth login
# List projects
xnatctl project list
# Download a session
xnatctl session download XNAT_E00001 --out ./data
Commands
| Command | Description |
|---|---|
xnatctl config |
Manage configuration profiles |
xnatctl auth |
Authentication (login/logout/status) |
xnatctl project |
Project operations (list/show/create) |
xnatctl subject |
Subject operations (list/show/rename/delete) |
xnatctl session |
Session operations (list/show/download/upload) |
xnatctl scan |
Scan operations (list/show/delete) |
xnatctl resource |
Resource operations (list/upload/download) |
xnatctl prearchive |
Prearchive management |
xnatctl pipeline |
Pipeline execution |
xnatctl admin |
Administrative operations |
xnatctl api |
Raw API access (escape hatch) |
xnatctl dicom |
DICOM utilities (requires pydicom) |
Configuration
Config file location: ~/.config/xnatctl/config.yaml
default_profile: production
output_format: table
profiles:
production:
url: https://xnat.example.org
username: myuser # optional, can also use env vars
password: mypassword # optional, can also use env vars
verify_ssl: true
timeout: 30
default_project: MYPROJECT
development:
url: https://xnat-dev.example.org
verify_ssl: false
Getting Started with Profiles
# Create an initial config (prompts for URL and optional defaults)
xnatctl config init --url https://xnat.example.org
# Add additional profiles
xnatctl config add-profile dev --url https://xnat-dev.example.org --no-verify-ssl
# Switch the active profile
xnatctl config use-context dev
# Show the active profile and config
xnatctl config show
Authentication Flow
# Login and cache a session token
xnatctl auth login
# Check current user/session context
xnatctl whoami
Credential priority (highest to lowest):
- CLI arguments (
--username,--password) - Environment variables (
XNAT_USER,XNAT_PASS) - Profile config (
username,passwordin config.yaml) - Interactive prompt
Session tokens are cached under ~/.config/xnatctl/.session and used automatically.
Environment Variables
| Variable | Description |
|---|---|
XNAT_URL |
Server URL |
XNAT_USER |
Username |
XNAT_PASS |
Password |
XNAT_TOKEN |
Session token |
XNAT_PROFILE |
Config profile |
Notes:
XNAT_TOKENtakes precedence over cached sessions and username/password.XNAT_URLandXNAT_PROFILEoverride values fromconfig.yamlfor the current shell.- Use
XNAT_USER/XNAT_PASSfor non-interactive auth (CI, scripts).
Development
# Clone and install
git clone https://github.com/rickyltwong/xnatctl.git
cd xnatctl
uv sync
# Run tests
uv run pytest
# Lint and format
uv run ruff check xnatctl
uv run ruff format xnatctl
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xnatctl-0.1.0.tar.gz.
File metadata
- Download URL: xnatctl-0.1.0.tar.gz
- Upload date:
- Size: 217.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7697985eaf28f8fca0e78b7f8949b3e8937db59e77a1aca1f8d0198fef656058
|
|
| MD5 |
ef042ba03e67061145b705da99835f43
|
|
| BLAKE2b-256 |
d4791759e513387303e0efac318dd1a308dca10b6a6411e8ce98ac862f93761b
|
Provenance
The following attestation bundles were made for xnatctl-0.1.0.tar.gz:
Publisher:
ci.yml on rickyltwong/xnatctl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xnatctl-0.1.0.tar.gz -
Subject digest:
7697985eaf28f8fca0e78b7f8949b3e8937db59e77a1aca1f8d0198fef656058 - Sigstore transparency entry: 963322100
- Sigstore integration time:
-
Permalink:
rickyltwong/xnatctl@3c95b945f7851f9f3a581d7fc53f4024eeb753a7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/rickyltwong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@3c95b945f7851f9f3a581d7fc53f4024eeb753a7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file xnatctl-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xnatctl-0.1.0-py3-none-any.whl
- Upload date:
- Size: 110.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1efcce9d8a10209065b7db341551334ac5f8b536511ac871326a5218f66bf050
|
|
| MD5 |
96f5289104563d8939657a0a6f14d648
|
|
| BLAKE2b-256 |
febaafabb2015ab5468ab7ae1c2dde3fbecf617ddf46b49190775ba17a4483fc
|
Provenance
The following attestation bundles were made for xnatctl-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on rickyltwong/xnatctl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xnatctl-0.1.0-py3-none-any.whl -
Subject digest:
1efcce9d8a10209065b7db341551334ac5f8b536511ac871326a5218f66bf050 - Sigstore transparency entry: 963322119
- Sigstore integration time:
-
Permalink:
rickyltwong/xnatctl@3c95b945f7851f9f3a581d7fc53f4024eeb753a7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/rickyltwong
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@3c95b945f7851f9f3a581d7fc53f4024eeb753a7 -
Trigger Event:
push
-
Statement type: