Design-Learn server skeleton for REST/WS/MCP routes
npm install design-learn-serverA minimal single-process server entry that registers REST, WebSocket, and MCP (SSE) routes.
``bash`
node src/server.js
`bash`
npx design-learn-server --port 3000 --data-dir ./data
`bash`
npx design-learn-server design-learn-mcp
Optional flags:
- --auth-token for MCP auth--server-name
- / --server-version --no-health-check
- to disable startup health check
Optional port override:
`bash`
PORT=3000 node src/server.js
- GET /api/health -> health check JSONPOST /api/import/browser
- -> enqueue browser plugin import (alias: /api/designs/import)POST /api/import/url
- -> enqueue Playwright URL extractionGET /api/import/jobs
- -> list import jobsGET /api/import/jobs/:id
- -> fetch job statusGET /api/import/stream
- -> SSE progress stream (optional jobId=...)GET /api/designs
- -> list designsPOST /api/designs
- -> create designGET /api/designs/:id
- -> fetch designPATCH /api/designs/:id
- -> update designDELETE /api/designs/:id
- -> delete designGET /api/snapshots
- -> list snapshotsGET /api/snapshots/:id
- -> fetch snapshotPOST /api/snapshots/import
- -> enqueue snapshot importGET /api/config
- -> fetch configPUT /api/config
- -> update configPOST /api/previews
- -> enqueue component previewGET /api/previews/:componentId
- -> fetch component previewGET /api/previews/jobs
- -> list preview jobsGET /api/previews/jobs/:id
- -> fetch preview job statusGET /mcp
- / POST /mcp / DELETE /mcp -> MCP Streamable HTTP (SSE streaming)WS /ws
- -> WebSocket upgrade endpoint (handshake only)
`bash`
curl -X POST http://localhost:3000/api/import/browser \\
-H 'Content-Type: application/json' \\
-d '{\"source\":\"browser-extension\",\"website\":{\"url\":\"https://example.com\",\"title\":\"Example\"},\"snapshot\":{\"html\":\"\",\"css\":\"body{}\"}}'
`bash`
curl -X POST http://localhost:3000/api/import/url \\
-H 'Content-Type: application/json' \\
-d '{\"url\":\"https://example.com\"}'
If playwright or scripts/lib/extractor.js is missing, the job will fail with playwright_not_installed or extractor_script_missing.
`bash`
curl -N http://localhost:3000/api/import/stream
- SQLite metadata:
- File storage: dataDir
- defaults to ./data, override with DESIGN_LEARN_DATA_DIR or DATA_DIR (supports ~ expansion)
- Optional: set DESIGN_LEARN_USE_INDEX=1 to read component/rule indexes.node scripts/rebuild-index.js
- Rebuild indexes:
- Schema version is tracked via SQLite PRAGMA user_version (current: 1).database.sqlite
- For breaking changes, back up and the designs/ folder before upgrading.
- Auth: set MCP_AUTH_TOKEN to require Authorization: Bearer on MCP requests.MCP_SERVER_VERSION
- Version: controls the MCP server version advertised to clients (default 0.1.0).
- Compatibility: prefer additive changes (new tools/resources/prompts) and keep existing contracts stable.
`bash`
./scripts/verify-backend.sh
`bash`
node scripts/verify-mcp.js --url http://localhost:3000/mcp
With auth:
`bash``
node scripts/verify-mcp.js --url http://localhost:3000/mcp --auth-token YOUR_TOKEN