Skip to main content

Portable workflow framework - transform any script into a versioned, schedulable command. Store in ~/.mcli/commands/, version with lockfile, run as daemon or cron job.

Project description

MCLI - Portable Workflow Framework

Transform any script into a versioned, portable, schedulable workflow command.

MCLI is a modular CLI framework that lets you write scripts once and run them anywhere - as interactive commands, scheduled jobs, or background daemons. Your workflows live in ~/.mcli/commands/, are versioned via lockfile, and completely decoupled from the engine source code.

🎯 Core Philosophy

Write a script. Store it. Version it. Run it anywhere. Schedule it. Share it.

No coupling to the engine. No vendor lock-in. Just portable workflows that work.

⚡ Quick Start

Installation

# Install from PyPI
pip install mcli-framework

# Or with UV (recommended)
uv pip install mcli-framework

Create Your First Workflow

Method 1: From a Python Script

# Write your script
cat > my_task.py << 'EOF'
import click

@click.command()
@click.option('--message', default='Hello', help='Message to display')
def app(message):
    """My custom workflow"""
    click.echo(f"{message} from my workflow!")
EOF

# Import as workflow
mcli commands import-script my_task.py --name my-task --group workflow

# Run it
mcli workflow my-task --message "Hi"

Method 2: Interactive Creation

# Create workflow interactively
mcli commands add my-task --group workflow

# Edit in your $EDITOR, then run
mcli workflow my-task

📦 Workflow System Features

1. Create Workflows

Multiple ways to create workflows:

# Import from existing Python script
mcli commands import-script script.py --name my-workflow --group workflow

# Create new workflow interactively
mcli commands add my-workflow --group workflow --description "Does something useful"

# List all workflows
mcli commands list-custom

2. Edit & Manage Workflows

# Edit workflow in $EDITOR
mcli commands edit my-workflow

# Show workflow details
mcli commands info my-workflow

# Search workflows
mcli commands search "pdf"

# Remove workflow
mcli commands remove my-workflow

3. Export & Import (Portability)

Share workflows across machines or with your team:

# Export all workflows to JSON
mcli commands export my-workflows.json

# Import on another machine
mcli commands import my-workflows.json

# Export single workflow to Python script
mcli commands export-script my-workflow --output my_workflow.py

Your workflows are just JSON files in ~/.mcli/commands/:

$ ls ~/.mcli/commands/
pdf-processor.json
data-sync.json
git-commit.json
commands.lock.json  # Version lockfile

4. Version Control with Lockfile

MCLI automatically maintains a lockfile for reproducibility:

# Update lockfile with current workflow versions
mcli commands update-lockfile

# Verify workflows match lockfile
mcli commands verify

Example commands.lock.json:

{
  "version": "1.0",
  "generated_at": "2025-10-17T10:30:00Z",
  "commands": {
    "pdf-processor": {
      "name": "pdf-processor",
      "description": "Intelligent PDF processor",
      "group": "workflow",
      "version": "1.2",
      "updated_at": "2025-10-15T14:30:00Z"
    }
  }
}

Version control your workflows:

