CLI Reference
Complete reference for Handrive command-line interface.
Commands Overview
Handrive uses a subcommand structure:
| Command | Description |
|---|---|
handrive serve | Start the HTTP server (daemon mode) |
handrive auth | Authentication commands (status, login, logout) |
handrive mcp | Run MCP server with stdio transport |
serve - HTTP Server
Start the Handrive HTTP server for headless operation.
Usage
handrive serve [OPTIONS]Options
| Option | Description |
|---|---|
-p, --port <PORT> | Port to listen on (default: 3001 or from config) |
Examples
# Start with default port
handrive serve
# Start with custom port
handrive serve --port 8080The server waits for authentication before initializing runtime services. Use handrive auth commands in a separate terminal to authenticate.
REST API
When the server is running, it exposes a REST API with built-in documentation:
- Swagger UI:
http://localhost:3001/api/docs - OpenAPI spec:
http://localhost:3001/api/openapi.json
Adjust the port if you started the server with a custom --port.
auth - Authentication
Manage authentication with the Handrive server.
Subcommands
auth status
Check current authentication status.
handrive auth status
# Output when logged in:
# Logged in as: user@example.com
# User ID: usr_abc123def456
# Device ID: dev_xyz789
# Output when not logged in:
# Not logged inauth login otp <EMAIL>
Login using email OTP authentication.
handrive auth login otp user@example.com
# Output:
# OTP code sent to user@example.com
#
# Enter OTP code: 123456
#
# Login successful!
# Email: user@example.com
# User ID: usr_abc123def456This command sends an OTP to your email, then prompts you to enter the code interactively.
auth logout
Logout and clear stored credentials.
handrive auth logout
# Output:
# Logged out successfullymcp - MCP Server
Run the MCP (Model Context Protocol) server with stdio transport for AI assistant integration.
Usage
handrive mcpPrerequisites
You must be authenticated before running the MCP server. The command will exit with an error if not logged in.
# First, ensure the server is running
handrive serve &
# Then authenticate
handrive auth login otp user@example.com
# Now run MCP server
handrive mcpClaude Desktop Configuration
Add to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"handrive": {
"command": "/path/to/handrive",
"args": ["mcp"]
}
}
}See the MCP Guide for detailed configuration and available tools.
Examples
Start Server and Authenticate
# Terminal 1: Start the server
handrive serve --port 3001
# Terminal 2: Authenticate
handrive auth login otp user@example.com
# Enter OTP when prompted
# Check status
handrive auth statusHeadless Server with Systemd
See the Headless Guide for complete systemd setup instructions.
# Basic systemd service command
ExecStart=/usr/local/bin/handrive serve --port 3001MCP Integration
# Ensure authenticated, then run MCP
handrive auth status
handrive mcpEnvironment Variables
Data Directory
| Platform | Location |
|---|---|
| macOS | ~/Library/Application Support/Handrive/ |
| Windows | %APPDATA%\Handrive\ |
| Linux | ~/.config/handrive/ |
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error or not authenticated |
See Also
- Headless Guide — Server deployment with systemd
- MCP Guide — MCP server configuration and tools
- Troubleshooting — Common issues