@svgrid/mcp 2.6.5 → 2.6.6

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
@@ -28,15 +28,61 @@ Point any MCP-capable client - Claude Desktop, Claude Code, Cursor, Zed - at thi
28
28
 
29
29
  | Tool | Purpose |
30
30
  | --- | --- |
31
+ | `check_svgrid_code` | **Verify** a file against the real API surface + the Svelte compiler. |
31
32
  | `list_examples` | Every demo: id, title, and one-line blurb. |
32
33
  | `get_example_source` | Full `.svelte` source for a demo by id. |
33
34
  | `list_docs` | Every documentation page (slug + title). |
34
35
  | `get_doc` | Markdown for a single doc by slug. |
35
- | `search_docs` | Case-insensitive substring search across the docs. |
36
+ | `search_docs` | Ranked full-text search across the docs. |
36
37
  | `get_api_reference` | The curated public-API surface, grouped by category. |
37
38
  | `introspect_source` | Studio: infer an `EntitySchema` from a Drizzle file or sample rows. |
38
39
  | `scaffold_entity` | Studio: generate SvelteKit files for a single entity. |
39
40
 
41
+ ### `check_svgrid_code` - the one a retrieval server cannot do
42
+
43
+ Reading the docs makes a model *likelier* to be right. This makes it *checkable*.
44
+ Hand it a file and it answers with line-numbered diagnostics and the exact
45
+ replacement for each:
46
+
47
+ ```jsonc
48
+ {
49
+ "ok": false,
50
+ "checkedAgainst": "@svgrid/grid@2.6.20",
51
+ "compiler": "svelte",
52
+ "counts": { "errors": 3, "warnings": 0, "info": 0 },
53
+ "diagnostics": [
54
+ { "rule": "svgrid/renamed-prop", "severity": "error", "line": 24,
55
+ "message": "`rowData` is not a SvGrid prop.", "fix": "Use `data`." },
56
+ { "rule": "svgrid/renamed-column-key", "severity": "error", "line": 10,
57
+ "message": "`accessorKey` is not a SvGrid column key.", "fix": "Use `field`." },
58
+ { "rule": "svelte/legacy-event-directive", "severity": "error", "line": 30,
59
+ "message": "`on:rowClick` never fires: SvGrid dispatches no component events, it takes callback props.",
60
+ "fix": "Use `onRowClick={...}`." }
61
+ ]
62
+ }
63
+ ```
64
+
65
+ What it checks:
66
+
67
+ - **Every name, against the installed version.** Importable symbols, `<SvGrid>`
68
+ props, `ColumnDef` keys, grid API methods, theme stylesheets. The list is
69
+ generated from the package sources at build time, so it cannot drift from
70
+ what the package exports, and an unknown name comes back with the nearest
71
+ real one.
72
+ - **Cross-package mistakes.** A symbol that lives in `@svgrid/enterprise`, or an
73
+ api method that only exists after `installEnterprise(api)`.
74
+ - **Svelte 5 rules.** `export let` and `$:` in a runes file (compiler errors),
75
+ `on:` / `<slot>` / `createEventDispatcher` (deprecations), and a plain `let`
76
+ array that gets mutated and silently never re-renders.
77
+ - **The file, compiled.** When a Svelte compiler is reachable - the user's
78
+ project copy first, then the one shipped here - real parse errors come back
79
+ too. The result says which of the two ran in its `compiler` field, so
80
+ "no errors" is never mistaken for "this compiles".
81
+
82
+ It is tuned to shut up when the code is right: it reports **nothing** across all
83
+ 373 demos in this repo, which is what a CI test asserts. A verifier that cries
84
+ wolf is worse than none, because a model will happily "fix" working code.
85
+
40
86
  ### Studio: drive the app model (agent co-designer)
41
87
 
42
88
  The `studio_*` tools let an agent build and edit the **same validated project model the visual designer uses** - add entities, screens, blocks, components, wire data sources, theme, RBAC, auth, the typed data layer, and the deploy target - then generate the full runnable app or export the `studio.config.json` the designer can Load. Every edit runs through the model's own functions + `validateProject`, so the agent can't produce an invalid app.
@@ -55,6 +101,20 @@ The `studio_*` tools let an agent build and edit the **same validated project mo
55
101
 
56
102
  A typical session: `studio_new_project` → `studio_add_entity` (×N) → `studio_set_entity_source` → `studio_set_data_layer` → `studio_set_auth` → `studio_generate_app` → write the files and run `svelte-check`.
57
103
 
104
+ ## Two ways to run it
105
+
106
+ | | stdio (this package) | remote HTTP |
107
+ | --- | --- | --- |
108
+ | Install | `npx @svgrid/mcp` | paste a URL |
109
+ | Needs Node | yes | no |
110
+ | `check_svgrid_code` compiles | yes | static checks only |
111
+ | Studio `studio_*` tools | yes (27) | no |
112
+ | Works offline | yes | no |
113
+
114
+ The remote server lives in [`workers/svgrid-mcp`](../../workers/svgrid-mcp) and
115
+ carries the six docs + verification tools. Use stdio when you want the compiler
116
+ pass, the Studio tools, or no third-party endpoint in the loop.
117
+
58
118
  ## Run
59
119
 