# Add lockfile to git
git add ~/.mcli/commands/commands.lock.json ~/.mcli/commands/*.json
git commit -m "Update workflows"

# On another machine
git pull
mcli commands verify  # Ensures consistency

5. Run as Daemon or Scheduled Task

Workflows aren't coupled to the engine - run them however you want:

As a Daemon:

# Start workflow as background daemon
mcli workflow daemon start my-task-daemon --workflow my-task

# Check daemon status
mcli workflow daemon status

# Stop daemon
mcli workflow daemon stop my-task-daemon

As Scheduled Task:

# Schedule workflow to run every hour
mcli workflow scheduler add \
  --name hourly-sync \
  --schedule "0 * * * *" \
  --workflow my-task

# List scheduled workflows
mcli workflow scheduler list

# View logs
mcli workflow scheduler logs hourly-sync

🎨 Real-World Workflow Examples

Example 1: PDF Processor

# Create PDF processing workflow
mcli commands import-script pdf_tool.py --name pdf --group workflow

# Use it
mcli workflow pdf extract ~/Documents/report.pdf
mcli workflow pdf compress ~/Documents/*.pdf --output compressed/
mcli workflow pdf split large.pdf --pages 10

Example 2: Data Sync Workflow

# Create sync workflow
cat > sync.py << 'EOF'
import click
import subprocess

@click.group()
def app():
    """Multi-cloud sync workflow"""
    pass

@app.command()
@click.argument('source')
@click.argument('dest')
def backup(source, dest):
    """Backup data to cloud"""
    subprocess.run(['rclone', 'sync', source, dest])
    click.echo(f"Synced {source} to {dest}")

@app.command()
def status():
    """Check sync status"""
    click.echo("Checking sync status...")
EOF

mcli commands import-script sync.py --name sync --group workflow

# Run manually
mcli workflow sync backup ~/data remote:backup

# Or schedule it
mcli workflow scheduler add \
  --name nightly-backup \
  --schedule "0 2 * * *" \
  --workflow "sync backup ~/data remote:backup"

Example 3: Git Commit Helper

# Already included as built-in workflow
mcli workflow git-commit

# Or create your own variant
mcli commands export-script git-commit --output my_git_helper.py
# Edit my_git_helper.py to customize
mcli commands import-script my_git_helper.py --name my-git --group workflow

🔧 Workflow Structure

Each workflow is a JSON file with this structure:

{
  "name": "my-workflow",
  "group": "workflow",
  "description": "Does something useful",
  "version": "1.0",
  "metadata": {
    "author": "you@example.com",
    "tags": ["utility", "automation"]
  },
  "code": "import click\n\n@click.command()\ndef app():\n    click.echo('Hello!')",
  "updated_at": "2025-10-17T10:00:00Z"
}

🚀 Built-in Workflows

MCLI comes with powerful built-in workflows:

mcli workflow --help

Available workflows:

  • pdf - Intelligent PDF processing (extract, compress, split, merge)
  • clean - Enhanced Mac system cleaner
  • emulator - Android/iOS emulator management
  • git-commit - AI-powered commit message generation
  • scheduler - Cron-like job scheduling
  • daemon - Process management and daemonization
  • redis - Redis cache management
  • videos - Video processing and overlay removal
  • sync - Multi-cloud synchronization
  • politician-trading - Financial data collection (specialized)

💡 Why MCLI?

The Problem

You write scripts. They work. Then:

  • ❌ Can't remember where you saved them
  • ❌ Hard to share with team members
  • ❌ No version control or change tracking
  • ❌ Coupling to specific runners or frameworks
  • ❌ No easy way to schedule or daemonize

The MCLI Solution

  • Centralized Storage: All workflows in ~/.mcli/commands/
  • Portable: Export/import as JSON, share anywhere
  • Versioned: Lockfile for reproducibility
  • Decoupled: Zero coupling to engine source code
  • Flexible Execution: Run interactively, scheduled, or as daemon
  • Discoverable: Tab completion, search, info commands

📚 Advanced Features

Shell Completion

# Install completion for your shell
mcli completion install

# Now use tab completion
mcli workflow <TAB>          # Shows all workflows
mcli workflow pdf <TAB>      # Shows pdf subcommands

AI Chat Integration

# Chat with AI about your workflows
mcli chat

# Configure AI providers
export OPENAI_API_KEY=your-key
export ANTHROPIC_API_KEY=your-key

Self-Update

# Update MCLI to latest version
mcli self update

# Check version
mcli version

🛠️ Development

For Development or Customization

# Clone repository
git clone https://github.com/gwicho38/mcli.git
cd mcli

# Setup with UV
uv venv
uv pip install -e ".[dev]"

# Run tests
make test

# Build wheel
make wheel

📖 Documentation

🎯 Common Use Cases

Use Case 1: Daily Automation Scripts

# Create your daily automation
mcli commands add daily-tasks --group workflow
# Add your tasks in $EDITOR
mcli workflow scheduler add --name daily --schedule "0 9 * * *" --workflow daily-tasks

Use Case 2: Team Workflow Sharing

# On your machine
mcli commands export team-workflows.json

# Share file with team
# On teammate's machine
mcli commands import team-workflows.json
mcli commands verify  # Ensure consistency

Use Case 3: CI/CD Integration

# In your CI pipeline
- pip install mcli-framework
- mcli commands import ci-workflows.json
- mcli workflow build-and-test
- mcli workflow deploy --env production

📦 Dependencies

Core (Always Installed)

  • click: CLI framework
  • rich: Beautiful terminal output
  • requests: HTTP client
  • python-dotenv: Environment management

Optional Features

All features are included by default as of v7.0.0. For specialized needs:

# GPU support (CUDA required)
pip install "mcli-framework[gpu]"

# Development tools
pip install "mcli-framework[dev]"

🤝 Contributing

We welcome contributions! Especially workflow examples.

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/awesome-workflow
  3. Create your workflow
  4. Export it: mcli commands export my-workflow.json
  5. Submit PR with workflow JSON

📄 License

MIT License - see LICENSE for details.

🙏 Acknowledgments


Start transforming your scripts into portable workflows today:

pip install mcli-framework
mcli commands add my-first-workflow --group workflow

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

mcli_framework-7.9.6.tar.gz (848.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcli_framework-7.9.6-py3-none-any.whl (785.6 kB view details)

Uploaded Python 3

File details

Details for the file mcli_framework-7.9.6.tar.gz.

File metadata

  • Download URL: mcli_framework-7.9.6.tar.gz
  • Upload date:
  • Size: 848.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcli_framework-7.9.6.tar.gz
Algorithm Hash digest
SHA256 51591c93e91761bfeba1511c4e4949728ff185ff2f32c97bc7a9e00e1ccbe528
MD5 ad96d1f1ac9b6e78fb3e6a0857195497
BLAKE2b-256 a268d1f0982910fbdf8a6d68ea905f7bf539acbe046758dad53d093381f8e44e

See more details on using hashes here.

File details

Details for the file mcli_framework-7.9.6-py3-none-any.whl.

File metadata

  • Download URL: mcli_framework-7.9.6-py3-none-any.whl
  • Upload date:
  • Size: 785.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcli_framework-7.9.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e60377ee60956276634291e49d59b16d25560086a4a60202b7da6f6acc8970f3
MD5 37f89ff38bcd73d51526b59ccc21aa21
BLAKE2b-256 f141e0138b1ab30a2a02ef51bc6a45b763d10910f3f9e2e8959808f7d781130a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page