@svgrid/mcp 3.0.33 → 3.0.34

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/dist/index.js CHANGED
@@ -21,10 +21,10 @@ import { createRequire } from 'node:module';
21
21
  // Our own stdio transport, not @modelcontextprotocol/sdk: the SDK's HTTP and
22
22
  // OAuth dependencies were most of a cold npx install (see stdio-server.ts).
23
23
  import { StdioMcpServer } from './stdio-server.js';
24
- import { CORE_TOOLS, PREVIEW_TOOL } from './tool-defs.js';
24
+ import { CORE_TOOLS, PREVIEW_TOOL, serverInstructions } from './tool-defs.js';
25
25
  import { PROMPTS, getPrompt } from './prompts.js';
26
26
  import { installedGrid, versionNote } from './installed.js';
27
- import { applyFixes, checkSvGridCode } from './validate.js';
27
+ import { applyFixes, checkSvGridCode, sourceArg } from './validate.js';
28
28
  import { compileWithSvelte } from './compile-svelte.js';
29
29
  import { ENTERPRISE_LINE, checkNeedsEnterprise } from './enterprise.js';
30
30
  let corpusLoad;
@@ -106,6 +106,7 @@ const server = new StdioMcpServer({ name: '@svgrid/mcp', version: pkgVersion },
106
106
  // resources (the user attaches a doc, no tool call needed) and the common
107
107
  // tasks are a natural fit for prompts.
108
108
  capabilities: { tools: {}, resources: {}, prompts: {} },
109
+ instructions: serverInstructions({ search: 'svgrid_search', get: 'svgrid_get', check: 'svgrid_check_code' }),
109
110
  });
110
111
  // ---- the two tools that are not pure retrieval ----------------------------
