Appearance
hailer-sdk init
Initialize a new Hailer project with proper structure and configuration.
Usage
bash
hailer-sdk initFlags
init is interactive, but any prompt can be pre-answered with a flag (useful for scripting / CI):
| Flag | Effect |
|---|---|
--project-name <name> | Project name (skips the prompt). |
--workspace <id> | Target workspace id (must be one you own or admin). |
--email <email> / --password <pw> | Credentials (skips the prompts). |
--user-api-key <key> | Authenticate with an API key instead of email/password (enables remote MCP). |
--mcp-url <url> | Remote MCP server URL. Requires --user-api-key. |
--bot / --no-bot | Create / skip the bot account (skips the prompt). |
--mcp / --no-mcp | Set up / skip the MCP server (skips the prompt). |
--hailer-studio | Adjust the generated project for Hailer Studio. |
--verbose | Detailed logging. |
Description
The init command is an interactive wizard that guides you through setting up a new Hailer project. It handles authentication, workspace selection, optional bot account creation, optional MCP server setup, and creates all necessary project files and configurations.
Interactive Steps
- Project name - Choose a name for your project
- API URL - Select which Hailer API to connect to (cloud or local development)
- Email - Enter your Hailer account email (skipped if
--user-api-keyprovided) - Password - Enter your Hailer account password (skipped if
--user-api-keyprovided) - Workspace selection - Choose from the workspaces where you're an owner or admin, or create a new one
- Bot account creation - Optionally create a bot user for automated workspace operations
- MCP server setup - Optionally set up the Model Context Protocol server for TUI integration. With
--user-api-key, sets up a remote MCP connection; otherwise sets up a local MCP server (local MCP requires a bot account)
What it Creates
The command generates a complete project structure:
my-project/
├── workspace/ # Workflow configs (generated on `npm run pull`)
│ └── hailer.d.ts # Type definitions (copied in at init)
├── .mcp.json # MCP configuration (if MCP enabled; git-ignored)
├── .env.local # MCP server credentials (local MCP only; git-ignored)
├── docs/ # Copy of SDK documentation
├── .env # Environment variables (password or user API key; git-ignored)
├── .gitignore # Excludes .env and other sensitive files
├── config.json # Workspace configuration
├── package.json # Node.js project configuration with useful scripts
├── tsconfig.json # TypeScript configuration
├── vitest.config.ts # Test runner configuration
├── CLAUDE.md # TUI agent instructions
└── README.md # Project documentation
# On `npm install`, the postinstall step also copies from @hailer/mcp:
# .claude/ # TUI configuration
# .opencode/ # OpenCode configuration
# CLAUDE.md # refreshed to the latest agent instructionsGenerated npm scripts
The package.json includes these helpful scripts:
Workspace Management:
npm run pull- Pull workflows from Hailernpm run push- Push all configurations to Hailernpm run workflows-push- Push only workflow configurationsnpm run workflows-sync- Create/delete workflowsnpm run fields-push- Push only field configurationsnpm run phases-push- Push only phase configurationsnpm run templates-push- Push only template configurationsnpm run templates-sync- Create/delete document templatesnpm run groups-push- Push only group configurationsnpm run teams-push- Push only team configurationsnpm run insights-push- Push only insights configurationsnpm run apps-push- Push only app configurations
Every push/sync script also has a
:forcevariant (e.g.push:force,fields-push:force,workflows-sync:force) that skips delete confirmations.
Testing & maintenance:
npm test/npm run test:watch/npm run test:ui- Run function-field tests (Vitest)npm run sdk-update- Update@hailer/sdkand re-run postinstallpostinstall- Copies.claude/and.opencode/config and refreshes type definitions (runs automatically onnpm install)
MCP Server (local MCP only):
npm run mcp-start- Start the MCP servernpm run mcp-update- Update @hailer/mcp package and refresh .claude and .opencode directories
Note: Remote MCP setups do not include
mcp-startscript — the MCP server runs remotely.
Bot Account (Optional)
During initialization, you can choose to create a bot account for your workspace. The bot account:
- Is registered as user Bot Botinen with email
<workspace-name>_<4-digit suffix>@botinen.fi - Gets a randomly generated secure password (32 characters)
- Is added to the 🤖 Bots team in your workspace (created if it doesn't exist)
- Is invited with the admin role
- Its credentials replace your personal credentials in the project's
.envfile (and, for local MCP, in.env.local)
This is useful for:
- Separating bot actions from personal user actions
Note: The bot credentials are displayed once during initialization. But you can see the bot's email in the config.json file and the password in .env file.
Declining the bot in the interactive flow means a local MCP server can't be set up — local MCP authenticates with the bot's credentials.
MCP Server Setup (Optional)
The MCP (Model Context Protocol) server enables your TUI to interact with your Hailer workspace programmatically. There are two modes: local and remote.
Local MCP (requires a bot account)
When enabled, the initialization:
- Creates
.mcp.json— annpx mcp-remoteclient pointing at the local server (http://localhost:3030/api/mcp) - Creates
.env.localwith the bot account's credentials the server authenticates with - Adds
mcp-startandmcp-updatenpm scripts topackage.json
Local MCP is only set up when a bot account exists — in the interactive flow, declining the bot skips it.
Starting the Local MCP Server
bash
cd my-project
npm install
npm run mcp-startThe npm install step will automatically install all dependencies including @hailer/mcp and run the postinstall script to copy .claude/ and .opencode/ configuration.
Then open a new terminal and start your TUI to interact with your workspace through the MCP server.
Updating the Local MCP Server
bash
npm run mcp-updateNote: After updating, restart the MCP server and any running TUI agents that depend on it.
Remote MCP (user API key authentication)
When --user-api-key is provided, MCP is configured to connect to a remote server instead of running locally.
When enabled, the initialization:
- Creates
.mcp.json— annpx mcp-remoteclient pointing at<mcp-url>/api/mcp?apiKey=<your-key>(git-ignored) - Prompts for the remote MCP server URL (or uses
--mcp-urlflag) - No
.env.localor local MCP scripts are created
Getting Started with Remote MCP
bash
cd my-project
npm installThen start your TUI — it will connect to the remote MCP server automatically. No need to start anything locally.
The .mcp.json file contains the remote server URL with your API key. It is git-ignored for security. If the URL or key changes, update .mcp.json and restart your TUI.
Next Steps
After initialization:
Navigate to your project:
bashcd my-project npm installPull your workspace configuration:
bashnpm run pull(Optional) If you set up a local MCP server, start it:
bashnpm run mcp-startFor remote MCP, just start your TUI — it connects automatically.
Start developing with type-safe workflow definitions!
API URL Selection
During initialization, you'll be prompted to select an API URL:
- Hailer cloud (
https://api.hailer.com) - Production Hailer API (default) - Hailer local (
https://api.hailer.local.gd/) - Local development environment
The selected API URL is saved to config.json and used for all subsequent SDK commands.
For local development:
- The SDK automatically detects local environments (URL contains "local")
- Self-signed SSL certificates are automatically accepted for local APIs
- Useful for testing changes before deploying to production
User API Key Authentication
As an alternative to email/password authentication, you can use a user API key:
bash
hailer-sdk init --user-api-key "your-api-key-here"
# With remote MCP server:
hailer-sdk init --user-api-key "your-api-key-here" --mcp-url "https://mcp.example.com"Note:
--mcp-urlrequires--user-api-key. It specifies the remote MCP server URL to connect to.
How it Works
When --user-api-key is provided:
- Email and password prompts are skipped
- Authentication uses the user API key
- You can still create a bot account (recommended for MCP server)
MCP Server Requirement
- Local MCP requires a bot account — its bot credentials are written to
.env.localand used to authenticate. In the interactive flow, declining the bot skips local MCP setup. - Remote MCP is configured when you authenticate with
--user-api-key(optionally with--mcp-url); no local server runs. - The
--mcp/--no-mcpflags force MCP setup on or off non-interactively.
Generated Files
The .env and config.json files are configured based on your authentication method:
With email/password (or bot account):
# .env
HAILER_PASSWORD="your-password"
# config.json
{
"email": "your-email@example.com",
"password": "HAILER_PASSWORD",
"workspaceId": "...",
"apiUrl": "..."
}With user API key only (no bot):
# .env
HAILER_USER_API_KEY="your-api-key"
# config.json
{
"workspaceId": "...",
"apiUrl": "...",
"userApiKey": "HAILER_USER_API_KEY"
}Notes
- The
.envfile contains your credentials - never commit this to version control - The
.env.localfile (local MCP only) contains MCP server credentials - git-ignored - The
.mcp.jsonfile is always git-ignored (it can contain an API key) - The generated
.gitignoreexcludes.env,.env.local,.mcp.json,.claude/, and.opencode/ - Type definitions are copied to your project for IDE support
- Bot credentials are displayed only once during initialization - save them securely!
- The MCP server is installed as an npm package (
@hailer/mcp) in yournode_modules/ - The
apiUrlfield inconfig.jsondetermines which API all commands will use
Troubleshooting
MCP Server Setup Fails
If the MCP server setup fails during initialization:
- Check your network connection (npm package must be downloaded)
- Ensure you have Node.js 18+ installed
- Verify that
@hailer/mcppackage is available on npm - Try running
npm installmanually after initialization to trigger thepostinstallscript
Bot Account Creation Fails
If bot account creation fails:
- You can continue with your personal credentials
- The project will still be initialized successfully
- You can manually create a bot account later through the Hailer UI
Workspace Creation Fails
If creating a new workspace fails:
- Select an existing workspace instead
- Check your account permissions
- Verify your network connection