60
120
  ```bash
@@ -0,0 +1,2 @@
1
+ import type { CompileFn } from './validate.js';
2
+ export declare const compileWithSvelte: CompileFn;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The second gate of `check_svgrid_code`: the real Svelte compiler.
3
+ *
4
+ * Kept in its own module, and imported dynamically, for two reasons. The
5
+ * compiler is only present when the server runs next to a project that has
6
+ * Svelte installed (a bare `npx @svgrid/mcp` in an empty directory does not),
7
+ * and a Worker build must be able to leave it out entirely - which it can,
8
+ * because nothing outside the stdio entry point imports this file.
9
+ */
10
+ import { createRequire } from 'node:module';
11
+ import { pathToFileURL } from 'node:url';
12
+ import { join } from 'node:path';
13
+ /** Compiler warnings that repeat per element and drown the real findings. */
14
+ const MAX_WARNINGS = 15;
15
+ /**
16
+ * Prefer the Svelte the USER's project is on, so the check matches what their
17
+ * build will do; fall back to the copy that ships with this package. Resolved
18
+ * once and reused - the compiler is not cheap to load.
19
+ */
20
+ let cached;
21
+ async function loadCompiler() {
22
+ if (cached !== undefined)
23
+ return cached;
24
+ const attempts = [
25
+ async () => {
26
+ const require = createRequire(join(process.cwd(), 'package.json'));
27
+ return (await import(pathToFileURL(require.resolve('svelte/compiler')).href));
28
+ },
29
+ async () => (await import('svelte/compiler')),
30
+ ];
31
+ for (const attempt of attempts) {
32
+ try {
33
+ const mod = await attempt();
34
+ if (typeof mod.compile === 'function') {
35
+ cached = mod;
36
+ return cached;
37
+ }
38
+ }
39
+ catch {
40
+ // Try the next source.
41
+ }
42
+ }
43
+ cached = null;
44
+ return cached;
45
+ }
46
+ export const compileWithSvelte = async (source, filename) => {
47
+ const mod = await loadCompiler();
48
+ if (!mod)
49
+ return { available: false, diagnostics: [] };
50
+ const compile = mod.compile;
51
+ const diagnostics = [];
52
+ try {
53
+ const { warnings } = compile(source, { filename, generate: 'client' });
54
+ for (const w of warnings.slice(0, MAX_WARNINGS)) {
55
+ diagnostics.push({
56
+ rule: `svelte/${w.code ?? 'warning'}`,
57
+ severity: 'warning',
58
+ line: w.start?.line ?? 1,
59
+ message: w.message ?? 'compiler warning',
60
+ });
61
+ }
62
+ }
63
+ catch (err) {
64
+ const e = err;
65
+ diagnostics.push({
66
+ rule: `svelte/${e.code ?? 'compile-error'}`,
67
+ severity: 'error',
68
+ line: e.start?.line ?? 1,
69
+ message: (e.message ?? String(err)).split('\n')[0],
70
+ fix: 'The file does not parse. Fix this first - every other check ran on unparsed text.',
71
+ });
72
+ }
73
+ return { available: true, diagnostics };
74
+ };
package/dist/data.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import type { ApiSurface } from './validate.js';
2
+ export type ExampleEntry = {
3
+ id: string;
4
+ path: string;
5
+ title: string;
6
+ category: string;
7
+ blurb: string;
8
+ source: string;
9
+ };
10
+ export type DocEntry = {
11
+ slug: string;
12
+ path: string;
13
+ title: string;
14
+ section: string;
15
+ markdown: string;
16
+ };
17
+ export declare const examples: readonly ExampleEntry[];
18
+ export declare const docs: readonly DocEntry[];
19
+ export declare const apiReference: {
20
+ readonly components: readonly ["SvGrid", "SvGridBoard", "FlexRender", "renderComponent", "renderSnippet"];
21
+ readonly headless: readonly ["createSvGrid", "createGrid", "createGridState", "subscribeGrid", "createTable"];
22
+ readonly scheduler: readonly ["registerSchedulerView", "getSchedulerView", "hasSchedulerView", "resolveEvents", "layoutDayEvents"];
23
+ readonly dataOps: readonly ["applyGroupAggregate", "filterFns", "sortFns"];
24
+ readonly export: readonly ["serializeDelimited", "serializeJson", "serializeHtml", "serializeMarkdown", "downloadTextFile", "copyTextToClipboard"];
25
+ readonly rowModels: readonly ["createCoreRowModel", "createFilteredRowModel", "createSortedRowModel", "createGroupedRowModel", "createExpandedRowModel", "createPaginatedRowModel"];
26
+ readonly features: readonly ["tableFeatures", "rowSortingFeature", "columnFilteringFeature", "columnGroupingFeature", "rowExpandingFeature", "rowPaginationFeature", "rowSelectionFeature"];
27
+ readonly virtualization: readonly ["createVirtualizer", "createSvelteVirtualizer", "createColumnVirtualizer"];
28
+ readonly accessibility: readonly ["getGridRootA11yProps", "getGridHeaderA11yProps", "getGridCellA11yProps", "getGridRowA11yProps", "getGridCellDomId"];
29
+ readonly utilities: readonly ["getKeyboardIntent", "getNextActiveCell", "parseEditorValue", "applyExcelFilter", "formatNumericWithConfig", "resolveDatePattern"];
30
+ };
31
+ export declare const apiSurface: ApiSurface;