@slexkit/mcp 0.4.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,85 +1,25 @@
1
- # @slexkit/mcp
2
-
3
- Read-only MCP server for SlexKit docs, component APIs, examples, and source validation.
4
-
5
- ## Configure
6
-
7
- ```json
8
- {
9
- "mcpServers": {
10
- "slexkit": {
11
- "command": "npx",
12
- "args": ["-y", "@slexkit/mcp"]
13
- }
14
- }
15
- }
16
- ```
17
-
18
- The same command shape works in clients such as Codex, Claude Desktop, and other MCP-compatible agent tools:
19
-
20
- ```sh
21
- npx -y @slexkit/mcp
22
- ```
23
-
24
- ## Tools
25
-
26
- The server exposes three read-only tools:
27
-
28
- | Tool | Purpose |
29
- |------|---------|
30
- | `slexkitDocs` | Search or fetch generated Markdown docs, standard artifact JSON, conformance reports, and optional `std.*` / `api.*` capability metadata. |
31
- | `slexkitExamples` | Return component examples or generated templates such as `status`, `calculator`, `stdlib-calculator`, `secure-network-card`, `toolhost-form`, and `host-integration`. |
32
- | `slexkitValidate` | Parse Slex source and return diagnostics, warnings, component usage, `std.*` usage, and `api.*` usage. |
33
-
34
- Example validation request:
35
-
36
- ```json
37
- {
38
- "name": "slexkitValidate",
39
- "arguments": {
40
- "source": "{ slex: \"0.1\", namespace: \"demo\", layout: { \"text:message\": { text: \"Hello\" } } }"
41
- }
42
- }
43
- ```
44
-
45
- Successful validation returns structured content similar to:
46
-
47
- ```json
48
- {
49
- "ok": true,
50
- "schemaVersion": "2026-06",
51
- "protocolVersion": "0.1",
52
- "logicProfileVersion": "0.1",
53
- "componentUsage": ["text"]
54
- }
55
- ```
56
-
57
- Invalid source returns `ok: false` plus a SlexKit diagnostic with message, location, and excerpt.
58
-
59
- Fetch standard artifacts through `slexkitDocs`:
60
-
61
- ```json
62
- {
63
- "name": "slexkitDocs",
64
- "arguments": {
65
- "standardArtifact": "slex-standard-manifest.json"
66
- }
67
- }
68
- ```
69
-
70
- Available standard artifacts include `slex-expression.schema.json`, `slex-component-catalog.json`, `slex-logic-profile.json`, `slex-capabilities.catalog.json`, `slex-conformance.json`, and `slex-standard-manifest.json`.
71
-
72
- Run the bundled conformance fixtures through `slexkitDocs`:
73
-
74
- ```json
75
- {
76
- "name": "slexkitDocs",
77
- "arguments": {
78
- "conformanceReport": true
79
- }
80
- }
81
- ```
82
-
83
- ## Safety
84
-
85
- The MCP server is read-only. It serves bundled docs and generated metadata from the package, validates source text, and writes no project files.
1
+ # @slexkit/mcp
2
+
3
+ Read-only MCP server for HTML-first SlexKit documentation, examples, custom-element metadata, standard artifacts, and static validation.
4
+
5
+ ```sh
6
+ bunx @slexkit/mcp
7
+ ```
8
+
9
+ Tools:
10
+
11
+ - `slexkitDocs` searches/fetches published documentation and HTML-profile metadata.
12
+ - `slexkitExamples` returns HTML examples and metadata generated from the actual Web Components definitions.
13
+ - `slexkitValidate` statically inspects HTML and inline JavaScript. It never executes payload scripts.
14
+
15
+ Validation input:
16
+
17
+ ```json
18
+ {
19
+ "source": "<slex-stat label=\"Count\" value=\"3\"></slex-stat>"
20
+ }
21
+ ```
22
+
23
+ The validator rejects legacy object source as well as external scripts/imports, inline event-handler attributes, embedded frames/plugins, navigation metadata, and executable URL schemes according to the runtime inspector. Static success is not permission to execute source in the host page; generated code still belongs in the isolated SlexKit document runtime.
24
+
25
+ Standard metadata is published as an HTML profile, custom-element catalog, sandbox SDK, static policy, conformance fixtures, and manifest. Component setup and asset URLs remain host-owned.
@@ -1,46 +1,3 @@
1
- # SlexKit Authoring Rules for LLMs
1
+ # SlexKit HTML authoring
2
2
 
