NitroStack CLI Reference - For AI Code Editors
Comprehensive CLI reference for AI agents working with NitroStack v3.0
Installation
# Global install (recommended)
npm install -g @nitrostack/cli
# Or run on-demand with npx
npx @nitrostack/cli <command>
Commands Overview
nitrostack init <project-name> [options] # Create new project
nitrostack dev [--port <number>] # Start development mode
nitrostack build [--output <path>] # Build for production
nitrostack start [--port <number>] # Start production MCP server
nitrostack generate <type> [name] [options] # Generate code boilerplate
nitrostack upgrade [--dry-run] [--latest] # Upgrade packages & skills
nitrostack install [--skip-widgets] # Install root and widget deps
nitrostack cursor [options] # Configure Cursor IDE MCP integration
nitrostack pack [options] # Package production zip bundle
nitrostack --version # Show version
nitrostack --help # Show help
1. Initialize Project
# Basic initialization (uses typescript-starter)
npx @nitrostack/cli init my-project
# Using preset shorthand:
npx @nitrostack/cli init my-project --preset starter
npx @nitrostack/cli init my-enterprise --preset enterprise-search
npx @nitrostack/cli init my-codemode --preset code-mode
npx @nitrostack/cli init my-pizzaz --preset pizzaz
npx @nitrostack/cli init my-flights --preset oauth
# Or with full template name:
npx @nitrostack/cli init my-enterprise --template typescript-enterprise-search
Available Templates & Presets
-
typescript-starter(Preset:starter, Default)- Calculator tool, resource, and prompt examples
- Interactive UI widget
- Health checks and DI configuration
- Perfect for quick starts and learning basics
-
typescript-enterprise-search(Preset:enterprise-search)- Progressive tool discovery with
BM25SearchTransform @Controllerdomain namespacing (finance, inventory, support)- Reduces model prompt token consumption by up to 98%
alwaysVisiblebypass for bootstrap tools
- Progressive tool discovery with
-
typescript-code-mode(Preset:code-mode)- Sandboxed QuickJS WebAssembly script execution
- Dedicated worker thread pool with memory and timeout caps
- Exposes
search,get_schema, andexecutemeta-tools - Batch data pipeline scripts in a single round-trip
-
typescript-pizzaz(Preset:pizzaz, Rich UI & Widgets)- Pizza shop finder with interactive Mapbox map
- Multi-widget dashboard integration
- State and theme synchronization
- Next.js and Tailwind widget architecture
-
typescript-oauth(Preset:oauth, Production Authentication)- OAuth 2.1 authentication flow with PKCE
- Duffel API flight booking tools
- Token introspection and scope guards
- Enterprise security architecture
What init Does
- Copies selected template files
- Installs npm dependencies (MCP server)
- Installs widget dependencies (
src/widgets/) - Creates
.envfrom.env.example - Copies agent skills (
SKILL.md) to.cursor/skills,.claude/skills,.gemini/skills, etc.
After Init
cd my-project
# Start development (MCP server + widget dev server)
npm run dev
2. Development Mode
# Start development (MCP server + widget dev server)
nitrostack-cli dev
# Custom port for widget development server (default: 3001)
nitrostack-cli dev --port 3005
What It Starts
-
MCP Server (stdio mode)
- Communicates via stdin/stdout
- Follows MCP protocol spec
- Hot reload on code changes
-
Studio (port 3000, or custom)
- Visual development interface
- Test tools manually
- AI chat (OpenAI/Gemini)
- Widget preview
- Resources browser
- Prompts testing
- Health checks dashboard
- OAuth 2.1 config
- Connection monitoring
-
Widget Dev Server (port 3001)
- Next.js dev server
- Hot module replacement
- Serves UI widgets
- Fast refresh
Studio Features
| Tab | Purpose |
|---|---|
| Tools | Execute tools, see widget previews, examples |
| AI Chat | Chat with LLM using your tools |
| Resources | Browse resources, view UI widgets |
| Prompts | Test prompt templates |
| Health | Monitor health checks |
| OAuth 2.1 | Configure OAuth endpoints |
| Ping | Test MCP connection |
URLs
- Studio UI:
http://localhost:3000 - Widget Dev:
http://localhost:3001 - MCP Server: stdio (no HTTP)
Hot Reload
Changes auto-reload:
- TypeScript files (
src/**/*.ts) - Widget files (
src/widgets/app/**/*) - No manual restart needed
3. Build Project
nitrostack-cli build
Build Process
The nitrostack-cli build command:
-
Builds Widgets First (if present)
- Input:
src/widgets/ - Output:
src/widgets/.next/ - Production optimized
- Static assets bundled
- Input:
-
Compiles TypeScript
- Input:
src/**/*.ts - Output:
dist/**/*.js - ES modules format
- Source maps included
- Input:
-
Auto-Detects Project Structure
- Checks for
src/widgets/package.json - Installs widget dependencies if needed
- Handles everything automatically
- Checks for
Output Structure
dist/
├── index.js # Entry point
├── app.module.js
├── modules/
│ ├── auth/
│ ├── products/
│ └── ...
└── ... (all compiled code)
src/widgets/.next/ # Built widgets
Run Production Build
# After build - use npm script (recommended)
npm start
# Or run directly
node dist/index.js
# Or use CLI
nitrostack-cli start
The nitrostack-cli start command:
- Runs the compiled
dist/index.js - Starts widget production server (if built)
- Sets
NODE_ENV=production - Handles all process orchestration
4. Generate Code
Generate Module
nitrostack-cli generate module payments
Creates:
src/modules/payments/
├── payments.module.ts # @Module definition
├── payments.tools.ts # @Tool definitions
├── payments.resources.ts # @Resource definitions
├── payments.prompts.ts # @Prompt definitions
└── payments.service.ts # @Injectable service
Generated module includes:
- Boilerplate decorator setup
- Example tool with Zod schema
- Example resource
- Example prompt
- Injectable service with DI
- Ready to import in
app.module.ts
Generate Tools
nitrostack-cli generate tools process-payment --module payments
- Adds tool to
src/modules/payments/payments.tools.ts - Includes:
@Tooldecorator- Zod input schema
- Example request/response
@Widgetplaceholder- Execution context
Generate Resources
nitrostack-cli generate resources payment-schema --module payments
- Adds resource to
src/modules/payments/payments.resources.ts - Includes URI pattern, mime type, examples
Generate Prompts
nitrostack-cli generate prompts payment-help --module payments
- Adds prompt to
src/modules/payments/payments.prompts.ts - Includes arguments, message template
Generate Guard
nitrostack-cli generate guard admin
Creates src/guards/admin.guard.ts:
@Injectable()
export class AdminGuard implements Guard {
async canActivate(context: ExecutionContext): Promise<boolean> {
// Your authorization logic
}
}
Usage:
@Tool({ name: 'admin_tool' })
@UseGuards(AdminGuard)
async adminTool(input: any, ctx: ExecutionContext) {}
Generate Middleware
nitrostack-cli generate middleware logging
Creates src/middleware/logging.middleware.ts:
@Middleware()
export class LoggingMiddleware implements MiddlewareInterface {
async use(context: ExecutionContext, next: () => Promise<any>) {
// Before
const result = await next();
// After
return result;
}
}
Generate Interceptor
nitrostack-cli generate interceptor transform
Creates src/interceptors/transform.interceptor.ts:
@Interceptor()
export class TransformInterceptor implements InterceptorInterface {
async intercept(context: ExecutionContext, next: () => Promise<any>) {
const result = await next();
return { success: true, data: result };
}
}
Generate Pipe
nitrostack-cli generate pipe validation
Creates src/pipes/validation.pipe.ts:
@Pipe()
export class ValidationPipe implements PipeInterface {
async transform(value: any, metadata: any): Promise<any> {
// Transform/validate value
return value;
}
}
Generate Types
# Generate TypeScript types from tool schemas
nitrostack-cli generate types
# Custom output path
nitrostack-cli generate types --output src/widgets/types/generated.ts
What It Does:
- Scans all
*.tools.tsfiles - Extracts Zod schemas from
@Tooldecorators - Converts to TypeScript interfaces
- Outputs to
src/widgets/types/tool-data.ts(default)
Example Input (tool):
@Tool({
name: 'get_product',
inputSchema: z.object({
product_id: z.string()
})
})
async getProduct(input: any) {
return { id: input.product_id, name: 'Product', price: 99 };
}
Example Output (generated types):
// Auto-generated by NitroStack CLI
export interface GetProductInput {
product_id: string;
}
export interface GetProductOutput {
id: string;
name: string;
price: number;
}
Usage in Widgets:
import { GetProductOutput } from '../../types/tool-data';
export default function ProductCard({ data }: { data: GetProductOutput }) {
return <div>{data.name} - ${data.price}</div>;
}
When to Run:
- After adding new tools
- After modifying tool schemas
- Before building widgets
- As part of CI/CD pipeline
5. Cursor IDE Integration (nitrostack cursor)
Integrate your MCP server directly into Cursor IDE (.cursor/mcp.json or ~/.cursor/mcp.json):
# Configure local .cursor/mcp.json (default: command mode)
nitrostack cursor
# Configure with legacy SSE endpoint
nitrostack cursor --type legacy-sse --port 3000
# Configure with modern MCP 2026-07-28 Streamable HTTP endpoint
nitrostack cursor --type streamable-http --url http://localhost:3000/mcp
# Global configuration with overwrite
nitrostack cursor --global --force
Options:
-g, --global: Write to user home~/.cursor/mcp.json-l, --local: Write to.cursor/mcp.json(default)-t, --type <type>:command,legacy-sse, orstreamable-http-u, --url <url>: Explicit server URL-p, --port <port>: Port for HTTP URL generation (default: 3000)--force: Overwrite existing configuration key
6. Project Packaging (nitrostack pack)
Create a clean, production-ready .zip deployment archive excluding build artifacts, local caches, and secret .env files:
# Create deployment bundle (e.g. my-project.zip in root)
nitrostack pack
# Preview files that would be included/excluded
nitrostack pack --dry-run
# Include environment variables if deploying to secure cloud workers
nitrostack pack --include-env
# Custom output zip name
nitrostack pack --output deploy-v1.0.0.zip
Default Exclusions:
node_modules/,.git/,.next/,dist/.env,.env.local,.env.*.local(unless--include-envis passed)- Canonical
.gitignorerules automatically synchronized
Configuration
Application Configuration (ConfigModule & .env)
NitroStack applications configure server settings, DI parameters, and runtime variables using @nitrostack/core's ConfigModule and environment variables (.env). NitroStack does not use a nitrostack.config.ts configuration file.
import { McpApp, Module, ConfigModule } from '@nitrostack/core';
@McpApp({
name: 'my-server',
version: '1.0.0',
description: 'My MCP server',
module: AppModule
})
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
envFilePath: '.env',
}),
]
})
export class AppModule {}
Environment Variables (.env)
# Node Environment
NODE_ENV=development
# Server Configuration
PORT=3000
MCP_SERVER_PORT=3000
WIDGET_PORT=3001
LOG_LEVEL=info
# OAuth 2.1 (if using typescript-oauth template)
OAUTH_CLIENT_ID=your-client-id
OAUTH_CLIENT_SECRET=your-client-secret
OAUTH_REDIRECT_URI=http://localhost:3000/callback
# Gemini API (for Studio chat)
GEMINI_API_KEY=your-gemini-key
Common Workflows
1. Create New Project (Starter Template)
# Install CLI
npm install -g @nitrostack/cli
# Initialize project
npx @nitrostack/cli init my-calculator --template typescript-starter
cd my-calculator
# Start development
npm run dev
# Open Studio
# http://localhost:3000
2. Create New Project (OAuth 2.1 Template)
# Initialize flight booking template
npx @nitrostack/cli init flight-booking --preset oauth
cd flight-booking
# Start development
npm run dev
3. Create Enterprise Search Project (BM25 Progressive Discovery)
# Initialize enterprise search template
npx @nitrostack/cli init enterprise-portal --preset enterprise-search
cd enterprise-portal
# Start development
npm run dev
4. Create Sandboxed Execution Project (Code Mode)
# Initialize QuickJS code mode template
npx @nitrostack/cli init data-engine --preset code-mode
cd data-engine
# Start development
npm run dev
5. Add New Feature Module
# Generate module
nitrostack-cli generate module payments
# Add to app.module.ts imports
# imports: [ConfigModule.forRoot(), PaymentsModule]
# Generate tools
nitrostack-cli generate tools create-payment --module payments
nitrostack-cli generate tools get-payment --module payments
# Generate types for widgets
nitrostack-cli generate types
# Create widget
mkdir -p src/widgets/app/payment-success
# Create page.tsx in that directory
# Test in Studio
npm run dev
4. Development Cycle
# Start dev server (auto-detects and builds everything)
npm run dev
# The CLI automatically:
# - Installs dependencies (if needed)
# - Builds widgets (on first run)
# - Starts TypeScript watch mode
# - Starts Studio
# - Starts widget dev server
# - Hot reloads everything
# Edit code (auto-reloads)
# - Edit src/modules/**/*.ts (MCP server hot reloads)
# - Edit src/widgets/app/**/* (Widget dev server hot reloads)
# Test in Studio
# - Execute tools manually
# - Test with AI chat
# - Preview widgets
# Add widget dependencies
npm run widget add <package-name>
# Generate types for widgets
nitrostack-cli generate types
# Build for production
npm run build
# Test production build
npm start
5. Deploy to Production
# Build project
nitrostack-cli build
# Copy to server
scp -r dist/ user@server:/app/
scp -r src/widgets/.next/ user@server:/app/widgets/
scp package.json user@server:/app/
scp .env.production user@server:/app/.env
# On server
cd /app
npm install --production
node dist/index.js
Troubleshooting
CLI Not Found
# Install globally
npm install -g nitrostack
# Or use npx
npx nitrostack-cli init my-project
Port Already in Use
# Use custom port
nitrostack-cli dev --port 3002
# Or kill process on port
lsof -ti:3000 | xargs kill -9
lsof -ti:3001 | xargs kill -9
Build Errors
# Clean and rebuild
rm -rf dist
rm -rf src/widgets/.next
npm run build
# Check TypeScript errors
npx tsc --noEmit
Module Not Found: nitrostack
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install
Widgets Not Loading
# The CLI handles widgets automatically, but if you need to debug:
# Install widget dependencies
npm run widget install
# Check widget dev server
curl http://localhost:3001
# Or restart dev mode (rebuilds everything)
npm run dev
Studio Not Connecting
# Check MCP server is running
ps aux | grep node
# Check logs
tail -f logs/server.log
# Restart
npm run dev
Quick Reference Card
Commands
| Command | Description |
|---|---|
nitrostack init <name> | Create new project |
nitrostack init <name> --preset <p> | Create with preset (starter, enterprise-search, code-mode, pizzaz, oauth) |
nitrostack init <name> --template <t> | Create with template directory name |
nitrostack dev | Start dev mode (MCP server + widget dev server) |
nitrostack dev --port <n> | Start with custom widget port (default: 3001) |
nitrostack build | Build MCP server + widgets for production |
nitrostack start | Start production server (default: 3000) |
nitrostack generate <type> <name> | Generate code (module, tools, resources, prompts, guard, middleware, pipe, health, etc.) |
nitrostack upgrade | Upgrade @nitrostack/core and refresh agent skills |
nitrostack install | Install root and widget dependencies |
nitrostack cursor | Configure Cursor IDE MCP integration (command, legacy-sse, streamable-http) |
nitrostack pack | Bundle production .zip deployment archive |
nitrostack --version | Show version |
nitrostack --help | Show help |
Project Scripts
| Script | Description |
|---|---|
npm run dev | Start development (MCP server + widgets, auto-reload) |
npm run build | Build MCP server + widgets for production |
npm start | Run production server |
npm run widget <cmd> | Run npm command in widgets directory |
Studio URLs
| URL | Purpose |
|---|---|
http://localhost:3000 | Studio UI |
http://localhost:3000/chat | AI Chat |
http://localhost:3001 | Widget dev server |
Key Concepts for AI Agents
1. Templates & Presets
- typescript-starter (
starter): Simple calculator, Next.js widget, health checks - typescript-enterprise-search (
enterprise-search): Progressive BM25 tool search, @Controller namespacing - typescript-code-mode (
code-mode): QuickJS WebAssembly sandboxing, worker pool script orchestration - typescript-pizzaz (
pizzaz): Rich interactive map, multi-widget dashboard - typescript-oauth (
oauth): OAuth 2.1 PKCE, Duffel flight booking tools
2. Development Flow
init→dev→ test in Studio →build→start(orpackfor deployment)
3. Code Generation
- Generate module first (
generate module <name>) - Then generate tools/resources/prompts (
generate tools <name> --module <name>) - Always run
generate typesafter schema changes
4. Studio
- Test tools interactively
- Use chat to verify model integrations
- Preview widgets with live simulated tool data
5. Widget Development
- Widgets live in
src/widgets/app/ - Link with
@Widget('widget-name') - Generate types for type safety
- Hot reload enabled
That's the complete NitroStack CLI reference!
Use nitrostack --help for more details or check /docs for SDK documentation.