@svgrid/mcp 3.0.32 → 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/compile-core.d.ts +24 -0
- package/dist/compile-core.js +27 -0
- package/dist/compile-svelte.js +2 -26
- package/dist/data.js +104 -75
- package/dist/index.js +21 -19
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js +1 -1
- package/dist/stdio-server.d.ts +60 -0
- package/dist/stdio-server.js +95 -0
- package/dist/tool-defs.d.ts +12 -0
- package/dist/tool-defs.js +15 -0
- package/dist/validate.d.ts +6 -0
- package/dist/validate.js +37 -0
- package/package.json +5 -7
- package/server.json +2 -2
package/dist/index.js
CHANGED
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
* npx @svgrid/mcp
|
|
19
19
|
*/
|
|
20
20
|
import { createRequire } from 'node:module';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import {
|
|
24
|
-
import { CORE_TOOLS, PREVIEW_TOOL } from './tool-defs.js';
|
|
21
|
+
// Our own stdio transport, not @modelcontextprotocol/sdk: the SDK's HTTP and
|
|
22
|
+
// OAuth dependencies were most of a cold npx install (see stdio-server.ts).
|
|
23
|
+
import { StdioMcpServer } from './stdio-server.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;
|
|
@@ -101,11 +101,12 @@ const pkgVersion = (() => {
|
|
|
101
101
|
return '0.0.0';
|
|
102
102
|
}
|
|
103
103
|
})();
|
|
104
|
-
const server = new
|
|
104
|
+
const server = new StdioMcpServer({ name: '@svgrid/mcp', version: pkgVersion }, {
|
|
105
105
|
// Tools alone was half the protocol. The corpus is a natural fit for
|
|
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 = {
|
|
@@ -152,7 +153,7 @@ async function listedTools() {
|
|
|
152
153
|
tools.push(...studioTools.STUDIO_TOOLS);
|
|
153
154
|
return tools;
|
|
154
155
|
}
|
|
155
|
-
server.setRequestHandler(
|
|
156
|
+
server.setRequestHandler('tools/list', async () => {
|
|
156
157
|
const tools = await listedTools();
|
|
157
158
|
// Warm the corpus once this reply is on the wire, so its first load overlaps
|
|
158
159
|
// the model choosing a tool rather than the first call.
|
|
@@ -160,8 +161,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
160
161
|
return { tools };
|
|
161
162
|
});
|
|
162
163
|
// ---- resources ------------------------------------------------------------
|
|
163
|
-
server.setRequestHandler(
|
|
164
|
-
server.setRequestHandler(
|
|
164
|
+
server.setRequestHandler('resources/list', async (req) => (await corpus()).resources.listResources(req.params?.cursor));
|
|
165
|
+
server.setRequestHandler('resources/read', async (req) => {
|
|
165
166
|
const { preview, resources } = await corpus();
|
|
166
167
|
const found = preview.readPreviewResource(req.params.uri) ?? resources.readResource(req.params.uri);
|
|
167
168
|
if (!found)
|
|
@@ -169,8 +170,8 @@ server.setRequestHandler(ReadResourceRequestSchema, async (req) => {
|
|
|
169
170
|
return found;
|
|
170
171
|
});
|
|
171
172
|
// ---- prompts --------------------------------------------------------------
|
|
172
|
-
server.setRequestHandler(
|
|
173
|
-
server.setRequestHandler(
|
|
173
|
+
server.setRequestHandler('prompts/list', async () => ({ prompts: PROMPTS }));
|
|
174
|
+
server.setRequestHandler('prompts/get', async (req) => {
|
|
174
175
|
const found = getPrompt(req.params.name, (req.params.arguments ?? {}));
|
|
175
176
|
if (!found)
|
|
176
177
|
throw new Error(`No SvGrid prompt named "${req.params.name}".`);
|
|
@@ -178,10 +179,9 @@ server.setRequestHandler(GetPromptRequestSchema, async (req) => {
|
|
|
178
179
|
});
|
|
179
180
|
// ---- tool calls -----------------------------------------------------------
|
|
180
181
|
async function runCheck(args) {
|
|
181
|
-
const source = args
|
|
182
|
-
if (
|
|
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,
|
|
@@ -284,8 +284,11 @@ const LEGACY_TARGET = {
|
|
|
284
284
|
get_doc: 'svgrid_get',
|
|
285
285
|
get_api_reference: 'svgrid_get',
|
|
286
286
|
};
|
|
287
|
-
server.setRequestHandler(
|
|
287
|
+
server.setRequestHandler('tools/call', async (req) => {
|
|
288
288
|
const { name, arguments: rawArgs } = req.params;
|
|
289
|
+
// As the SDK answered it: a call that names no tool is invalid params.
|
|
290
|
+
if (typeof name !== 'string')
|
|
291
|
+
throw Object.assign(new Error('Invalid params: tools/call needs a tool name'), { code: -32602 });
|
|
289
292
|
const args = (rawArgs ?? {});
|
|
290
293
|
const [{ core: coreTools, preview }] = await Promise.all([corpus(), loadStudio()]);
|
|
291
294
|
// Retrieval tools, old names mapped onto the new ones.
|
|
@@ -346,13 +349,12 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
346
349
|
};
|
|
347
350
|
});
|
|
348
351
|
async function main() {
|
|
349
|
-
// Connect and nothing else: `initialize` is answered by the
|
|
350
|
-
// neither the corpus nor enterprise. They load on the first request that
|
|
352
|
+
// Connect and nothing else: `initialize` is answered by the transport and
|
|
353
|
+
// needs neither the corpus nor enterprise. They load on the first request that
|
|
351
354
|
// does (normally tools/list). Loading them eagerly after connect did not
|
|
352
355
|
// help: the first read of the 12 MB corpus held the event loop for seconds,
|
|
353
356
|
// and the initialize reply waited behind it.
|
|
354
|
-
|
|
355
|
-
await server.connect(transport);
|
|
357
|
+
server.connect();
|
|
356
358
|
process.stderr.write(`@svgrid/mcp ${pkgVersion} on stdio\n`);
|
|
357
359
|
}
|
|
358
360
|
/** The fuller banner, once the corpus is in, naming both grid versions. */
|
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.
|
|
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.
|
|
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
|
/**
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP stdio transport this server needs, in place of
|
|
3
|
+
* @modelcontextprotocol/sdk.
|
|
4
|
+
*
|
|
5
|
+
* The SDK carries HTTP transports and OAuth (Express, Hono, JOSE, AJV and
|
|
6
|
+
* their dependencies), none of which a stdio server runs, and a cold
|
|
7
|
+
* `npx -y @svgrid/mcp` spent its time installing them: 111 packages, 23 to 38
|
|
8
|
+
* seconds to the `initialize` reply against a client's 30 second connect
|
|
9
|
+
* timeout, with the server itself starting in 0.3 s.
|
|
10
|
+
*
|
|
11
|
+
* What MCP over stdio is: JSON-RPC 2.0, one message per line on stdin and
|
|
12
|
+
* stdout. This answers `initialize` the way the SDK does (the client's
|
|
13
|
+
* protocol version when it is one of SUPPORTED_PROTOCOL_VERSIONS, else the
|
|
14
|
+
* latest), answers `ping`, and hands every other request to the handler
|
|
15
|
+
* registered for its method. Unknown methods get -32601 and a handler that
|
|
16
|
+
* throws gets -32603 with its message, as from the SDK. Notifications need no
|
|
17
|
+
* reply: `notifications/initialized` and `notifications/cancelled` are
|
|
18
|
+
* accepted and nothing else is sent. Requests run concurrently, as the SDK
|
|
19
|
+
* runs them, so a slow first tools/call does not hold up a ping.
|
|
20
|
+
*/
|
|
21
|
+
import type { Readable, Writable } from 'node:stream';
|
|
22
|
+
export declare const LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
23
|
+
export declare const SUPPORTED_PROTOCOL_VERSIONS: string[];
|
|
24
|
+
export declare const ErrorCode: {
|
|
25
|
+
readonly ParseError: -32700;
|
|
26
|
+
readonly InvalidRequest: -32600;
|
|
27
|
+
readonly MethodNotFound: -32601;
|
|
28
|
+
readonly InvalidParams: -32602;
|
|
29
|
+
readonly InternalError: -32603;
|
|
30
|
+
};
|
|
31
|
+
/** A request as a handler receives it, the same shape the SDK passed. */
|
|
32
|
+
export type McpRequest = {
|
|
33
|
+
method: string;
|
|
34
|
+
params: Record<string, any>;
|
|
35
|
+
};
|
|
36
|
+
type Handler = (request: McpRequest) => unknown | Promise<unknown>;
|
|
37
|
+
export declare class StdioMcpServer {
|
|
38
|
+
private readonly serverInfo;
|
|
39
|
+
private readonly options;
|
|
40
|
+
private readonly handlers;
|
|
41
|
+
constructor(serverInfo: {
|
|
42
|
+
name: string;
|
|
43
|
+
version: string;
|
|
44
|
+
}, options: {
|
|
45
|
+
capabilities: Record<string, unknown>;
|
|
46
|
+
instructions?: string;
|
|
47
|
+
});
|
|
48
|
+
setRequestHandler(method: string, handler: Handler): void;
|
|
49
|
+
/**
|
|
50
|
+
* The reply to one message, or null when none is owed (a notification).
|
|
51
|
+
* Exported for tests; connect() feeds it each line.
|
|
52
|
+
*/
|
|
53
|
+
handle(message: unknown): Promise<object | null>;
|
|
54
|
+
/** Read requests from `input`, one per line, and write the replies to `output`. */
|
|
55
|
+
connect(input?: Readable, output?: Writable): void;
|
|
56
|
+
private initialize;
|
|
57
|
+
private result;
|
|
58
|
+
private error;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export const LATEST_PROTOCOL_VERSION = '2025-11-25';
|
|
2
|
+
export const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, '2025-06-18', '2025-03-26', '2024-11-05', '2024-10-07'];
|
|
3
|
+
export const ErrorCode = {
|
|
4
|
+
ParseError: -32700,
|
|
5
|
+
InvalidRequest: -32600,
|
|
6
|
+
MethodNotFound: -32601,
|
|
7
|
+
InvalidParams: -32602,
|
|
8
|
+
InternalError: -32603,
|
|
9
|
+
};
|
|
10
|
+
export class StdioMcpServer {
|
|
11
|
+
serverInfo;
|
|
12
|
+
options;
|
|
13
|
+
handlers = new Map();
|
|
14
|
+
constructor(serverInfo, options) {
|
|
15
|
+
this.serverInfo = serverInfo;
|
|
16
|
+
this.options = options;
|
|
17
|
+
}
|
|
18
|
+
setRequestHandler(method, handler) {
|
|
19
|
+
this.handlers.set(method, handler);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The reply to one message, or null when none is owed (a notification).
|
|
23
|
+
* Exported for tests; connect() feeds it each line.
|
|
24
|
+
*/
|
|
25
|
+
async handle(message) {
|
|
26
|
+
const m = (message ?? {});
|
|
27
|
+
const isRequest = m.id !== undefined && m.id !== null;
|
|
28
|
+
if (typeof m.method !== 'string') {
|
|
29
|
+
return isRequest ? this.error(m.id, ErrorCode.InvalidRequest, 'Invalid request: no method') : null;
|
|
30
|
+
}
|
|
31
|
+
// A notification never gets a reply, whatever it is.
|
|
32
|
+
if (!isRequest)
|
|
33
|
+
return null;
|
|
34
|
+
const params = m.params && typeof m.params === 'object' ? m.params : {};
|
|
35
|
+
try {
|
|
36
|
+
if (m.method === 'initialize')
|
|
37
|
+
return this.result(m.id, this.initialize(params));
|
|
38
|
+
if (m.method === 'ping')
|
|
39
|
+
return this.result(m.id, {});
|
|
40
|
+
const handler = this.handlers.get(m.method);
|
|
41
|
+
if (!handler)
|
|
42
|
+
return this.error(m.id, ErrorCode.MethodNotFound, `Method not found: ${m.method}`);
|
|
43
|
+
return this.result(m.id, (await handler({ method: m.method, params })) ?? {});
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
const e = err;
|
|
47
|
+
const code = Number.isSafeInteger(e?.code) ? e.code : ErrorCode.InternalError;
|
|
48
|
+
return this.error(m.id, code, e?.message ?? String(err), e?.data);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Read requests from `input`, one per line, and write the replies to `output`. */
|
|
52
|
+
connect(input = process.stdin, output = process.stdout) {
|
|
53
|
+
let buffer = '';
|
|
54
|
+
const send = (reply) => {
|
|
55
|
+
if (reply)
|
|
56
|
+
output.write(JSON.stringify(reply) + '\n');
|
|
57
|
+
};
|
|
58
|
+
input.setEncoding('utf8');
|
|
59
|
+
input.on('data', (chunk) => {
|
|
60
|
+
buffer += chunk;
|
|
61
|
+
let nl;
|
|
62
|
+
while ((nl = buffer.indexOf('\n')) !== -1) {
|
|
63
|
+
const line = buffer.slice(0, nl).replace(/\r$/, '');
|
|
64
|
+
buffer = buffer.slice(nl + 1);
|
|
65
|
+
if (!line.trim())
|
|
66
|
+
continue;
|
|
67
|
+
let message;
|
|
68
|
+
try {
|
|
69
|
+
message = JSON.parse(line);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
send(this.error(null, ErrorCode.ParseError, 'Parse error: a line was not JSON'));
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
// Not awaited: each request answers when it is ready.
|
|
76
|
+
void this.handle(message).then(send, (err) => process.stderr.write(`@svgrid/mcp: ${String(err)}\n`));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
initialize(params) {
|
|
81
|
+
const requested = params.protocolVersion;
|
|
82
|
+
return {
|
|
83
|
+
protocolVersion: SUPPORTED_PROTOCOL_VERSIONS.includes(requested) ? requested : LATEST_PROTOCOL_VERSION,
|
|
84
|
+
capabilities: this.options.capabilities,
|
|
85
|
+
serverInfo: this.serverInfo,
|
|
86
|
+
...(this.options.instructions ? { instructions: this.options.instructions } : {}),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
result(id, result) {
|
|
90
|
+
return { jsonrpc: '2.0', id, result };
|
|
91
|
+
}
|
|
92
|
+
error(id, code, message, data) {
|
|
93
|
+
return { jsonrpc: '2.0', id, error: { code, message, ...(data !== undefined ? { data } : {}) } };
|
|
94
|
+
}
|
|
95
|
+
}
|
package/dist/tool-defs.d.ts
CHANGED
|
@@ -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 = [
|
package/dist/validate.d.ts
CHANGED
|
@@ -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.
|
|
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
|
|
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/",
|
|
@@ -30,12 +30,10 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"
|
|
34
|
-
"svelte": "^5.55.5",
|
|
35
|
-
"zod": "^3.23.8"
|
|
33
|
+
"svelte": "^5.55.5"
|
|
36
34
|
},
|
|
37
35
|
"peerDependencies": {
|
|
38
|
-
"@svgrid/enterprise": "^3.1.
|
|
36
|
+
"@svgrid/enterprise": "^3.1.27"
|
|
39
37
|
},
|
|
40
38
|
"peerDependenciesMeta": {
|
|
41
39
|
"@svgrid/enterprise": {
|
|
@@ -45,7 +43,7 @@
|
|
|
45
43
|
"devDependencies": {
|
|
46
44
|
"@types/node": "^22.10.7",
|
|
47
45
|
"typescript": "6.0.3",
|
|
48
|
-
"@svgrid/enterprise": "^3.1.
|
|
46
|
+
"@svgrid/enterprise": "^3.1.27"
|
|
49
47
|
},
|
|
50
48
|
"engines": {
|
|
51
49
|
"node": ">=18"
|
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.
|
|
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.
|
|
18
|
+
"version": "3.0.34",
|
|
19
19
|
"runtimeHint": "npx",
|
|
20
20
|
"transport": {
|
|
21
21
|
"type": "stdio"
|