Matrix CLI — thin UX layer over matrix-python-sdk (deep links, local builder, runtime)
Project description
⚡️ Matrix CLI
The command-line interface for Matrix Hub — search, inspect, install, run, probe MCP servers, manage remotes, check connectivity, and safely uninstall.
Requires Python 3.11+ and matrix-python-sdk ≥ 0.1.9.
🌍 Why Matrix CLI
Matrix CLI gets you from discovery → install → run → interact with agents, tools, and MCP servers — fast. Built to be secure by default, delightful for developers, and friendly for automation worldwide.
🚀 What’s new in v0.1.6
Aligned with matrix-python-sdk 0.1.9 (backwards-compatible refactor) and introduces a faster way to talk to your agents.
- ✨ New:
matrix do <alias> <prompt>— the quickest way to interact with a running agent. - Smarter runner discovery: Auto-materializes
runner.jsonfrom embedded b64/URL/object, embedded manifests (v1/v2), on-disk search, or inference (server.py,package.json). Synthesizes connector runners if an MCP URL is present. - Safer materialization: Writes only under your target; supports base64 files, git/http artifacts; robust logging.
- Faster environment prep: Python: fresh venv + upgraded
pip/setuptools/wheel, thenrequirements.txtor editablepyproject.toml/setup.py. Node: auto-detects pnpm > yarn > npm. - Connector-aware run (attach mode): If
runner.jsonis a connector with an MCP SSE URL,matrix runattaches (no local process).matrix stopbecomes a no-op (clears the lock). - Better MCP probing & calls: Tolerates
/ssevs/messages/, clearer errors,--jsonfor scripts. - Idempotent installs: Re-install same alias with
--force --no-promptwithout surprises.
Tip:
export MATRIX_SDK_DEBUG=1for verbose installer logs.
🎬 A 5-Minute End-to-End Demo
Experience the full lifecycle with a Watsonx agent — from search to results.
0) Setup
Create a local .env with your credentials:
# .env
WATSONX_API_KEY="your_api_key_here"
WATSONX_URL="your_url_here"
WATSONX_PROJECT_ID="your_project_id_here"
1) 🔍 Discover
matrix search "watsonx" --type mcp_server --limit 5
2) 📦 Install
matrix install mcp_server:watsonx-agent@0.1.0 --alias watsonx-chat
3) 🚀 Run
matrix run watsonx-chat --port 6288
# ✓ URL: http://127.0.0.1:6288/sse
# Health: http://127.0.0.1:6288/health
4) ✨ Ask with matrix do
matrix do watsonx-chat "Tell me about Genoa"
5) ⚙️ Advanced call
matrix mcp call chat --alias watsonx-chat --args '{"query":"List three landmarks in Genoa"}'
6) 📋 Manage & clean up
matrix ps
matrix stop watsonx-chat
matrix uninstall watsonx-chat -y
📦 Install
# Recommended
pipx install matrix-cli
# Or with pip (active virtualenv)
pip install matrix-cli
Optional extras
# Add MCP client (SSE works; WebSocket needs `websockets`)
pip install "matrix-cli[mcp]" # installs mcp>=1.13.1
# If you also want WebSocket probing:
pip install websockets
# Dev extras (linting, tests, docs)
pip install "matrix-cli[dev]"
# Using pipx? Inject extras later:
pipx inject matrix-cli mcp websockets
⚙️ Configuration
The CLI reads, in order: environment variables, ~/.config/matrix/cli.toml (optional), then built-ins.
Environment
export MATRIX_HUB_BASE="https://api.matrixhub.io" # or your dev hub
export MATRIX_HUB_TOKEN="..." # optional
export MATRIX_HOME="$HOME/.matrix" # optional; default ~/.matrix
# TLS (corporate CA/proxy)
export SSL_CERT_FILE=/path/to/ca.pem
# or
export REQUESTS_CA_BUNDLE=/path/to/ca.pem
# ps URL host override (display only)
export MATRIX_PS_HOST="localhost"
# Installer / builder verbosity (SDK ≥ 0.1.9)
export MATRIX_SDK_DEBUG=1
Optional TOML (~/.config/matrix/cli.toml)
hub_base = "https://api.matrixhub.io"
token = ""
home = "~/.matrix"
🏁 Quick start
# Basics
matrix --version
matrix version
# Search (includes pending by default)
matrix search "hello"
# Filtered search
matrix search "hello" --type mcp_server --limit 5
# Install (short name resolves to mcp_server:<name>@<latest>)
matrix install hello-sse-server --alias hello-sse-server
# Run and interact
matrix run hello-sse-server
matrix do hello-sse-server "What is Matrix CLI?"
# Inspect
matrix ps # shows URL column
matrix logs hello-sse-server -f
matrix stop hello-sse-server
# Show raw details
matrix show mcp_server:hello-sse-server@0.1.0
# Hub health (human / JSON for CI)
matrix connection
matrix connection --json --timeout 3.0
Demo GIFs
🔍 Search tips
Useful filters:
--type {agent|tool|mcp_server}--mode {keyword|semantic|hybrid}--capabilities rag,sql--frameworks langchain,autogen--providers openai,anthropic--with-snippets--certified(registered/certified only)--jsonfor programmatic output--exactto fetch a specific ID
Examples:
# MCP servers about "hello"
matrix search "hello" --type mcp_server --limit 5
# Hybrid mode with snippets
matrix search "watsonx" --mode hybrid --with-snippets
# Structured results
matrix search "sql agent" --capabilities rag,sql --json
If the public Hub is unreachable, some operations try a local dev Hub once and tell you.
🧩 Install behavior (safer by design)
- Accepts
name,name@ver,ns:name,ns:name@ver. - If
nsmissing, prefersmcp_server. - If
@versionmissing, picks latest (stable > pre-release). - Uses a small cache under
~/.matrix/cache/resolve.json(per-hub, short TTL). - No absolute paths sent to the Hub — the CLI sends a safe
<alias>/<version>label, then materializes locally. - Preflight checks ensure your local target is writable before network calls.
Examples:
# Short name; alias is optional (auto-suggested if omitted)
matrix install hello-sse-server --alias hello-sse-server
# Specific version
matrix install mcp_server:hello-sse-server@0.1.0
# Custom target
matrix install hello-sse-server --target ~/.matrix/runners/hello-sse-server/0.1.0
▶️ Run, interact, and probe
matrix run <alias> prints a click-ready URL and Health link, plus a logs hint.
# Instant interaction
matrix do <alias> "Your question here"
# Probe tools exposed by your local MCP server (auto-discovers port)
matrix mcp probe --alias <alias>
# Call a tool (optional args as JSON)
matrix mcp call <tool_name> --alias <alias> --args '{"key":"value"}'
🔗 Connector mode (attach to a remote/local MCP)
If you already have an MCP server listening (e.g. on http://127.0.0.1:6289/sse), attach to it without starting a local process by using a connector runner:
~/.matrix/runners/<alias>/<version>/runner.json:
{
"type": "connector",
"name": "watsonx-chat",
"description": "Connector to Watsonx MCP over SSE",
"integration_type": "MCP",
"request_type": "SSE",
"url": "http://127.0.0.1:6289/sse",
"endpoint": "/sse",
"headers": {}
}
Then:
matrix run watsonx-chat
matrix ps # shows URL (PID=0 attach mode)
matrix mcp probe --alias watsonx-chat
matrix mcp call chat --alias watsonx-chat --args '{"query":"Hello"}'
In connector mode,
matrix stopsimply clears the lock (no local process to kill).
🧪 MCP utilities (SSE/WS)
Probe and call tools on MCP servers.
# Probe by alias (auto-discovers port; infers endpoint)
matrix mcp probe --alias hello-sse-server
# Or probe by full SSE URL
matrix mcp probe --url http://127.0.0.1:52305/messages/
# Call a tool (optional args as JSON)
matrix mcp call hello --alias hello-sse-server --args '{}'
# JSON mode for scripts
matrix mcp probe --alias hello-sse-server --json
Notes:
- SSE works with
mcp>=1.13.1(installed via themcpextra). - WebSocket URLs (
ws:///wss://) require thewebsocketspackage. - If a call fails, the CLI helps by listing tools and tolerates
/ssevs/messages/endpoints.
🧭 Process management
matrix ps shows a URL column built from the runner’s port and endpoint (default /messages/).
┏━━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ALIAS ┃ PID ┃ PORT ┃ UPTIME ┃ URL ┃ TARGET ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ hello-sse-server │ 1234 ┃ 52305 ┃ 02:18:44 │ http://127.0.0.1:52305/messages/ │ ~/.matrix/runners/hello…/0.1.0 │
└──────────────────┴──────┴───────┴──────────┴──────────────────────────────────┴──────────────────────────────────┘
Copy the URL directly into:
matrix mcp probe --url http://127.0.0.1:52305/messages/
Script-friendly output:
# Plain (space-delimited): alias pid port uptime_seconds url target
matrix ps --plain
# JSON: array of objects with {alias,pid,port,uptime_seconds,url,target}
matrix ps --json
Other commands:
matrix logs <alias> [-f]
matrix stop <alias>
matrix doctor <alias>
🌐 Hub health & TLS
# Quick Hub health
matrix connection
matrix connection --json
TLS policy:
- Respects
REQUESTS_CA_BUNDLE/SSL_CERT_FILE. - Tries OS trust (when available).
- Falls back to
certifi. - Never throws on network errors in health checks — returns a structured status with exit codes.
🧹 Safe uninstall
Remove one or many aliases, and optionally purge local files.
# Uninstall one alias (keeps files by default)
matrix uninstall hello-sse-server
# Uninstall several and also delete files (safe paths only)
matrix uninstall hello-a hello-b --purge
# Remove everything from the local alias store (stop first, purge files)
matrix uninstall --all --force-stop --purge -y
# Dry-run (show what would be removed)
matrix uninstall --all --dry-run
Safety features:
- Only purges targets under
~/.matrix/runnersby default. - Skips deleting files still referenced by other aliases.
--force-filesallows deleting outside the safe path (⚠️ dangerous; off by default).--stopped-onlyto avoid touching running aliases.
Exit codes: 0 success, 2 partial/failed.
🧰 Scripting & CI examples
# Search, parse with jq, then install the first result
results=$(matrix search "ocr table" --type tool --json)
first_id=$(echo "$results" | jq -r '.items[0].id')
matrix install "$first_id" --alias ocr-table --force --no-prompt
# Health check in CI (exit code 0/2)
matrix connection --json
# Get the port quickly for an alias
port=$(matrix ps --plain | awk '$1=="hello-sse-server"{print $3; exit}')
matrix mcp probe --url "http://127.0.0.1:${port}/messages/" --json
🐞 Troubleshooting
- “Missing 'mcp' package” — Install the optional extra:
pip install "matrix-cli[mcp]"(andpip install websocketsfor WS). - TLS / certificate errors — Set
SSL_CERT_FILEorREQUESTS_CA_BUNDLEto your CA bundle. - Alias not found when probing — Use the alias shown by
matrix ps(case-insensitive), or pass--urldirectly. - Connector mode shows PID=0 — Expected in attach mode; ensure the remote server is running.
🛠️ Development
# Create venv and install (editable) with useful extras
python3.11 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -e ".[dev,mcp]"
# Common tasks
make lint # ruff/flake8
make fmt # black
make typecheck # mypy
make test # pytest
make build # sdist + wheel
🌍 About MatrixHub
MatrixHub aims to be the pip of agents & MCP servers — a secure, open, and developer-friendly registry and runtime that scales from personal laptops to global enterprises. If you’re building agents, tools, or MCP services, Matrix CLI gets you from idea to running in seconds.
📄 License
Apache License 2.0
✉️ Feedback
Issues and PRs welcome! If you hit rough edges with install/probing/health, the new connector flow, or ps --plain/--json and uninstall, please open an issue with your command, output, and environment.
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 matrix_cli-0.1.8.tar.gz.
File metadata
- Download URL: matrix_cli-0.1.8.tar.gz
- Upload date:
- Size: 83.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5dfefeb9ff5210fadc579911a97af3eb1317011e9f81773d6d726960065eb77
|
|
| MD5 |
1283379b52a1b776d96ed2b6038850f0
|
|
| BLAKE2b-256 |
1bcfb96923b7566d196c5d729007e8d52c1eec8da2149bc2370c930998e7df17
|
Provenance
The following attestation bundles were made for matrix_cli-0.1.8.tar.gz:
Publisher:
release.yml on agent-matrix/matrix-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matrix_cli-0.1.8.tar.gz -
Subject digest:
f5dfefeb9ff5210fadc579911a97af3eb1317011e9f81773d6d726960065eb77 - Sigstore transparency entry: 506756915
- Sigstore integration time:
-
Permalink:
agent-matrix/matrix-cli@598352ad015523c4ad49cbb8a13441457df28c04 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/agent-matrix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@598352ad015523c4ad49cbb8a13441457df28c04 -
Trigger Event:
release
-
Statement type:
File details
Details for the file matrix_cli-0.1.8-py3-none-any.whl.
File metadata
- Download URL: matrix_cli-0.1.8-py3-none-any.whl
- Upload date:
- Size: 85.1 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 |
2f1c0481b8931af9359dbf3d5217a3d3daaadaf80dcc10a6b5f71a0113984075
|
|
| MD5 |
f2d227629600c8e787edf1c6529add39
|
|
| BLAKE2b-256 |
d72be646b17559c869cbc4ed0202a21dacd6236a30d63230c2dd544d8063a005
|
Provenance
The following attestation bundles were made for matrix_cli-0.1.8-py3-none-any.whl:
Publisher:
release.yml on agent-matrix/matrix-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matrix_cli-0.1.8-py3-none-any.whl -
Subject digest:
2f1c0481b8931af9359dbf3d5217a3d3daaadaf80dcc10a6b5f71a0113984075 - Sigstore transparency entry: 506756946
- Sigstore integration time:
-
Permalink:
agent-matrix/matrix-cli@598352ad015523c4ad49cbb8a13441457df28c04 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/agent-matrix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@598352ad015523c4ad49cbb8a13441457df28c04 -
Trigger Event:
release
-
Statement type: