@blocksweb/cli
v1.4.0
Published
Command-line interface for BlocksWeb CMS - Create, manage, and deploy pages via API with MCP support
Maintainers
Readme
BlocksWeb CLI
A command-line interface for managing BlocksWeb CMS workspaces, pages, and collections.
Features
- 🔐 Browser Authentication: One-time authentication via browser or API key
- 📄 Page Management: Create, update, delete, and list pages
- 📦 Collection Management: Manage data collections and schemas
- 🏢 Workspace Info: View workspace details and usage statistics
- 🎨 Interactive Mode: Guided prompts for complex operations
- 📱 JSON Support: Full JSON input/output support for automation
Installation
# Use with npx (recommended - no installation required)
npx @blocksweb/cli --help
# Or install globally
npm install -g @blocksweb/cli
# Or install in your project
npm install @blocksweb/cliQuick Start
Set Environment Variable: Add your API key to your project
export BLOCKSWEB_API_KEY="your-api-key-here"List Pages: See all pages in your workspace
npx @blocksweb/cli pages listCreate a Page: Add a new page to your site
npx @blocksweb/cli create page "Homepage"View Workspace: Check your workspace information
npx @blocksweb/cli workspace info
Authentication
The CLI supports two authentication methods:
Environment Variable (Recommended)
export BLOCKSWEB_API_KEY="your-api-key-here"
npx @blocksweb/cli auth statusThis uses your project's API key directly from the environment.
Check Authentication Status
npx @blocksweb/cli auth statusLogout
npx @blocksweb/cli auth logoutCommands
Pages
List Pages
# List all pages
blocksweb pages list
# Search pages
blocksweb pages list --search "about"
# JSON output
blocksweb pages list --jsonCreate Page
# Basic page creation
blocksweb create page "About Us"
# With custom slug and status
blocksweb create page "About Us" --slug about --status published
# With JSON content
blocksweb create page "Homepage" --content '{"title": "Welcome", "sections": []}'
# Interactive mode
blocksweb create page "Contact" --interactiveUpdate Page
# Update page by name, slug, or ID
blocksweb update page homepage --name "Home Page"
# Update status
blocksweb update page homepage --status published
# Update content
blocksweb update page homepage --content '{"title": "New Title"}'
# Interactive mode
blocksweb update page homepage --interactiveDelete Page
# Delete with confirmation
blocksweb pages delete homepage
# Force delete without confirmation
blocksweb pages delete homepage --forceShow Page Details
# Human-readable format
blocksweb pages show homepage
# JSON format
blocksweb pages show homepage --jsonCollections
List Collections
# List all collections
blocksweb collections list
# Search collections
blocksweb collections list --search "products"
# JSON output
blocksweb collections list --jsonCreate Collection
# Basic collection
blocksweb collections create "Products"
# With schema
blocksweb collections create "Products" --schema '{"fields": [{"name": "title", "type": "text"}]}'
# Interactive mode
blocksweb collections create "Products" --interactiveUpdate Collection
# Update collection name
blocksweb collections update products --name "Product Catalog"
# Update schema
blocksweb collections update products --schema '{"fields": [{"name": "title", "type": "text"}, {"name": "price", "type": "number"}]}'
# Interactive mode
blocksweb collections update products --interactiveDelete Collection
# Delete with confirmation
blocksweb collections delete products
# Force delete
blocksweb collections delete products --forceWorkspace
Show Workspace Info
# Human-readable format
blocksweb workspace info
# JSON format
blocksweb workspace info --jsonList Workspace Collections
# List collections in workspace
blocksweb workspace collections
# JSON format
blocksweb workspace collections --jsonMCP Server Integration
The CLI can automatically configure the BlocksWeb MCP (Model Context Protocol) server for Claude Code, enabling you to interact with your BlocksWeb CMS directly through natural language commands in Claude Code.
Install MCP Server
# Navigate to your project directory
cd /path/to/your/project
# Install MCP server (creates project-level configuration)
blocksweb mcp install
# Alternative command
blocksweb mcp setupThis command will:
- Create
.claude/config.jsonin your project directory (project-level configuration) - Create
.claude/config.example.jsonfor team members to copy - Create
.claude/README.mdwith setup instructions - Automatically update
.gitignoreto excludeconfig.json(keeps your API key safe) - Configure the MCP server to use
@blocksweb/mcp-server@latestfor automatic updates - Use your API key from CLI settings or environment variable
Check MCP Status
# Check if MCP server is configured
blocksweb mcp statusRemove MCP Server
# Remove MCP server configuration
blocksweb mcp remove
# Alternative command
blocksweb mcp uninstallNote: After installing or removing the MCP server, you need to restart Claude Code for the changes to take effect.
What is MCP?
MCP (Model Context Protocol) allows Claude Code to interact with BlocksWeb CMS directly. Once configured, you can:
- Create and manage pages through natural language commands
- Query and update collections
- Manage workspace settings
- All from within your Claude Code conversation
Team Collaboration
The project-level configuration enables better team collaboration:
- Share the setup: Commit
.claude/config.example.jsonand.claude/README.mdto git - Keep secrets safe:
.claude/config.jsonis automatically added to.gitignore - Easy onboarding: Team members copy
config.example.jsontoconfig.jsonand add their API key - Per-project setup: Each project can have its own MCP configuration
Examples
Create a Blog Post Page
blocksweb create page "My First Blog Post" \\
--slug "my-first-blog-post" \\
--status draft \\
--content '{
"title": "My First Blog Post",
"content": "This is the content of my first blog post",
"author": "John Doe",
"publishedAt": "2023-01-01"
}'Update Page to Published
blocksweb update page "my-first-blog-post" --status publishedCreate a Product Collection
blocksweb collections create "Products" --schema '{
"fields": [
{"name": "title", "type": "text", "required": true},
{"name": "description", "type": "textarea", "required": false},
{"name": "price", "type": "number", "required": true},
{"name": "image", "type": "image", "required": false}
]
}'Batch Operations with JSON
# Get all pages as JSON and process with jq
blocksweb pages list --json | jq '.[] | select(.status == "draft") | .name'
# Create multiple pages from a JSON file
cat pages.json | jq -r '.[] | "blocksweb create page \\"\\(.name)\\" --slug \\(.slug) --status \\(.status)"' | shSetting up Claude Code Integration
# Step 1: Authenticate with BlocksWeb
blocksweb auth set-key your-api-key-here
# Step 2: Install MCP server for Claude Code
blocksweb mcp install
# Step 3: Restart Claude Code
# Now you can interact with BlocksWeb directly in Claude Code!
# Example: "Create a new page called About Us with a hero section"Configuration
The CLI stores configuration in ~/.blocksweb/ directory:
- Authentication tokens
- API keys
- Workspace preferences
API Integration
The CLI directly communicates with the BlocksWeb API at https://cloud.blocksweb.nl/api. All operations are performed via RESTful API calls with proper authentication headers.
Error Handling
The CLI provides detailed error messages and suggestions:
- Authentication errors guide you to re-authenticate
- Network errors show connection status
- API errors display server response messages
- Validation errors highlight specific issues
Development
# Clone the repository
git clone https://github.com/blocksweb/cli.git
# Install dependencies
npm install
# Build
npm run build
# Run locally
npm run start -- --helpSupport
- Documentation: https://docs.blocksweb.com
- Issues: https://github.com/blocksweb/cli/issues
- Support: [email protected]
License
MIT License - see LICENSE file for details.