3
- SlexKit's agent-readable source is Markdown with explicit `slex` fences. Do not use `.mdx`; `slex` fences are the interactive layer.
4
-
5
- ## Always Do
6
-
7
- - Emit explicit `slex` fenced code blocks for display-oriented interactive UI.
8
- - Use a Slex expression envelope: `slex`, `namespace`, `g`, and `layout`.
9
- - Put mutable state and helper functions in `g`; put component structure in `layout`.
10
- - Use `std.*` for common calculations, formatting, units, and small statistics.
11
- - Use component keys in `type:identifier` form, such as `card:summary`.
12
- - Use `$` read-pipes for dynamic props and `on*` write-pipes for event handlers.
13
- - Include readable Markdown fallback text after the fence.
14
- - Use secure runtime integration for untrusted or agent-generated source.
15
-
16
- ## Do Not
17
-
18
- - Do not emit imports, JSX, Svelte, Vue, or project scaffolding inside `slex` fences.
19
- - Do not ask hosts to scan plain JavaScript, JSON, or untagged code blocks.
20
- - Do not wrap ordinary status cards or summaries in ToolHost.
21
- - Do not bypass the sandbox for untrusted source.
22
- - Do not use native `fetch`, `XMLHttpRequest`, `WebSocket`, `setTimeout`, or `requestAnimationFrame` in secure mode; use policy-gated `api.*` instead.
23
- - Do not invent `.mdx` routes for SlexKit docs.
24
-
25
- ## Display UI Example
26
-
27
- ```slex
28
- {
29
- slex: "0.1",
30
- namespace: "release_status",
31
- g: { done: 3, total: 4 },
32
- layout: {
33
- "card:summary": {
34
- title: "Release status",
35
- "text:count": { "$text": "g.done + '/' + g.total + ' complete'" },
36
- "progress:bar": { "$value": "g.done / g.total * 100" }
37
- }
38
- }
39
- }
40
- ```
41
-
42
- **Fallback:** Release status: 3/4 complete.
43
-
44
- ## ToolHost Boundary
45
-
46
- Use ToolHost only when the UI must return structured user input to the host, such as confirmations, option lists, or forms. Display-only dashboards, metrics, and status blocks should stay as `slex` fences.
3
+ Use the `html-1` profile. A `slex` fence contains standard HTML/SVG, optional CSS, documented `slex-*` elements, and optional inline module scripts. Do not emit object g/layout source, expression attributes, runtime imports, or component registration. Use native events and `slex.root`; `slex.signal` is an `AbortSignal`; release side effects with `slex.onDispose`. The host owns runtime/style URLs, component registration, and approved capabilities. Each fence is a separate isolated document; `slex.shared` transfers artifact-local JSON only.
@@ -1,126 +1,3 @@
1
- # SlexKit Capabilities for LLMs
1
+ # Sandbox SDK
2
2
 