111
112
  const CHECK_TOOL = {
@@ -178,10 +179,9 @@ server.setRequestHandler('prompts/get', async (req) => {
178
179
  });
179
180
  // ---- tool calls -----------------------------------------------------------
180
181
  async function runCheck(args) {
181
- const source = args.source;
182
- if (typeof source !== 'string' || !source.trim()) {
182
+ const source = sourceArg(args);
183
+ if (!source)
183
184
  return errText('source (the file contents to check) is required');
184
- }
185
185
  const { apiSurface } = await corpus();
186
186
  const result = await checkSvGridCode(source, apiSurface, {
187
187
  filename: typeof args.filename === 'string' ? args.filename : undefined,
package/dist/preview.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare const UI_MIME_TYPE = "text/html;profile=mcp-app";
8
8
  * start failing in a way nobody is watching for. `tools/mcp-tools.test.ts` checks these
9
9
  * against the workspace so they cannot quietly rot either.
10
10
  */
11
- export declare const PREVIEW_GRID_WC_VERSION = "3.0.34";
11
+ export declare const PREVIEW_GRID_WC_VERSION = "3.0.35";
12
12
  export declare function previewResource(): {
13
13
  uri: string;
14
14
  name: string;
package/dist/preview.js CHANGED
@@ -27,7 +27,7 @@ export const UI_MIME_TYPE = 'text/html;profile=mcp-app';
27
27
  * start failing in a way nobody is watching for. `tools/mcp-tools.test.ts` checks these
28
28
  * against the workspace so they cannot quietly rot either.
29
29
  */
30
- export const PREVIEW_GRID_WC_VERSION = '3.0.34';
30
+ export const PREVIEW_GRID_WC_VERSION = '3.0.35';
31
31
  const EXT_APPS_VERSION = '1.7.5';
32
32
  const CDN = 'https://cdn.jsdelivr.net/npm';
33
33
  /**
@@ -6,6 +6,18 @@
6
6
  * list them without loading it; the handlers stay in those modules, which
7
7
  * re-export these for existing imports.
8
8
  */
9
+ /**
10
+ * The `instructions` both servers send in `initialize`. A client puts this in
11
+ * front of the model on every turn, which no tool description gets, so it
12
+ * carries the two habits that decide whether the code works: look the API up,
13
+ * then check the file. The tool names differ between the npm server and the
14
+ * hosted one (`search` and `fetch` are fixed names there), hence the argument.
15
+ */
16
+ export declare function serverInstructions(names: {
17
+ search: string;
18
+ get: string;
19
+ check: string;
20
+ }): string;
9
21
  export declare const UI_RESOURCE_URI = "ui://svgrid/preview.html";
10
22
  export declare const UI_RESOURCE_META_KEY = "ui/resourceUri";
11
23
  export declare const CORE_TOOLS: readonly [{
package/dist/tool-defs.js CHANGED
@@ -6,6 +6,21 @@
6
6
  * list them without loading it; the handlers stay in those modules, which
7
7
  * re-export these for existing imports.
8
8
  */
9
+ /**
10
+ * The `instructions` both servers send in `initialize`. A client puts this in
11
+ * front of the model on every turn, which no tool description gets, so it
12
+ * carries the two habits that decide whether the code works: look the API up,
13
+ * then check the file. The tool names differ between the npm server and the
14
+ * hosted one (`search` and `fetch` are fixed names there), hence the argument.
15
+ */
16
+ export function serverInstructions(names) {
17
+ return [
18
+ 'SvGrid is a Svelte 5 data grid (@svgrid/grid, MIT; @svgrid/enterprise adds export, import, pivot, print, Kanban, scheduler and spreadsheet).',
19
+ 'Svelte 5 only: runes ($state, $derived, $props) and snippets, callback props such as onCellClick, never `export let`, `on:` directives or stores.',
20
+ `Before writing grid code, call ${names.search} for the feature and ${names.get} for the page or demo it returns, so prop and option names come from this version rather than from memory.`,
21
+ `Run ${names.check} on every file you write that uses SvGrid, before showing it to the user, and use its \`fixed\` copy when it returns one.`,
22
+ ].join(' ');
23
+ }
9
24
  export const UI_RESOURCE_URI = 'ui://svgrid/preview.html';
10
25
  export const UI_RESOURCE_META_KEY = 'ui/resourceUri';
11
26
  export const CORE_TOOLS = [
@@ -149,6 +149,12 @@ export declare function applyFixes(source: string, diagnostics: readonly Diagnos
149
149
  applied: string[];
150
150
  };
151
151
  export declare function checkStatic(source: string, surface: ApiSurface, filename?: string): Diagnostic[];
152
+ /**
153
+ * The file to check, from a tool call's arguments. The schema names it
154
+ * `source`, but models guess `code` first and `content` second; answering to
155
+ * those costs nothing and saves the caller a failed round trip.
156
+ */
157
+ export declare function sourceArg(args: Record<string, unknown>): string | undefined;
152
158
  /**
153
159
  * Check a snippet and report what a model should do next. `compile` is the
154
160
  * optional second gate: when the host can reach a Svelte compiler, real parse
package/dist/validate.js CHANGED
@@ -362,6 +362,8 @@ function checkImports(ctx) {
362
362
  const { scan, raw, surface } = ctx;
363
363
  // Both `import { a } from 'x'` and the bare `import 'x'` a stylesheet uses.
364
364
  const re = /import\s+(?:(type\s+)?([\s\S]*?)\s+from\s*)?(['"])([^'"]*)\3/g;
365
+ /** Look-alike imports of names SvGrid does not export, judged after the loop. */
366
+ const foreign = [];
365
367
  for (let m; (m = re.exec(scan));) {
366
368
  const clause = m[2] ?? '';
367
369
  // The specifier text was blanked out by `blankOut`; read it back from the
@@ -396,6 +398,9 @@ function checkImports(ctx) {
396
398
  ...(exact ? { rename: { from: spec, to: from } } : {}),
397
399
  });
398
400
  }
401
+ else {
402
+ foreign.push({ spec, line, names });
403
+ }
399
404
  continue;
400
405
  }
401
406
  if (!spec.startsWith('@svgrid/'))
@@ -487,6 +492,20 @@ function checkImports(ctx) {
487
492
  }
488
493
  }
489
494
  }
495
+ // A look-alike package used with its own names is that library's business,
496
+ // unless the same file also imports SvGrid: then a model has most likely
497
+ // mixed the two up, and the import that does nothing for SvGrid is a lead.
498
+ if (foreign.length && [...ctx.importedFrom].some((s) => s.startsWith('@svgrid/'))) {
499
+ for (const f of foreign) {
500
+ push(ctx, {
501
+ rule: 'svgrid/lookalike-package-mixed',
502
+ severity: 'warning',
503
+ line: f.line,
504
+ message: `"${f.spec}" is an unrelated project, imported next to @svgrid/*${f.names.length ? ` (\`${f.names.join('`, `')}\`)` : ''}.`,
505
+ fix: `Drop the "${f.spec}" import if this file renders <SvGrid>; SvGrid needs no second grid package.`,
506
+ });
507
+ }
508
+ }
490
509
  }
491
510
  /** Attributes on every `<Tag ...>` occurrence, expressions and shorthands included. */
492
511
  function readTagAttrs(ctx, tag) {
@@ -597,6 +616,10 @@ function checkGridProps(ctx) {
597
616
  const evt = name.slice(3);
598
617
  const callback = `on${evt.charAt(0).toUpperCase()}${evt.slice(1)}`;
599
618
  const real = known.find((k) => k.toLowerCase() === callback.toLowerCase());
619
+ // The rename is exact only for an inline handler that never reads
620
+ // `.detail`: a callback prop gets the payload itself, not a CustomEvent,
621
+ // and a bare `on:cellClick` forwards the event, which has no prop form.
622
+ const exact = !!real && attr.valueRaw.startsWith('{') && !/\bdetail\b/.test(attr.valueRaw);
600
623
  push(ctx, {
601
624
  rule: 'svelte/legacy-event-directive',
602
625
  severity: 'error',
@@ -605,6 +628,7 @@ function checkGridProps(ctx) {
605
628
  fix: real
606
629
  ? `Use \`${real}={...}\`.`
607
630
  : `Look for the matching \`on...\` prop - call svgrid_get with ref:"api" or read reference/SvGrid.`,
631
+ ...(exact ? { rename: { from: name, to: real } } : {}),
608
632
  see: 'reference/SvGrid',
609
633
  });
610
634
  continue;
@@ -1429,6 +1453,19 @@ export function checkStatic(source, surface, filename = 'Component.svelte') {
1429
1453
  .filter((d) => d.severity === 'error' || !hasError.has(`${d.rule}|${d.line}`))
1430
1454
  .sort((a, b) => rank[a.severity] - rank[b.severity] || a.line - b.line);
1431
1455
  }
1456
+ /**
1457
+ * The file to check, from a tool call's arguments. The schema names it
1458
+ * `source`, but models guess `code` first and `content` second; answering to
1459
+ * those costs nothing and saves the caller a failed round trip.
1460
+ */
1461
+ export function sourceArg(args) {
1462
+ for (const key of ['source', 'code', 'content']) {
1463
+ const v = args[key];
1464
+ if (typeof v === 'string' && v.trim())
1465
+ return v;
1466
+ }
1467
+ return undefined;
1468
+ }
1432
1469
  /**
1433
1470
  * Check a snippet and report what a model should do next. `compile` is the
1434
1471
  * optional second gate: when the host can reach a Svelte compiler, real parse
package/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "type": "commercial",
6
6
  "url": "https://svgrid.com/pricing"
7
7
  },
8
- "version": "3.0.33",
9
- "description": "Model Context Protocol server for SvGrid, the Svelte 5 data grid: checks the code your AI writes against the real API surface, plus version-pinned docs, API reference and 373 demo sources.",
8
+ "version": "3.0.34",
9
+ "description": "Model Context Protocol server for SvGrid, the Svelte 5 data grid: checks the code your AI writes against the real API surface, plus version-pinned docs, API reference and the source of every live demo.",
10
10
  "license": "MIT",
11
11
  "author": "jQWidgets <sales@jqwidgets.com>",
12
12
  "homepage": "https://svgrid.com/docs/help/mcp-server/",
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "com.svgrid/svgrid",
4
4
  "title": "SvGrid",
5
5
  "description": "Checks AI-written SvGrid code against the real API, plus version-pinned Svelte 5 grid docs.",
6
- "version": "3.0.33",
6
+ "version": "3.0.34",
7
7
  "websiteUrl": "https://svgrid.com/docs/help/mcp-server/",
8
8
  "repository": {
9
9
  "url": "https://github.com/sv-grid/sv-grid",
@@ -15,7 +15,7 @@
15
15
  "registryType": "npm",
16
16
  "registryBaseUrl": "https://registry.npmjs.org",
17
17
  "identifier": "@svgrid/mcp",
18
- "version": "3.0.33",
18
+ "version": "3.0.34",
19
19
  "runtimeHint": "npx",
20
20
  "transport": {
21
21
  "type": "stdio"