@lism-css/mcp 0.11.0 → 0.13.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/README.ja.md +4 -2
- package/README.md +4 -2
- package/dist/data/docs-index.json +456 -178
- package/dist/data/guides/SKILL.md +154 -0
- package/dist/data/guides/base-styles.md +106 -0
- package/dist/data/guides/components-core.md +292 -0
- package/dist/data/guides/components-ui.md +351 -0
- package/dist/data/guides/css-rules.md +166 -0
- package/dist/data/guides/primitive-class.md +148 -0
- package/dist/data/guides/primitives/a--decorator.md +45 -0
- package/dist/data/guides/primitives/a--divider.md +69 -0
- package/dist/data/guides/primitives/a--icon.md +105 -0
- package/dist/data/guides/primitives/a--spacer.md +63 -0
- package/dist/data/guides/primitives/is--boxLink.md +97 -0
- package/dist/data/guides/primitives/is--container.md +46 -0
- package/dist/data/guides/primitives/is--layer.md +71 -0
- package/dist/data/guides/primitives/is--vertical.md +52 -0
- package/dist/data/guides/primitives/is--wrapper.md +87 -0
- package/dist/data/guides/primitives/l--box.md +31 -0
- package/dist/data/guides/primitives/l--center.md +55 -0
- package/dist/data/guides/primitives/l--cluster.md +38 -0
- package/dist/data/guides/primitives/l--columns.md +72 -0
- package/dist/data/guides/primitives/l--flex.md +74 -0
- package/dist/data/guides/primitives/l--flow.md +134 -0
- package/dist/data/guides/primitives/l--fluidCols.md +68 -0
- package/dist/data/guides/primitives/l--frame.md +94 -0
- package/dist/data/guides/primitives/l--grid.md +68 -0
- package/dist/data/guides/primitives/l--sideMain.md +102 -0
- package/dist/data/guides/primitives/l--stack.md +56 -0
- package/dist/data/guides/primitives/l--switchCols.md +69 -0
- package/dist/data/guides/primitives/l--tileGrid.md +61 -0
- package/dist/data/guides/prop-responsive.md +54 -0
- package/dist/data/guides/property-class.md +401 -0
- package/dist/data/guides/set-class.md +192 -0
- package/dist/data/guides/tokens.md +228 -0
- package/dist/data/guides/utility-class.md +82 -0
- package/dist/data/meta.js +2 -2
- package/dist/index.js +4 -0
- package/dist/lib/load-data.js +2 -11
- package/dist/lib/load-markdown.d.ts +7 -0
- package/dist/lib/load-markdown.js +47 -0
- package/dist/lib/markdown-utils.d.ts +42 -0
- package/dist/lib/markdown-utils.js +158 -0
- package/dist/lib/schemas.d.ts +0 -242
- package/dist/lib/schemas.js +0 -64
- package/dist/lib/search.d.ts +2 -16
- package/dist/lib/search.js +29 -69
- package/dist/lib/types.d.ts +0 -64
- package/dist/tools/convert-css.js +96 -55
- package/dist/tools/get-component.js +150 -30
- package/dist/tools/get-guide.d.ts +2 -0
- package/dist/tools/get-guide.js +45 -0
- package/dist/tools/get-overview.js +26 -39
- package/dist/tools/get-props-system.js +45 -33
- package/dist/tools/get-tokens.js +9 -14
- package/dist/tools/search-docs.js +28 -10
- package/package.json +2 -2
- package/dist/data/components.json +0 -564
- package/dist/data/overview.json +0 -114
- package/dist/data/props-system.json +0 -1147
- package/dist/data/tokens.json +0 -148
|
@@ -1,61 +1,73 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { loadMarkdown } from '../lib/load-markdown.js';
|
|
3
|
+
import { parsePropRows } from '../lib/markdown-utils.js';
|
|
4
4
|
import { parsePropClassName } from '../lib/search.js';
|
|
5
|
-
import {
|
|
6
|
-
/** cssProperty
|
|
5
|
+
import { markdownResponse, error, notFound, READ_ONLY_ANNOTATIONS } from '../lib/response.js';
|
|
6
|
+
/** cssProperty フィールドからコア名を抽出("--hl 変数のみ" → "--hl") */
|
|
7
7
|
function normalizeCssProperty(raw) {
|
|
8
|
-
// "(class: is--container)" → "is--container"
|
|
9
|
-
const classMatch = raw.match(/\(class:\s*(.+?)\)/);
|
|
10
|
-
if (classMatch)
|
|
11
|
-
return classMatch[1].trim().toLowerCase();
|
|
12
|
-
// "--hl (CSS変数)" → "--hl"
|
|
13
8
|
return raw
|
|
14
9
|
.replace(/\s*\(.*\)$/, '')
|
|
10
|
+
.replace(/([^)]*)$/, '')
|
|
15
11
|
.trim()
|
|
16
12
|
.toLowerCase();
|
|
17
13
|
}
|
|
18
14
|
export function registerGetPropsSystem(server) {
|
|
19
15
|
server.registerTool('get_props_system', {
|
|
20
|
-
description: 'Get the lism-css Props system reference: how React/Astro props map to CSS classes and styles. Supports lookup by lism prop name (e.g. "p", "fz") OR by CSS property name (e.g. "padding", "font-size").
|
|
16
|
+
description: 'Get the lism-css Props system reference: how React/Astro props map to CSS classes and styles. Supports lookup by lism prop name (e.g. "p", "fz") OR by CSS property name (e.g. "padding", "font-size"). Omit the prop parameter to get the full reference.\n' +
|
|
17
|
+
'Use this when you need to find a specific prop mapping, understand the Property Class system, or check what CSS property a lism prop corresponds to.\n' +
|
|
18
|
+
'For bulk CSS-to-lism conversion, convert_css is more efficient. For component-specific documentation, use get_component.\n' +
|
|
19
|
+
'The response is pre-formatted Markdown. Output it verbatim. Do NOT summarize the prop tables.',
|
|
21
20
|
inputSchema: {
|
|
22
21
|
prop: z
|
|
23
22
|
.string()
|
|
24
23
|
.optional()
|
|
25
|
-
.describe('Prop name or CSS property name to look up. Accepts lism prop names (e.g. "p", "fz", "bgc") and standard CSS property names (e.g. "padding", "font-size", "background-color"). Omit to get the full
|
|
24
|
+
.describe('Prop name or CSS property name to look up. Accepts lism prop names (e.g. "p", "fz", "bgc") and standard CSS property names (e.g. "padding", "font-size", "background-color"). Omit to get the full reference.'),
|
|
26
25
|
},
|
|
27
26
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
28
27
|
}, ({ prop }) => {
|
|
29
28
|
try {
|
|
30
|
-
const
|
|
29
|
+
const md = loadMarkdown('property-class.md');
|
|
30
|
+
// prop 未指定: 全文を返す
|
|
31
31
|
if (!prop) {
|
|
32
|
-
return
|
|
32
|
+
return markdownResponse(md);
|
|
33
33
|
}
|
|
34
34
|
const queryLower = parsePropClassName(prop) ?? prop.toLowerCase();
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return false;
|
|
46
|
-
});
|
|
47
|
-
if (found.length > 0) {
|
|
48
|
-
matched.push({ ...cat, props: found });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
35
|
+
const rows = parsePropRows(md);
|
|
36
|
+
// 一致する行を探す
|
|
37
|
+
const matched = rows.filter((row) => {
|
|
38
|
+
if (row.prop.toLowerCase() === queryLower)
|
|
39
|
+
return true;
|
|
40
|
+
const normalizedCss = normalizeCssProperty(row.cssProperty);
|
|
41
|
+
if (normalizedCss === queryLower)
|
|
42
|
+
return true;
|
|
43
|
+
return false;
|
|
44
|
+
});
|
|
51
45
|
if (matched.length === 0) {
|
|
52
|
-
const
|
|
53
|
-
return notFound(`"${prop}" に一致する Prop が見つかりません。Lism prop 名 (例: "p", "fz") または CSS プロパティ名 (例: "padding", "font-size") で検索できます。`, { availableProps
|
|
46
|
+
const availableProps = rows.map((r) => `${r.prop} (${r.cssProperty})`);
|
|
47
|
+
return notFound(`"${prop}" に一致する Prop が見つかりません。Lism prop 名 (例: "p", "fz") または CSS プロパティ名 (例: "padding", "font-size") で検索できます。`, { availableProps });
|
|
48
|
+
}
|
|
49
|
+
// 一致したセクション名のユニーク一覧を取得
|
|
50
|
+
const sections = [...new Set(matched.map((r) => r.sectionName))];
|
|
51
|
+
// property-class.md から対象セクションを抽出して結合
|
|
52
|
+
const lines = md.split('\n');
|
|
53
|
+
const resultParts = [`## 検索結果: "${prop}"\n`];
|
|
54
|
+
for (const sectionName of sections) {
|
|
55
|
+
// セクション内の一致する行だけを含む簡易 Markdown を生成
|
|
56
|
+
const sectionRows = matched.filter((r) => r.sectionName === sectionName);
|
|
57
|
+
const header = `### ${sectionName}\n`;
|
|
58
|
+
const tableHeader = '| Prop | CSS プロパティ | プリセット値クラス | BP クラス |\n|------|--------------|-------------|-----|';
|
|
59
|
+
// 対応する元テーブル行を探して取得
|
|
60
|
+
const tableRows = sectionRows.map((row) => {
|
|
61
|
+
const pattern = new RegExp(`^\\|\\s*\`${row.prop.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}\`\\s*\\|`);
|
|
62
|
+
const originalLine = lines.find((l) => pattern.test(l));
|
|
63
|
+
return originalLine ?? `| \`${row.prop}\` | \`${row.cssProperty}\` | — | — |`;
|
|
64
|
+
});
|
|
65
|
+
resultParts.push(header + tableHeader + '\n' + tableRows.join('\n'));
|
|
54
66
|
}
|
|
55
|
-
return
|
|
67
|
+
return markdownResponse(resultParts.join('\n\n'));
|
|
56
68
|
}
|
|
57
69
|
catch (e) {
|
|
58
|
-
return error(`Failed to load props system data: ${e instanceof Error ? e.message : String(e)}. The data files may not be built yet.
|
|
70
|
+
return error(`Failed to load props system data: ${e instanceof Error ? e.message : String(e)}. The data files may not be built yet. Run "pnpm build" in packages/mcp first.`);
|
|
59
71
|
}
|
|
60
72
|
});
|
|
61
73
|
}
|
package/dist/tools/get-tokens.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TokenCategorySchema } from '../lib/schemas.js';
|
|
4
|
-
import { success, error, READ_ONLY_ANNOTATIONS } from '../lib/response.js';
|
|
5
|
-
const TOKEN_CATEGORIES = ['all', 'color', 'spacing', 'fontSize', 'shadow', 'radius', 'lineHeight', 'letterSpacing', 'fontFamily', 'zIndex'];
|
|
1
|
+
import { loadMarkdown } from '../lib/load-markdown.js';
|
|
2
|
+
import { markdownResponse, error, READ_ONLY_ANNOTATIONS } from '../lib/response.js';
|
|
6
3
|
export function registerGetTokens(server) {
|
|
7
4
|
server.registerTool('get_tokens', {
|
|
8
|
-
description: 'Get design tokens (colors, spacing, font sizes, shadows, etc.) used in lism-css.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
description: 'Get design tokens (colors, spacing, font sizes, shadows, etc.) used in lism-css. Returns the full token reference including CSS variable names and available values.\n' +
|
|
6
|
+
'Use this when you need to check available token values, variable names, or design scales (e.g. "what spacing values exist?", "what are the font size tokens?").\n' +
|
|
7
|
+
'For prop-to-CSS mappings, get_props_system is more suitable. For CSS conversion, use convert_css. Call get_overview first if you have not yet.\n' +
|
|
8
|
+
'The response is pre-formatted Markdown. Output it verbatim. Do NOT summarize or omit token values.',
|
|
12
9
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
13
|
-
}, (
|
|
10
|
+
}, () => {
|
|
14
11
|
try {
|
|
15
|
-
|
|
16
|
-
const filtered = category === 'all' ? data : data.filter((c) => c.category === category);
|
|
17
|
-
return success({ tokens: filtered });
|
|
12
|
+
return markdownResponse(loadMarkdown('tokens.md'));
|
|
18
13
|
}
|
|
19
14
|
catch (e) {
|
|
20
|
-
return error(`Failed to load tokens data: ${e instanceof Error ? e.message : String(e)}. The data files may not be built yet.
|
|
15
|
+
return error(`Failed to load tokens data: ${e instanceof Error ? e.message : String(e)}. The data files may not be built yet. Run "pnpm build" in packages/mcp first.`);
|
|
21
16
|
}
|
|
22
17
|
});
|
|
23
18
|
}
|
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { loadJSON } from '../lib/load-data.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { loadMarkdown } from '../lib/load-markdown.js';
|
|
4
|
+
import { DocsEntrySchema } from '../lib/schemas.js';
|
|
5
|
+
import { parsePropRows } from '../lib/markdown-utils.js';
|
|
6
|
+
import { searchDocs } from '../lib/search.js';
|
|
5
7
|
import { success, error, READ_ONLY_ANNOTATIONS } from '../lib/response.js';
|
|
6
|
-
const DOC_CATEGORIES = ['all', 'core-components', '
|
|
8
|
+
const DOC_CATEGORIES = ['all', 'core-components', 'primitives', 'property-class', 'ui', 'guide'];
|
|
9
|
+
/**
|
|
10
|
+
* property-class.md のテーブルから CSSプロパティ名 → Lism prop名 のマップを構築する。
|
|
11
|
+
* search.ts の buildCssPropertyMap と同じインターフェースを返す。
|
|
12
|
+
*/
|
|
13
|
+
function buildCssPropertyMapFromMarkdown(md) {
|
|
14
|
+
const map = new Map();
|
|
15
|
+
for (const row of parsePropRows(md)) {
|
|
16
|
+
const normalized = row.cssProperty.toLowerCase();
|
|
17
|
+
if (normalized.startsWith('(class:'))
|
|
18
|
+
continue;
|
|
19
|
+
const existing = map.get(normalized) ?? [];
|
|
20
|
+
existing.push(row.prop.toLowerCase());
|
|
21
|
+
map.set(normalized, existing);
|
|
22
|
+
}
|
|
23
|
+
return map;
|
|
24
|
+
}
|
|
7
25
|
export function registerSearchDocs(server) {
|
|
8
26
|
server.registerTool('search_docs', {
|
|
9
|
-
description: "Search lism-css documentation by keyword. Returns matching pages with relevance scores. Supports CSS property names (e.g. 'font-size', 'padding') which are automatically expanded to corresponding lism prop names
|
|
27
|
+
description: "Search lism-css documentation by keyword. Returns matching pages with relevance scores. Supports CSS property names (e.g. 'font-size', 'padding') which are automatically expanded to corresponding lism prop names.\n" +
|
|
28
|
+
'Use this when you cannot find information with other tools, or to discover available components, features, and guides by keyword.\n' +
|
|
29
|
+
'Do NOT use this as your first step — prefer get_component for a known component, get_props_system for a known prop, or get_guide for a specific topic. This is a fallback search tool.\n' +
|
|
30
|
+
'Returns JSON with search results including page URLs and relevance scores.',
|
|
10
31
|
inputSchema: {
|
|
11
32
|
query: z.string().describe('Search query (keywords separated by spaces). CSS property names like "font-size" are also accepted.'),
|
|
12
33
|
category: z.enum(DOC_CATEGORIES).default('all').describe('Filter by documentation category.'),
|
|
@@ -16,15 +37,12 @@ export function registerSearchDocs(server) {
|
|
|
16
37
|
}, ({ query, category, limit }) => {
|
|
17
38
|
try {
|
|
18
39
|
const entries = loadJSON('docs-index.json', z.array(DocsEntrySchema));
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const aliasMap = buildAliasMap(components);
|
|
22
|
-
const cssPropertyMap = buildCssPropertyMap(propsData.categories);
|
|
23
|
-
const results = searchDocs(entries, query, { category, limit, aliasMap, cssPropertyMap });
|
|
40
|
+
const cssPropertyMap = buildCssPropertyMapFromMarkdown(loadMarkdown('property-class.md'));
|
|
41
|
+
const results = searchDocs(entries, query, { category, limit, cssPropertyMap });
|
|
24
42
|
return success({ query, results });
|
|
25
43
|
}
|
|
26
44
|
catch (e) {
|
|
27
|
-
return error(`Failed to search docs: ${e instanceof Error ? e.message : String(e)}. The data files may not be built yet.
|
|
45
|
+
return error(`Failed to search docs: ${e instanceof Error ? e.message : String(e)}. The data files may not be built yet. Run "pnpm build" in packages/mcp first.`);
|
|
28
46
|
}
|
|
29
47
|
});
|
|
30
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lism-css/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "MCP server for lism-css documentation and API reference.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"format": "prettier --write . --ignore-path ../../.prettierignore",
|
|
26
|
-
"build": "tsc -p tsconfig.build.json && cp src/data
|
|
26
|
+
"build": "tsc -p tsconfig.build.json && cp src/data/docs-index.json dist/data/ && rm -rf dist/data/guides && cp -r ../../.claude/skills/lism-css-guide dist/data/guides",
|
|
27
27
|
"dev": "tsc --watch",
|
|
28
28
|
"test": "vitest run"
|
|
29
29
|
}
|