CLI & MCP Reference
SWS provides a unified Rust CLI (sws) and local stdio Model Context Protocol (MCP) server for deterministic builds, validation, export, and AI-assisted editing.
Release rollout note
The pure-Rust sws-cli crate ships as part of the v0.1.0 core engine milestone. While working from the Phase 0/1 workspace before crates/sws-cli merges to main, equivalent local scripts are available via npm run render, npm run check:headers, npm run lint:abc, and npm run sites:build.
sws Commands
| Command | Description |
|---|---|
sws init <dir> [--pack <name>] |
Scaffold a starter SWS site project directory, optionally preconfigured for a vertical pack such as hospitality. |
sws build <input> <outdir> [--check] |
Compile a SiteDocument IR or pack manifest into deterministic static HTML, CSS, JSON-LD, sitemap.xml, robots.txt, and _headers. Pass --check in CI to verify files byte-for-byte without writing. |
sws check <input> [--headers-file <path>] [--json] |
Validate IR/pack schemas, run compiler WCAG 2.2 AA and plugin lint passes, and optionally check _headers parity against Rust SECURITY_HEADERS. |
sws export <input> <outdir> |
Export a deployable Cloudflare Workers + Static Assets + D1 bundle (public/, wrangler.jsonc, and D1 SQL migrations). |
sws mcp |
Start the local stdio JSON-RPC 2.0 MCP server for editor and AI-assistant integrations. |
Example CLI Workflow
# Initialize a starter site
sws init ./my-site
# Validate IR, accessibility rules, and header parity (JSON report for CI)
sws check ./my-site/site.json --headers-file ./my-site/public/_headers --json
# Compile deterministic static output
sws build ./my-site/site.json ./my-site/public
# Export a Cloudflare-ready bundle
sws export ./my-site/site.json ./dist-bundle
Stdio MCP Server (sws mcp)
The built-in MCP server communicates over standard input/output using JSON-RPC 2.0 so coding agents can inspect and patch site IR deterministically without hand-editing rendered HTML.
| MCP Tool | Purpose |
|---|---|
read_site_ir |
Load and validate a site IR or pack JSON file and return its normalized structure. |
apply_ir_patch |
Apply structured patches to site IR while enforcing schema invariants. |
compile_preview |
Compile the current IR in memory and return preview diagnostics and artifact summaries. |
run_a11y_and_plugin_checks |
Run compiler accessibility checks and active vertical pack linters on the site IR. |
Local MCP Client Configuration
{
"mcpServers": {
"sws": {
"command": "sws",
"args": ["mcp"]
}
}
}