Skip to content

Add MCP dashboard-schema generator - #1072

Draft
dillan wants to merge 10 commits into
mxtommy:masterfrom
dillan:feat/mcp-schema-generator
Draft

Add MCP dashboard-schema generator#1072
dillan wants to merge 10 commits into
mxtommy:masterfrom
dillan:feat/mcp-schema-generator

Conversation

@dillan

@dillan dillan commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What this adds

A build-time generator that extracts KIP's design vocabulary into a single,
versioned JSON artifact for the external kip-mcp-server to consume, so an AI
assistant can design valid KIP dashboards.

  • tools/gen-mcp-schema/ reads KIP source statically with the TypeScript Compiler
    API
    (already a KIP dependency — no new packages) and emits
    src/assets/kip-dashboard-schema.json: the widget catalog, each widget's
    DEFAULT_CONFIG, its binding kind and path slots, plus the design system (24-column
    grid, colour tokens, theme names, dashboard icons, unit groups).
  • It reads static literals only and never executes Angular components. It fails
    loudly
    if a widget's DEFAULT_CONFIG is ever not a pure literal (so the artifact
    can't go silently wrong).
  • Output is canonical and deterministic (recursively sorted keys, sorted sets, no
    timestamps), so the committed artifact diffs cleanly between versions.
  • npm run gen:mcp-schema regenerates it; a drift-gate test fails if it's out of date.

Scope and safety

  • Changes are limited to tools/gen-mcp-schema/ and the generated
    src/assets/kip-dashboard-schema.json. No app code changes.
  • Built test-first (Vitest) in an isolated node config, so it does not touch the
    app's ng test or the production build.
  • KIP's static host already serves src/assets, so the artifact is reachable at
    /@mxtommy/kip/assets/kip-dashboard-schema.json with no new server code.

dillan added 10 commits June 23, 2026 12:06
Begin the KIP dashboard-schema generator test-first. The new vitest suite (run via test:mcp-schema, in an isolated node environment) describes the widget catalog the generator must extract from widget.service.ts.

These tests fail on purpose: the generator is still a stub. The ts-morph implementation lands in the next commit.
Extract KIP's widget catalog from widget.service.ts using the TypeScript Compiler API (already a KIP dependency, so no new packages). The _widgetDefinition literal is read statically and each entry validated; the generator fails loudly if the shape changes, and commented-out widgets are naturally excluded.

For stable, consistent diffs of the generated artifact, output is canonical: object keys sorted recursively (serialize.ts), widgets sorted by selector, and plugin lists sorted.
Extend the generator test-first to cover per-widget DEFAULT_CONFIG, the structural binding kind (paths-record / paths-array / datachart / none), and path-slot extraction.

These tests fail on purpose against a stub; the implementation lands in the next commit.
Read each widget component's static DEFAULT_CONFIG via the TypeScript Compiler API, resolving the component file from its import in widget.service.ts. Derive bindingKind structurally and extract path slots for record-bound widgets.

The 'every widget' test confirms all active widget DEFAULT_CONFIGs are pure static literals, so static extraction is sound.
Cover the 24-column grid geometry, colour tokens, theme names, dashboard icons, and unit groups the generator must read from KIP source. These fail on purpose against a stub.
Read the 24-column grid geometry from dashboard.component.ts, colour tokens from app-service.ts, unit groups from units.service.ts, and dashboard icons from the SVG sprite. Colours and unit groups keep their authored order; icons are sorted and de-duplicated.
Cover buildSchema: version-stamped meta plus the assembled widgets and design system. Fails on purpose against a stub.
Add buildSchema (version-stamped meta + widgets + design system) and generate src/assets/kip-dashboard-schema.json, which KIP's static host serves at /@mxtommy/kip/assets/kip-dashboard-schema.json for the kip-mcp-server to fetch.

The artifact is deterministic (no timestamps) and canonical. The new gen:mcp-schema script regenerates it; a drift-gate test fails if a widget or the design system changes without regenerating.
Read each token's base hex from the $kip-dark-color SCSS map and add it
to the generated schema's colour list, so previews can render the real
KIP palette instead of guessing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant