# MCP Gateway CLI

Command-line tool for managing MCP Gateway workspaces, backends, and agents.

## Installation

### pip (Python)
```bash
pip install mcpgw
```

### Homebrew (macOS/Linux)
```bash
# Add tap
brew tap orangefennec/tap

# Install
brew install mcpgw
```

### From source
```bash
cd cli
pip install -e .
```

## Quick Start

### 1. Login
```bash
mcpgw auth login
# Enter your email and password
```

### 2. List Workspaces
```bash
mcpgw workspace list
```

### 3. Create Workspace
```bash
mcpgw workspace create --name "Production"
```

### 4. Add Backend
```bash
mcpgw backend add WORKSPACE_ID --name "Gmail" --url "http://gmail-mcp:9000"
```

### 5. Create Agent
```bash
mcpgw agent create WORKSPACE_ID --name "My Agent"
# Save the API key shown!
```

## Commands

### Authentication
```bash
mcpgw auth login              # Login
mcpgw auth logout             # Logout
mcpgw auth whoami             # Show current user
```

### Workspaces
```bash
mcpgw workspace list                    # List all workspaces
mcpgw workspace get WORKSPACE_ID        # Get workspace details
mcpgw workspace create                  # Create new workspace
mcpgw workspace delete WORKSPACE_ID     # Delete workspace
```

### Backends
```bash
mcpgw backend list WORKSPACE_ID                           # List backends
mcpgw backend add WORKSPACE_ID --name X --url Y           # Add backend
mcpgw backend remove WORKSPACE_ID BACKEND_ID              # Remove backend
```

### Backend Catalog
```bash
mcpgw catalog list                                  # Browse catalog
mcpgw catalog list --category email                 # Filter by category
mcpgw catalog enable WORKSPACE_ID BACKEND_ID        # Enable from catalog
```

### Agents
```bash
mcpgw agent list WORKSPACE_ID                 # List agents
mcpgw agent create WORKSPACE_ID --name X      # Create agent
```

## Configuration

Config stored in `~/.mcpgw/config.json`

### Environment Variables
- `MCPGW_API_URL` - API base URL (default: http://localhost:8000/api/v1)

## Examples

### Setup a new workspace
```bash
# Login
mcpgw auth login

# Create workspace
mcpgw workspace create --name "Production"

# Enable Gmail backend
WORKSPACE_ID="ws_abc123"
mcpgw catalog enable $WORKSPACE_ID backend_gmail

# Create an agent
mcpgw agent create $WORKSPACE_ID --name "Email Agent"
```

### Get workspace info as JSON
```bash
mcpgw workspace list --json-output | jq '.[0]'
```

## Development

```bash
# Install in development mode
cd cli
pip install -e .

# Run tests
pytest

# Build distribution
python setup.py sdist bdist_wheel

# Upload to PyPI
twine upload dist/*
```

## License

MIT