3
- Use `std.*` for pure deterministic calculations and formatting. Use `api.*` only for host-injected or secure-runtime capabilities that may require policy.
4
-
5
- ## Expression Context
6
-
7
- - `g` (always): Reactive state proxy.
8
- - `std` (always): Pure deterministic SlexKit standard library.
9
- - `api` (host-injected): Host or secure runtime capability object.
10
- - `$event` (event handlers): Event payload for on* handlers.
11
- - `$item` ($for): Current array item.
12
- - `$index` ($for): Current item index.
13
- - `$key` ($for): Current item key.
14
-
15
- ## std.math
16
-
17
- Small numeric helpers for common interactive calculations.
18
-
19
- - `std.math.clamp(value, min, max)`: Clamp a number into a range. Example: `std.math.clamp(g.score, 0, 100)`
20
- - `std.math.round(value, digits = 0)`: Round with a fixed number of decimal digits. Example: `std.math.round(g.latency, 1)`
21
- - `std.math.safeDivide(numerator, denominator, fallback = 0)`: Divide with a fallback for zero or invalid denominators. Example: `std.math.safeDivide(g.used, g.total, 0)`
22
- - `std.math.percent(part, total, digits = 1)`: Return part / total as a percentage number. Example: `std.math.percent(g.done, g.total, 1)`
23
- - `std.math.lerp(start, end, t)`: Linear interpolation. Example: `std.math.lerp(0, 100, g.progress)`
24
-
25
- ## std.stats
26
-
27
- Finite-number aggregations for arrays.
28
-
29
- - `std.stats.sum(values)`: Sum finite numeric values. Empty arrays return 0. Example: `std.stats.sum(g.samples)`
30
- - `std.stats.mean(values)`: Average finite numeric values. Empty arrays return NaN. Example: `std.stats.mean(g.samples)`
31
- - `std.stats.min(values)`: Minimum finite numeric value. Empty arrays return NaN. Example: `std.stats.min(g.samples)`
32
- - `std.stats.max(values)`: Maximum finite numeric value. Empty arrays return NaN. Example: `std.stats.max(g.samples)`
33
- - `std.stats.median(values)`: Median finite numeric value. Empty arrays return NaN. Example: `std.stats.median(g.samples)`
34
-
35
- ## std.format
36
-
37
- Deterministic display formatting with en-US defaults.
38
-
39
- - `std.format.fixed(value, digits = 2)`: Format a number with fixed decimal places. Example: `std.format.fixed(g.voltage, 3)`
40
- - `std.format.number(value, digits = 0, locale = 'en-US')`: Locale number formatting. Example: `std.format.number(g.requests)`
41
- - `std.format.compact(value, digits = 1, locale = 'en-US')`: Compact number formatting. Example: `std.format.compact(g.users)`
42
- - `std.format.percent(ratio, digits = 1)`: Format a ratio as a percentage string. Example: `std.format.percent(g.done / g.total, 1)`
43
- - `std.format.currency(value, currency = 'USD', locale = 'en-US')`: Format a currency value. Example: `std.format.currency(g.revenue, 'USD')`
44
-
45
- ## std.units
46
-
47
- Small unit display helpers for common dashboards.
48
-
49
- - `std.units.withUnit(value, unit, digits = 2)`: Format a value with a unit suffix. Example: `std.units.withUnit(g.power, 'W', 1)`
50
- - `std.units.bytes(value, digits = 1)`: Format bytes as B, KB, MB, GB, TB, or PB. Example: `std.units.bytes(g.payloadBytes)`
51
- - `std.units.duration(ms, digits = 1)`: Format milliseconds as ms, s, min, or h. Example: `std.units.duration(g.elapsedMs)`
52
- - `std.units.si(value, unit = '', digits = 2)`: Format with SI prefixes. Example: `std.units.si(g.frequency, 'Hz', 2)`
53
-
54
- ## Policy-Gated Runtime API
55
-
56
- - `api.get(url, options)` (network, secure default: denied): Policy-gated GET request.
57
- - `api.post(url, body, options)` (network, secure default: denied): Policy-gated POST request.
58
- - `api.fetch(url, options)` (network, secure default: denied): Policy-gated GET or POST request.
59
- - `api.setTimeout(fn, ms)` (timer, secure default: denied): Policy-gated timeout.
60
- - `api.clearTimeout(id)` (timer, secure default: denied): Clear a policy-gated timeout.
61
- - `api.setInterval(fn, ms)` (timer, secure default: denied): Policy-gated interval.
62
- - `api.clearInterval(id)` (timer, secure default: denied): Clear a policy-gated interval.
63
- - `api.raf(fn)` (animation, secure default: denied): Policy-gated animation frame.
64
- - `api.cancelRaf(id)` (animation, secure default: denied): Cancel a policy-gated animation frame.
65
- - `api.createCanvas(width, height)` (canvas, secure default: denied): Create a policy-counted canvas.
66
- - `api.getCanvasContext(canvas, contextId, options)` (canvas, secure default: denied): Get a policy-checked canvas context.
67
- - `api.onDispose(fn)` (lifecycle, secure default: available): Register runtime cleanup.
68
- - `api.now()` (lifecycle, secure default: available): Runtime clock.
69
- - `api.isTimeoutError(error)` (diagnostics, secure default: available): Check timeout errors.
70
- - `api.isNetworkError(error)` (diagnostics, secure default: available): Check network errors.
71
- - `api.isPolicyError(error)` (diagnostics, secure default: available): Check policy errors.
72
- - `api.errorMessage(error)` (diagnostics, secure default: available): Extract a displayable error message.
73
-
74
- Secure mode blocks native `fetch`, `XMLHttpRequest`, `WebSocket`, `setTimeout`, `setInterval`, and `requestAnimationFrame`. Use `api.get`, `api.post`, `api.fetch`, `api.setTimeout`, `api.setInterval`, and `api.raf` when host policy enables them.
75
-
76
- ## Recipe: Std Calculator
77
-
78
- ```slex
79
- {
80
- slex: "0.1",
81
- namespace: "std_calculator",
82
- g: { done: 7, total: 12, samples: [120, 95, 143, 110], bytes: 1536000 },
83
- layout: {
84
- "card:summary": {
85
- title: "Stdlib calculator",
86
- "stat:progress": { label: "Progress", "$value": "std.format.percent(std.math.safeDivide(g.done, g.total), 1)" },
87
- "stat:average": { label: "Average", "$value": "std.format.fixed(std.stats.mean(g.samples), 1)", unit: "ms" },
88
- "stat:payload": { label: "Payload", "$value": "std.units.bytes(g.bytes)" }
89
- }
90
- }
91
- }
92
- ```
93
-
94
- ## Recipe: Secure Network Card
95
-
96
- ```slex
97
- {
98
- slex: "0.1",
99
- namespace: "secure_network_card",
100
- g: {
101
- status: "idle",
102
- async load() {
103
- this.status = "loading";
104
- try {
105
- var result = await api.get("https://api.example.com/status", { credentials: "omit" });
106
- this.status = "HTTP " + result.status;
107
- } catch (error) {
108
- this.status = api.isPolicyError(error) ? "blocked by policy" : api.errorMessage(error);
109
- }
110
- }
111
- },
112
- layout: {
113
- "card:network": {
114
- title: "Secure network card",
115
- "button:load": { label: "Load", onclick: "g.load()" },
116
- "text:status": { "$text": "g.status" }
117
- }
118
- }
119
- }
120
- ```
121
-
122
- ## Recipe: Timer and Animation Policy
123
-
124
- - Timers are disabled in secure mode unless `policy.timer.enabled` is true.
125
- - Use `api.setTimeout` and `api.setInterval`; do not use native scheduling globals.
126
- - Animation is disabled unless `policy.animation.enabled` is true; use `api.raf`.
3
+ `slex.root`, the scope `AbortSignal` at `slex.signal`, `slex.onDispose`, `slex.onSnapshot`, `slex.onRestore`, policy-gated `slex.api`, and artifact-local JSON `slex.shared.get/set/subscribe`. Each fence is a separate isolated document. The frame policy denies direct payload resource loads in supported browsers, while approved operations use the host bridge. This is not a universal egress firewall: iframe self-navigation can issue a request. SlexKit does not provide CPU preemption.