CLI Introduction
Overview
The NitroStack CLI is a powerful command-line tool for creating, developing, and building MCP servers with v3.0's decorator-based architecture.
Features
- Quick Initialization - Create new projects in seconds
- Hot Reload - Development mode with automatic reloading
- 🎨 Studio Integration - Visual testing environment
- 🔨 Code Generation - Generate modules, tools, types, and more
- 📦 Production Builds - Optimize for deployment
- 🎯 Templates - 5 pre-built official templates (
typescript-starter,typescript-enterprise-search,typescript-code-mode,typescript-pizzaz,typescript-oauth)
Commands
| Command | Description |
|---|---|
init | Create a new NitroStack project |
dev | Start development server with hot reload |
build | Build project for production |
start | Start production MCP server |
generate | Generate code (types, modules, tools, guards, health, etc.) |
upgrade | Upgrade @nitrostack/core and refresh agent skills |
install | Install dependencies in root and widget packages |
cursor | Integrate MCP server with Cursor IDE (command, legacy-sse, streamable-http) |
pack | Create optimized production bundle excluding secrets |
Installation
Global Installation
Bash
npm install -g @nitrostack/cli
Verify installation:
Bash
nitrostack-cli --version
Using npx
No installation required:
Bash
npx @nitrostack/cli init my-project
Quick Start
Bash
# Create a new project
nitrostack-cli init my-server --template typescript-oauth
# Navigate to project
cd my-server
# Install dependencies
npm install
# Start development
nitrostack-cli dev
Studio opens at http://localhost:3000 automatically!
Command Reference
nitrostack-cli init
Create a new NitroStack project.
Bash
nitrostack-cli init <project-name> [options]
Options:
--template <name>- Template to use (typescript-starter,typescript-pizzaz,typescript-oauth)
Example:
Bash
nitrostack-cli init travel-agent --template typescript-oauth
nitrostack-cli dev
Start development server with hot reload and Studio.
Bash
nitrostack-cli dev [options]
Options:
--port <number>- Studio port (default: 3000)
Example:
Bash
nitrostack-cli dev --port 8080
nitrostack-cli build
Build project for production.
Bash
nitrostack-cli build
Outputs to dist/ directory.
nitrostack-cli generate
Generate code from templates.
Bash
nitrostack-cli generate <type> [name] [options]
Types:
types- Generate TypeScript types from toolsmodule- Generate a new moduletool- Generate a tool definitionresource- Generate a resource definitionprompt- Generate a prompt definitionguard- Generate an authentication guardmiddleware- Generate middlewareinterceptor- Generate an interceptorpipe- Generate a pipefilter- Generate an exception filterservice- Generate a service
Examples:
Bash
# Generate types
nitrostack-cli generate types
# Generate module
nitrostack-cli generate module payments
# Generate tool
nitrostack-cli generate tool create-payment --module payments
# Generate guard
nitrostack-cli generate guard admin
Configuration
NitroStack applications and CLI behaviors are configured via:
- Command-line flags - (e.g.
--port <port>for widget dev server) - Environment variables - Standard
.envfiles loaded viadotenvorConfigModule.forRoot() - Project metadata - Standard
package.jsonscripts and dependencies
Environment Variables
Bash
# .env
PORT=3000
WIDGET_PORT=3001
LOG_LEVEL=info
Development Workflow
- Initialize - Create project with
init - Develop - Use
devfor hot reload + Studio - Generate - Add features with
generate - Test - Test in Studio with AI chat
- Build - Production build with
build - Deploy - Deploy
dist/to server
Best Practices
1. Use Templates
Start with a template for best practices:
Bash
nitrostack-cli init my-project --template typescript-oauth
2. Generate Code
Use generators instead of manual coding:
Bash
nitrostack-cli generate module users
nitrostack-cli generate tool get-user --module users
3. Type Generation
Regenerate types after tool changes:
Bash
nitrostack-cli generate types
4. Test in Studio
Always test in Studio before deployment:
Bash
nitrostack-cli dev
# Test with AI chat
# Test manual execution
Troubleshooting
Command Not Found
Bash
# If installed globally
npm install -g nitrostack
# Or use npx
npx nitrostack --version
Port Already in Use
Bash
# Use different port
nitrostack-cli dev --port 8080
Permission Errors
Bash
# Fix npm permissions
sudo chown -R $USER /usr/local/lib/node_modules
Next Steps
CLI Version: 3.0.0