AIW - AI CLI & MCP Unified Gateway
Unified Router & Proxy for AI CLI Tools and MCP Servers
What is AIW?
AIW is a unified gateway that acts as:
| Layer | Role | What it does |
|---|---|---|
| AI CLI Proxy | Router + Proxy | Route requests to claude/codex/gemini with provider switching, role injection, and transparent parameter forwarding |
| MCP Proxy | Router + Proxy | Route tool calls to multiple MCP servers with intelligent selection, plugin marketplace, and hot-reload |
┌─────────────────────────────────────────────────────────────┐
│ AIW Gateway │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────┐ ┌─────────────────────────────┐ │
│ │ AI CLI Router │ │ MCP Router │ │
│ │ │ │ │ │
│ │ aiw claude ... ───┼───►│ Claude CLI │ │
│ │ aiw codex ... ───┼───►│ Codex CLI │ │
│ │ aiw gemini ... ───┼───►│ Gemini CLI │ │
│ │ │ │ │ │
│ │ + Provider Switch │ │ aiw mcp serve ────────────►│ │
│ │ + Role Injection │ │ ├─► filesystem server │ │
│ │ + Param Forwarding │ │ ├─► git server │ │
│ │ + CWD Control │ │ ├─► database server │ │
│ │ │ │ └─► ... (plugin market) │ │
│ └─────────────────────┘ └─────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
Installation
# Install from NPM
# Verify installation
AI CLI Router & Proxy
Basic Usage
# Route to specific AI CLI
# Auto mode: automatic failover across AI CLIs
# Route to multiple AI CLIs
Provider Switching (-p)
# Switch API provider without changing AI CLI
# Auto-select compatible provider
# Provider config: ~/.aiw/providers.json
Auto Mode (Automatic Failover)
# Auto mode tries AI CLIs in configured order, switches on failure
# With specific provider
# With auto provider (max compatibility)
# Configure CLI execution order
How it works:
- Reads
cli_execution_orderfrom~/.aiw/config.json - Tries each CLI in order (e.g., codex → gemini → claude)
- Uses built-in LLM (Ollama) to judge success/failure
- Switches to next CLI if current fails (or halts if error is non-retryable)
Configuration (~/.aiw/config.json):
Constraints:
- Must include all 3 CLIs (codex, gemini, claude)
- Order can be changed but cannot remove/disable CLIs
- LLM judgment is mandatory (no timeout-based fallback)
Role Injection (-r)
# Inject role prompt before task
# 22 built-in roles + custom roles in ~/.aiw/role/*.md
Working Directory (-C)
# Start AI CLI in specific directory
Transparent Parameter Forwarding
# All unknown flags forwarded to AI CLI
# Order: aiw flags (-r, -p, -C) → AI CLI flags → prompt
Combined Example
# Full example with all options
# ^^^^^^^^ ^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
# role provider cwd forwarded prompt
MCP Router & Proxy
Start MCP Server
# Start AIW as MCP server
# Configure in Claude Code (~/.claude/settings.json)
{
}
MCP Server Management
# List configured MCP servers
# Add MCP server
# Enable/disable servers (hot-reload)
# Edit config directly
MCP Registry (Search & Install)
# Browse all available MCP servers (interactive TUI)
# Search across registries (Official + Smithery)
# Get server info
# Install server
Plugin Marketplace
# Browse MCP plugins (interactive TUI)
# Search plugins
# Install plugin
# List/manage installed plugins
# Manage marketplace sources
Task Monitoring
# Show task status
# Wait for all AI CLI tasks to complete
# Wait for specific process
Update
# Update AIW and all AI CLI tools
Configuration Files
| File | Purpose |
|---|---|
~/.aiw/config.json |
AIW global configuration |
~/.aiw/providers.json |
AI provider configurations |
~/.aiw/mcp.json |
MCP server configurations |
~/.aiw/role/*.md |
Custom role prompts |
~/.aiw/settings.json |
Plugin marketplace settings |
~/.aiw/plugins.json |
Installed plugin records |
Global Configuration (~/.aiw/config.json)
| Option | Type | Description |
|---|---|---|
user_roles_dir |
string | Custom directory for user roles (supports ~ expansion). If set, AIW will load user roles from this directory instead of ~/.aiw/role/ |
cli_execution_order |
array | Execution order for auto mode (must include all 3: codex, gemini, claude). Use aiw config cli-order TUI to manage |
This allows you to manage all your roles in a single location, such as ~/.claude/roles/, and share them across different tools.
Quick Reference
# AI CLI routing
# Configuration
# MCP commands
||||
# Plugin commands
||||
# Other commands
License
MIT License - see LICENSE file for details.
AIW - Unified Gateway for AI CLI & MCP | v0.5.39