@symbo.ls/mcp-server 3.6.8 → 3.7.0
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/package.json +1 -1
- package/src/mcp-handler.js +218 -11
- package/src/worker-handler.js +1 -1
package/package.json
CHANGED
package/src/mcp-handler.js
CHANGED
|
@@ -33,15 +33,33 @@ function listSkillFiles() {
|
|
|
33
33
|
const V2_PATTERNS = [
|
|
34
34
|
[/\bextend\s*:/g, "v2 syntax: use 'extends' (plural) instead of 'extend'"],
|
|
35
35
|
[/\bchildExtend\s*:/g, "v2 syntax: use 'childExtends' (plural) instead of 'childExtend'"],
|
|
36
|
-
[
|
|
37
|
-
|
|
36
|
+
[
|
|
37
|
+
/\bon\s*:\s*\{/g,
|
|
38
|
+
'v2 syntax: flatten event handlers with onX prefix (e.g. onClick) instead of on: {} wrapper',
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
/\bprops\s*:\s*\{(?!\s*\})/g,
|
|
42
|
+
'v2 syntax: flatten props directly on the component instead of props: {} wrapper',
|
|
43
|
+
],
|
|
38
44
|
];
|
|
39
45
|
|
|
40
46
|
const RULE_CHECKS = [
|
|
41
|
-
[
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
[
|
|
48
|
+
/\bimport\s+.*\bfrom\s+['"]\.\//,
|
|
49
|
+
'FORBIDDEN: No imports between project files — reference components by PascalCase key name',
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
/\bexport\s+default\s+\{/,
|
|
53
|
+
'Components should use named exports (export const Name = {}), not default exports',
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
/\bfunction\s+\w+\s*\(.*\)\s*\{[\s\S]*?return\s*\{/,
|
|
57
|
+
'Components must be plain objects, not functions that return objects',
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
/(?:padding|margin|gap|width|height)\s*:\s*['"]?\d+px/,
|
|
61
|
+
'Use design tokens (A, B, C) instead of hardcoded pixel values',
|
|
62
|
+
],
|
|
45
63
|
];
|
|
46
64
|
|
|
47
65
|
function auditCode(code) {
|
|
@@ -194,6 +212,51 @@ const TOOLS = [
|
|
|
194
212
|
required: ['component_code'],
|
|
195
213
|
},
|
|
196
214
|
},
|
|
215
|
+
{
|
|
216
|
+
name: 'detect_environment',
|
|
217
|
+
description:
|
|
218
|
+
'Detect what type of Symbols environment the user is working in (local project, CDN, JSON runtime, or remote server) based on project indicators, and return the appropriate setup guide and code format.',
|
|
219
|
+
inputSchema: {
|
|
220
|
+
type: 'object',
|
|
221
|
+
properties: {
|
|
222
|
+
has_symbols_json: {
|
|
223
|
+
type: 'boolean',
|
|
224
|
+
description: 'Whether symbols.json exists in the project root',
|
|
225
|
+
},
|
|
226
|
+
has_symbols_dir: {
|
|
227
|
+
type: 'boolean',
|
|
228
|
+
description: 'Whether a symbols/ directory exists with components/, pages/, etc.',
|
|
229
|
+
},
|
|
230
|
+
has_package_json: {
|
|
231
|
+
type: 'boolean',
|
|
232
|
+
description: 'Whether package.json exists with smbls dependency',
|
|
233
|
+
},
|
|
234
|
+
has_cdn_import: {
|
|
235
|
+
type: 'boolean',
|
|
236
|
+
description:
|
|
237
|
+
'Whether HTML files contain CDN imports (esm.sh/smbls, cdn.jsdelivr.net/npm/smbls, etc.)',
|
|
238
|
+
},
|
|
239
|
+
has_iife_script: {
|
|
240
|
+
type: 'boolean',
|
|
241
|
+
description: 'Whether HTML files use <script src="...smbls"> (IIFE global)',
|
|
242
|
+
},
|
|
243
|
+
has_json_data: {
|
|
244
|
+
type: 'boolean',
|
|
245
|
+
description: 'Whether the project uses frank-generated JSON data files',
|
|
246
|
+
},
|
|
247
|
+
has_mermaid_config: {
|
|
248
|
+
type: 'boolean',
|
|
249
|
+
description:
|
|
250
|
+
'Whether mermaid/wrangler config or GATEWAY_URL/JSON_PATH env vars are present',
|
|
251
|
+
},
|
|
252
|
+
file_list: {
|
|
253
|
+
type: 'string',
|
|
254
|
+
description:
|
|
255
|
+
'Comma-separated list of key files in the project root (e.g. "index.html,package.json,symbols.json")',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
197
260
|
];
|
|
198
261
|
|
|
199
262
|
function callTool(name, args = {}) {
|
|
@@ -237,26 +300,52 @@ function callTool(name, args = {}) {
|
|
|
237
300
|
if (name === 'generate_component') {
|
|
238
301
|
const desc = args.description || '';
|
|
239
302
|
const compName = args.component_name || 'MyComponent';
|
|
240
|
-
const context = readSkills(
|
|
303
|
+
const context = readSkills(
|
|
304
|
+
'RULES.md',
|
|
305
|
+
'COMPONENTS.md',
|
|
306
|
+
'SYNTAX.md',
|
|
307
|
+
'COOKBOOK.md',
|
|
308
|
+
'DEFAULT_LIBRARY.md',
|
|
309
|
+
);
|
|
241
310
|
return `# Generate Component: ${compName}\n\n## Description\n${desc}\n\n## Requirements\n- Named export: \`export const ${compName} = { ... }\`\n- DOMQL v3 syntax only (extends, childExtends, flattened props, onX events)\n- Use design tokens for spacing (A, B, C), colors from theme\n- NO imports between files — PascalCase keys auto-extend registered components\n- Include responsive breakpoints where appropriate (@tabletS, @mobileL)\n- Use the default library components (Button, Avatar, Icon, Field, etc.) via extends\n- Follow modern UI/UX: visual hierarchy, confident typography, minimal cognitive load\n\n## Context — Rules, Syntax & Examples\n\n${context}`;
|
|
242
311
|
}
|
|
243
312
|
|
|
244
313
|
if (name === 'generate_page') {
|
|
245
314
|
const desc = args.description || '';
|
|
246
315
|
const pageName = args.page_name || 'home';
|
|
247
|
-
const context = readSkills(
|
|
316
|
+
const context = readSkills(
|
|
317
|
+
'RULES.md',
|
|
318
|
+
'PROJECT_STRUCTURE.md',
|
|
319
|
+
'PATTERNS.md',
|
|
320
|
+
'SNIPPETS.md',
|
|
321
|
+
'DEFAULT_LIBRARY.md',
|
|
322
|
+
'COMPONENTS.md',
|
|
323
|
+
);
|
|
248
324
|
return `# Generate Page: ${pageName}\n\n## Description\n${desc}\n\n## Requirements\n- Export as: \`export const ${pageName} = { ... }\`\n- Page is a plain object composing components\n- Add to pages/index.js route map: \`'/${pageName}': ${pageName}\`\n- Use components by PascalCase key (Header, Footer, Hero, etc.)\n- Use design tokens — no hardcoded pixels\n- Include responsive layout adjustments\n\n## Context — Rules, Structure, Patterns & Snippets\n\n${context}`;
|
|
249
325
|
}
|
|
250
326
|
|
|
251
327
|
if (name === 'convert_react') {
|
|
252
328
|
const source = args.source_code || '';
|
|
253
|
-
const context = readSkills(
|
|
329
|
+
const context = readSkills(
|
|
330
|
+
'RULES.md',
|
|
331
|
+
'MIGRATION.md',
|
|
332
|
+
'SYNTAX.md',
|
|
333
|
+
'COMPONENTS.md',
|
|
334
|
+
'LEARNINGS.md',
|
|
335
|
+
);
|
|
254
336
|
return `# Convert React → Symbols DOMQL v3\n\n## Source Code to Convert\n\`\`\`jsx\n${source}\n\`\`\`\n\n## Conversion Rules\n- Function/class components → plain object exports\n- JSX → nested object children (PascalCase keys auto-extend)\n- import/export between files → REMOVE (reference by key name)\n- useState → state: { key: val } + s.update({ key: newVal })\n- useEffect → onRender (mount), onStateUpdate (deps)\n- props → flattened directly on component (no props wrapper)\n- onClick={handler} → onClick: (event, el, state) => {}\n- className → use design tokens and theme directly\n- map() → children: (el, s) => s.items, childExtends, childProps\n- conditional rendering → if: (el, s) => boolean\n- CSS modules/styled → CSS-in-props with design tokens\n- React.Fragment → not needed, just nest children\n\n## Context — Migration Guide, Syntax & Rules\n\n${context}`;
|
|
255
337
|
}
|
|
256
338
|
|
|
257
339
|
if (name === 'convert_html') {
|
|
258
340
|
const source = args.source_code || '';
|
|
259
|
-
const context = readSkills(
|
|
341
|
+
const context = readSkills(
|
|
342
|
+
'RULES.md',
|
|
343
|
+
'SYNTAX.md',
|
|
344
|
+
'COMPONENTS.md',
|
|
345
|
+
'DESIGN_SYSTEM.md',
|
|
346
|
+
'SNIPPETS.md',
|
|
347
|
+
'LEARNINGS.md',
|
|
348
|
+
);
|
|
260
349
|
return `# Convert HTML → Symbols DOMQL v3\n\n## Source Code to Convert\n\`\`\`html\n${source}\n\`\`\`\n\n## Conversion Rules\n- <div> → Box, Flex, or Grid (based on layout purpose)\n- <span>, <p>, <h1>-<h6> → Text, P, H with tag property\n- <a> → Link (has built-in SPA router)\n- <button> → Button (has icon/text support)\n- <input> → Input, Radio, Checkbox (based on type)\n- <img> → Img\n- <form> → Form (extends Box with tag: 'form')\n- <ul>/<ol> + <li> → children array with childExtends\n- CSS classes → flatten as CSS-in-props on the component\n- CSS px values → design tokens (16px → 'A', 26px → 'B', 42px → 'C')\n- CSS colors → theme color tokens\n- media queries → @tabletS, @mobileL, @screenS breakpoints\n- id/class attributes → not needed (use key names and themes)\n- inline styles → flatten as component properties\n- <style> blocks → distribute to component-level properties\n\n## Context — Syntax, Components & Design System\n\n${context}`;
|
|
261
350
|
}
|
|
262
351
|
|
|
@@ -287,6 +376,115 @@ function callTool(name, args = {}) {
|
|
|
287
376
|
return output;
|
|
288
377
|
}
|
|
289
378
|
|
|
379
|
+
if (name === 'detect_environment') {
|
|
380
|
+
const {
|
|
381
|
+
has_symbols_json,
|
|
382
|
+
has_symbols_dir,
|
|
383
|
+
has_package_json,
|
|
384
|
+
has_cdn_import,
|
|
385
|
+
has_iife_script,
|
|
386
|
+
has_json_data,
|
|
387
|
+
has_mermaid_config,
|
|
388
|
+
file_list,
|
|
389
|
+
} = args;
|
|
390
|
+
|
|
391
|
+
// Detect environment type
|
|
392
|
+
let envType = 'unknown';
|
|
393
|
+
let confidence = 'low';
|
|
394
|
+
|
|
395
|
+
if (has_mermaid_config) {
|
|
396
|
+
envType = 'remote_server';
|
|
397
|
+
confidence = 'high';
|
|
398
|
+
} else if (has_json_data) {
|
|
399
|
+
envType = 'json_runtime';
|
|
400
|
+
confidence = 'high';
|
|
401
|
+
} else if (has_symbols_json && has_symbols_dir) {
|
|
402
|
+
envType = 'local_project';
|
|
403
|
+
confidence = 'high';
|
|
404
|
+
} else if (has_symbols_dir || (has_package_json && has_symbols_json)) {
|
|
405
|
+
envType = 'local_project';
|
|
406
|
+
confidence = 'medium';
|
|
407
|
+
} else if (has_cdn_import || has_iife_script) {
|
|
408
|
+
envType = 'cdn';
|
|
409
|
+
confidence = 'high';
|
|
410
|
+
} else if (has_package_json) {
|
|
411
|
+
envType = 'local_project';
|
|
412
|
+
confidence = 'low';
|
|
413
|
+
} else if (file_list) {
|
|
414
|
+
const files = file_list.toLowerCase();
|
|
415
|
+
if (
|
|
416
|
+
files.includes('index.html') &&
|
|
417
|
+
!files.includes('package.json') &&
|
|
418
|
+
!files.includes('symbols.json')
|
|
419
|
+
) {
|
|
420
|
+
envType = 'cdn';
|
|
421
|
+
confidence = 'medium';
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// Build response with appropriate guide
|
|
426
|
+
const fullGuide = readSkill('RUNNING_APPS.md');
|
|
427
|
+
let output = `# Environment Detection\n\n**Detected: ${envType}** (confidence: ${confidence})\n\n`;
|
|
428
|
+
|
|
429
|
+
if (envType === 'local_project') {
|
|
430
|
+
output += `## Your Environment: Local Project\n\n`;
|
|
431
|
+
output += `You're working in a standard Symbols project with file-based structure.\n\n`;
|
|
432
|
+
output += `### Code Format\n`;
|
|
433
|
+
output += `- Components: \`export const Name = { extends: 'Flex', ... }\` in \`components/\`\n`;
|
|
434
|
+
output += `- Pages: \`export const pageName = { extends: 'Page', ... }\` in \`pages/\`\n`;
|
|
435
|
+
output += `- State: \`export default { key: value }\` in \`state.js\`\n`;
|
|
436
|
+
output += `- Functions: \`export const fn = function() {}\` in \`functions/\`\n`;
|
|
437
|
+
output += `- No imports between files (except pages/index.js)\n\n`;
|
|
438
|
+
output += `### Commands\n`;
|
|
439
|
+
output += `\`\`\`bash\nnpm start # dev server\nsmbls build # production build\nsmbls push # deploy to platform\nsmbls deploy # deploy to provider\n\`\`\`\n\n`;
|
|
440
|
+
const structureGuide = readSkill('PROJECT_STRUCTURE.md');
|
|
441
|
+
output += `### Full Project Structure Reference\n\n${structureGuide}`;
|
|
442
|
+
} else if (envType === 'cdn') {
|
|
443
|
+
output += `## Your Environment: CDN (Browser-Only)\n\n`;
|
|
444
|
+
output += `You're running Symbols directly in the browser via CDN import.\n\n`;
|
|
445
|
+
output += `### Code Format\n`;
|
|
446
|
+
output += `- Single HTML file with \`<script type="module">\`\n`;
|
|
447
|
+
output += `- Import: \`import { create } from 'https://esm.sh/smbls'\`\n`;
|
|
448
|
+
output += `- Define app as inline object tree\n`;
|
|
449
|
+
output += `- Mount: \`create(App, { designSystem, components, functions, state })\`\n`;
|
|
450
|
+
output += `- Components defined as JS variables (no file-based registry)\n\n`;
|
|
451
|
+
output += `### Limitations\n`;
|
|
452
|
+
output += `- No file-based routing (use tab/view switching)\n`;
|
|
453
|
+
output += `- No SSR\n`;
|
|
454
|
+
output += `- \`childExtends: 'Name'\` needs components passed to \`create()\`\n\n`;
|
|
455
|
+
const cdnGuide = readSkill('RUNNING_APPS.md');
|
|
456
|
+
output += `### Full CDN Reference\n\n${cdnGuide}`;
|
|
457
|
+
} else if (envType === 'json_runtime') {
|
|
458
|
+
output += `## Your Environment: JSON Runtime (Frank)\n\n`;
|
|
459
|
+
output += `You're running Symbols from serialized JSON project data.\n\n`;
|
|
460
|
+
output += `### Code Format\n`;
|
|
461
|
+
output += `- Project data is a JSON object with components, pages, designSystem, state, functions\n`;
|
|
462
|
+
output += `- Functions are serialized as strings\n`;
|
|
463
|
+
output += `- Convert with: \`smbls frank to-json ./symbols\` or \`toJSON({ entry: './symbols' })\`\n`;
|
|
464
|
+
output += `- Reverse with: \`smbls frank to-fs data.json -o ./output\` or \`toFS(data, './output')\`\n`;
|
|
465
|
+
output += `- Can be loaded by Mermaid server via JSON_PATH env var\n\n`;
|
|
466
|
+
output += `### Full Reference\n\n${fullGuide}`;
|
|
467
|
+
} else if (envType === 'remote_server') {
|
|
468
|
+
output += `## Your Environment: Remote Symbols Server (Mermaid)\n\n`;
|
|
469
|
+
output += `You're working with the Mermaid rendering server for hosted Symbols apps.\n\n`;
|
|
470
|
+
output += `### URL Patterns\n`;
|
|
471
|
+
output += `- Production: \`https://app.user.preview.symbols.app/\`\n`;
|
|
472
|
+
output += `- Development: \`https://app.user.preview.dev.symbols.app/\`\n`;
|
|
473
|
+
output += `- Staging: \`https://app.user.preview.staging.symbols.app/\`\n`;
|
|
474
|
+
output += `- Legacy: \`https://app.symbo.ls/\`\n`;
|
|
475
|
+
output += `- Custom domains supported\n\n`;
|
|
476
|
+
output += `### Deployment\n`;
|
|
477
|
+
output += `\`\`\`bash\nsmbls push # deploy to Symbols platform\n\`\`\`\n\n`;
|
|
478
|
+
output += `### Full Reference\n\n${fullGuide}`;
|
|
479
|
+
} else {
|
|
480
|
+
output += `## Could Not Determine Environment\n\n`;
|
|
481
|
+
output += `Provide more details about your project files to get specific guidance.\n\n`;
|
|
482
|
+
output += `### All 4 Ways to Run Symbols Apps\n\n${fullGuide}`;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
return output;
|
|
486
|
+
}
|
|
487
|
+
|
|
290
488
|
throw new Error(`Unknown tool: ${name}`);
|
|
291
489
|
}
|
|
292
490
|
|
|
@@ -310,7 +508,16 @@ const SKILL_RESOURCES = {
|
|
|
310
508
|
'symbols://skills/cookbook': 'COOKBOOK.md',
|
|
311
509
|
'symbols://skills/snippets': 'SNIPPETS.md',
|
|
312
510
|
'symbols://skills/default-library': 'DEFAULT_LIBRARY.md',
|
|
511
|
+
'symbols://skills/default-components': 'DEFAULT_COMPONENTS.md',
|
|
313
512
|
'symbols://skills/learnings': 'LEARNINGS.md',
|
|
513
|
+
'symbols://skills/running-apps': 'RUNNING_APPS.md',
|
|
514
|
+
'symbols://skills/brand-identity': 'BRAND_IDENTITY.md',
|
|
515
|
+
'symbols://skills/design-critique': 'DESIGN_CRITIQUE.md',
|
|
516
|
+
'symbols://skills/design-system-architect': 'DESIGN_SYSTEM_ARCHITECT.md',
|
|
517
|
+
'symbols://skills/design-trend': 'DESIGN_TREND.md',
|
|
518
|
+
'symbols://skills/figma-matching': 'FIGMA_MATCHING.md',
|
|
519
|
+
'symbols://skills/marketing-assets': 'MARKETING_ASSETS.md',
|
|
520
|
+
'symbols://skills/presentation': 'PRESENTATION.md',
|
|
314
521
|
};
|
|
315
522
|
|
|
316
523
|
function listResources() {
|
|
@@ -381,7 +588,7 @@ const PROMPTS = [
|
|
|
381
588
|
// MCP JSON-RPC handler
|
|
382
589
|
// ---------------------------------------------------------------------------
|
|
383
590
|
|
|
384
|
-
const SERVER_INFO = { name: 'Symbols MCP', version: '1.1.
|
|
591
|
+
const SERVER_INFO = { name: 'Symbols MCP', version: '1.1.1' };
|
|
385
592
|
|
|
386
593
|
export function handleJsonRpc(req) {
|
|
387
594
|
const { method, params, id } = req;
|
package/src/worker-handler.js
CHANGED
|
@@ -117,7 +117,7 @@ export async function handleRequest(request) {
|
|
|
117
117
|
}
|
|
118
118
|
return json({
|
|
119
119
|
name: 'Symbols MCP',
|
|
120
|
-
version: '1.
|
|
120
|
+
version: '1.1.1',
|
|
121
121
|
description: 'MCP server for Symbols.app — documentation search and framework reference',
|
|
122
122
|
endpoints: {
|
|
123
123
|
mcp: 'POST / (Streamable HTTP transport)',
|