Overview

ntcli uses environment variables to configure various aspects of its behavior, from API endpoints to authentication settings. Most variables have sensible defaults and are managed automatically.

Authentication Variables

OAuth Configuration (Optional)

These variables are automatically configured for the production environment and rarely need to be modified:
CLERK_OAUTH_CLIENT_ID
string
Clerk OAuth client ID for authenticationDefault: Automatically configured for production
When to modify: Custom Clerk environment only (advanced use cases)
CLERK_DOMAIN
string
Clerk domain for OAuth authenticationDefault: Automatically configured for production
When to modify: Custom Clerk environment only (advanced use cases)

API Configuration

Endpoint Settings

NTCLI_API_URL
string
Base URL for the NimbleTools APIDefault: https://mcp.nimbletools.ai
Example: https://api.nimbletools.dev (for development)
NTCLI_DEFAULT_PORT
number
Default port for OAuth callback serverDefault: 41247
Range: 1024-65535 (unprivileged ports)

Debug and Development

NTCLI_DEBUG
boolean
Enable detailed HTTP debugging outputDefault: false
Values: 1, true, yes (to enable)
NODE_ENV
string
Node.js environment settingDefault: production
Values: development, staging, production
NODE_TLS_REJECT_UNAUTHORIZED
string
Disable TLS certificate validation (development only)Default: 1 (enabled)
Values: 0 (disable validation), 1 (enable validation)
Use case: Local development with self-signed certificates

Usage Examples

Development Environment

Set up ntcli for local development:
# Development API endpoint
export NTCLI_API_URL=https://dev-api.nimbletools.ai

# Enable debug output
export NTCLI_DEBUG=1

# Use alternative callback port
export NTCLI_DEFAULT_PORT=3000

# Development environment
export NODE_ENV=development

# Disable TLS validation for self-signed certificates (development only)
export NODE_TLS_REJECT_UNAUTHORIZED=0

CI/CD Environment

Configure ntcli for automated deployments:
# Production API (default)
export NTCLI_API_URL=https://mcp.nimbletools.ai

# Disable debug output (default)
export NTCLI_DEBUG=0

# Production environment
export NODE_ENV=production

# Use standard callback port (default)
export NTCLI_DEFAULT_PORT=41247

Corporate/Enterprise

Configure for enterprise deployments:
# Custom enterprise endpoint
export NTCLI_API_URL=https://ntcli.company.com

# Custom OAuth settings (if needed)
export CLERK_DOMAIN=company-auth.clerk.accounts.dev
export CLERK_OAUTH_CLIENT_ID=custom_client_id

# Corporate callback port
export NTCLI_DEFAULT_PORT=8080

Setting Environment Variables

Temporary (Current Session)

export NTCLI_API_URL=https://dev-api.nimbletools.ai
export NTCLI_DEBUG=1
ntcli auth login

Persistent (Shell Profile)

Add to ~/.bashrc or ~/.bash_profile:
# NimbleTools CLI Configuration
export NTCLI_API_URL=https://mcp.nimbletools.ai
export NTCLI_DEFAULT_PORT=41247

Using .env Files

Create a .env file in your project directory:
# .env file
NTCLI_API_URL=https://mcp.nimbletools.ai
NTCLI_DEBUG=0
NTCLI_DEFAULT_PORT=41247
NODE_ENV=production
Then load it before running ntcli:
# Load .env file and run command
export $(cat .env | xargs) && ntcli auth login

Environment Variable Precedence

Variables are resolved in the following order (highest to lowest priority):
  1. Command-line flags (e.g., --port 3000)
  2. Environment variables (e.g., NTCLI_DEFAULT_PORT=3000)
  3. Configuration files (future feature)
  4. Built-in defaults

Example Priority Resolution

# Environment variable sets default
export NTCLI_DEFAULT_PORT=8080

# Command-line flag overrides environment variable
ntcli auth login --port 3000
# Uses port 3000, not 8080

Debug Output Control

Enable Debug Mode

export NTCLI_DEBUG=1
ntcli auth login --verbose
Debug mode shows:
  • HTTP request/response details
  • Authentication flow steps
  • API endpoint resolutions
  • Token exchange information
  • Error stack traces

Debug Output Example

$ NTCLI_DEBUG=1 ntcli auth login
[DEBUG] Starting OAuth flow...
[DEBUG] Callback server starting on port 41247
[DEBUG] Opening browser to: https://clerk.nimbletools.ai/oauth/authorize?...
[DEBUG] Received callback with code: abc123...
[DEBUG] Exchanging code for tokens...
[DEBUG] Authentication successful

Validation and Troubleshooting

Check Current Configuration

# View all environment variables
env | grep NTCLI

# Check specific variables
echo $NTCLI_API_URL
echo $NTCLI_DEFAULT_PORT
echo $NTCLI_DEBUG

Test Configuration

# Test API connectivity
ntcli health

# Test authentication with debug
NTCLI_DEBUG=1 ntcli auth status

# Test with custom endpoint
NTCLI_API_URL=https://dev-api.nimbletools.ai ntcli health

Common Issues

Security Considerations

Sensitive Variables

Some environment variables contain sensitive information:
VariableSensitivityRecommendation
CLERK_OAUTH_CLIENT_IDMediumDon’t share publicly
CLERK_DOMAINLowSafe to share
NTCLI_API_URLLowSafe to share
NTCLI_DEBUGLowDisable in production

Best Practices

Development

Use separate OAuth clients and API endpoints for development

Production

Disable debug mode and use production OAuth settings

CI/CD

Store sensitive variables in secure CI/CD secret management

Teams

Document environment setup in team onboarding guides