design-learn-server
v0.1.7
Published
Design-Learn server skeleton for REST/WS/MCP routes
Readme
Design-Learn Server (Skeleton)
A minimal single-process server entry that registers REST, WebSocket, and MCP (SSE) routes.
Start
node src/server.jsQuick start (npx)
npx design-learn-server --port 3000 --data-dir ./dataMCP stdio (npx)
npx -y -p design-learn-server design-learn-mcpOptional flags:
--auth-token <token>for MCP auth--server-name <name>/--server-version <ver>--no-health-checkto disable startup health check
Optional port override:
PORT=3000 node src/server.jsEndpoints
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 (optionaljobId=...)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)
Extraction pipeline
Browser plugin import
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\":\"<html></html>\",\"css\":\"body{}\"}}'URL extraction (Playwright)
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.
Progress stream
curl -N http://localhost:3000/api/import/streamData storage
- SQLite metadata:
<dataDir>/database.sqlite - File storage:
<dataDir>/designs dataDirdefaults to./data, override withDESIGN_LEARN_DATA_DIRorDATA_DIR(supports~expansion)
Search indexes
- Optional: set
DESIGN_LEARN_USE_INDEX=1to read component/rule indexes. - Rebuild indexes:
node scripts/rebuild-index.js
Migrations
- Schema version is tracked via SQLite
PRAGMA user_version(current: 1). - For breaking changes, back up
database.sqliteand thedesigns/folder before upgrading.
MCP auth & versioning
- Auth: set
MCP_AUTH_TOKENto requireAuthorization: Bearer <token>on MCP requests. - Version:
MCP_SERVER_VERSIONcontrols the MCP server version advertised to clients (default0.1.0). - Compatibility: prefer additive changes (new tools/resources/prompts) and keep existing contracts stable.
Backend quick check
./scripts/verify-backend.shMCP quick check
node scripts/verify-mcp.js --url http://localhost:3000/mcpWith auth:
node scripts/verify-mcp.js --url http://localhost:3000/mcp --auth-token YOUR_TOKEN