@lism-css/mcp 0.10.4 → 0.12.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.
Files changed (39) hide show
  1. package/README.ja.md +4 -2
  2. package/README.md +4 -2
  3. package/dist/data/docs-index.json +282 -64
  4. package/dist/data/guides/SKILL.md +113 -0
  5. package/dist/data/guides/base-styles.md +106 -0
  6. package/dist/data/guides/components-core.md +338 -0
  7. package/dist/data/guides/components-ui.md +351 -0
  8. package/dist/data/guides/css-rules.md +146 -0
  9. package/dist/data/guides/module-class.md +162 -0
  10. package/dist/data/guides/prop-responsive.md +54 -0
  11. package/dist/data/guides/property-class.md +400 -0
  12. package/dist/data/guides/set-class.md +190 -0
  13. package/dist/data/guides/tokens.md +210 -0
  14. package/dist/data/guides/utility-class.md +81 -0
  15. package/dist/data/meta.js +2 -2
  16. package/dist/index.js +4 -0
  17. package/dist/lib/load-data.js +2 -11
  18. package/dist/lib/load-markdown.d.ts +6 -0
  19. package/dist/lib/load-markdown.js +29 -0
  20. package/dist/lib/markdown-utils.d.ts +42 -0
  21. package/dist/lib/markdown-utils.js +158 -0
  22. package/dist/lib/schemas.d.ts +0 -242
  23. package/dist/lib/schemas.js +0 -64
  24. package/dist/lib/search.d.ts +2 -16
  25. package/dist/lib/search.js +9 -68
  26. package/dist/lib/types.d.ts +0 -64
  27. package/dist/tools/convert-css.js +96 -55
  28. package/dist/tools/get-component.js +60 -29
  29. package/dist/tools/get-guide.d.ts +2 -0
  30. package/dist/tools/get-guide.js +45 -0
  31. package/dist/tools/get-overview.js +26 -39
  32. package/dist/tools/get-props-system.js +45 -33
  33. package/dist/tools/get-tokens.js +9 -14
  34. package/dist/tools/search-docs.js +27 -9
  35. package/package.json +2 -2
  36. package/dist/data/components.json +0 -564
  37. package/dist/data/overview.json +0 -114
  38. package/dist/data/props-system.json +0 -1154
  39. package/dist/data/tokens.json +0 -152
@@ -1,12 +1,33 @@
1
1
  import { z } from 'zod';
2
2
  import { loadJSON } from '../lib/load-data.js';
3
- import { DocsEntrySchema, ComponentInfoSchema, PropsSystemDataSchema } from '../lib/schemas.js';
4
- import { buildAliasMap, buildCssPropertyMap, searchDocs } from '../lib/search.js';
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
8
  const DOC_CATEGORIES = ['all', 'core-components', 'modules', 'props', '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. Use this when other tools don't return the information you need, or to discover available components and features.",
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 components = loadJSON('components.json', z.array(ComponentInfoSchema));
20
- const propsData = loadJSON('props-system.json', PropsSystemDataSchema);
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. Ensure the server was installed correctly.`);
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.10.4",
3
+ "version": "0.12.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/*.json dist/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
  }