@lism-css/mcp 0.1.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/LICENSE +21 -0
- package/README.md +76 -0
- package/bin/lism-mcp.mjs +2 -0
- package/dist/data/components.json +366 -0
- package/dist/data/docs-index.json +646 -0
- package/dist/data/meta.d.ts +2 -0
- package/dist/data/meta.js +5 -0
- package/dist/data/overview.json +80 -0
- package/dist/data/props-system.json +596 -0
- package/dist/data/tokens.json +131 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -0
- package/dist/lib/load-data.d.ts +3 -0
- package/dist/lib/load-data.js +29 -0
- package/dist/lib/response.d.ts +14 -0
- package/dist/lib/response.js +28 -0
- package/dist/lib/schemas.d.ts +232 -0
- package/dist/lib/schemas.js +65 -0
- package/dist/lib/search.d.ts +2 -0
- package/dist/lib/search.js +57 -0
- package/dist/lib/types.d.ts +76 -0
- package/dist/lib/types.js +1 -0
- package/dist/tools/get-component.d.ts +2 -0
- package/dist/tools/get-component.js +39 -0
- package/dist/tools/get-overview.d.ts +2 -0
- package/dist/tools/get-overview.js +50 -0
- package/dist/tools/get-props-system.d.ts +2 -0
- package/dist/tools/get-props-system.js +32 -0
- package/dist/tools/get-tokens.d.ts +2 -0
- package/dist/tools/get-tokens.js +19 -0
- package/dist/tools/search-docs.d.ts +2 -0
- package/dist/tools/search-docs.js +22 -0
- package/package.json +29 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { loadJSON } from '../lib/load-data.js';
|
|
3
|
+
import { ComponentInfoSchema } from '../lib/schemas.js';
|
|
4
|
+
import { success, error, notFound, READ_ONLY_ANNOTATIONS } from '../lib/response.js';
|
|
5
|
+
export function registerGetComponent(server) {
|
|
6
|
+
server.tool('get_component', 'Get detailed information about a specific lism-css component: props, usage examples, and category. If not found, try search_docs with a broader query.', {
|
|
7
|
+
name: z.string().describe('Component name to look up (e.g. "Box", "Flex", "Accordion").'),
|
|
8
|
+
package: z
|
|
9
|
+
.enum(['lism-css', '@lism-css/ui'])
|
|
10
|
+
.optional()
|
|
11
|
+
.describe('Filter by package. "lism-css" for core components, "@lism-css/ui" for UI components.'),
|
|
12
|
+
}, READ_ONLY_ANNOTATIONS, ({ name, package: pkg }) => {
|
|
13
|
+
try {
|
|
14
|
+
const data = loadJSON('components.json', z.array(ComponentInfoSchema));
|
|
15
|
+
let candidates = data;
|
|
16
|
+
if (pkg) {
|
|
17
|
+
candidates = data.filter((c) => c.package === pkg);
|
|
18
|
+
}
|
|
19
|
+
const nameLower = name.toLowerCase();
|
|
20
|
+
const exact = candidates.find((c) => c.name.toLowerCase() === nameLower);
|
|
21
|
+
if (exact) {
|
|
22
|
+
return success({ component: exact });
|
|
23
|
+
}
|
|
24
|
+
const suggestions = candidates
|
|
25
|
+
.filter((c) => c.name.toLowerCase().includes(nameLower))
|
|
26
|
+
.map((c) => ({ name: c.name, package: c.package }));
|
|
27
|
+
if (suggestions.length > 0) {
|
|
28
|
+
return notFound(`Component "${name}" not found. Did you mean one of these? Or try search_docs with a broader query.`, {
|
|
29
|
+
suggestions,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const available = candidates.map((c) => ({ name: c.name, package: c.package }));
|
|
33
|
+
return notFound(`Component "${name}" not found. Try search_docs to find related pages.`, { availableComponents: available });
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
return error(`Failed to load component data: ${e instanceof Error ? e.message : String(e)}. The data files may not be built yet. Ensure the server was installed correctly.`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { loadJSON } from '../lib/load-data.js';
|
|
2
|
+
import { OverviewDataSchema } from '../lib/schemas.js';
|
|
3
|
+
import { markdownResponse, error, READ_ONLY_ANNOTATIONS } from '../lib/response.js';
|
|
4
|
+
import { meta } from '../data/meta.js';
|
|
5
|
+
function toMarkdown(data) {
|
|
6
|
+
const lines = [];
|
|
7
|
+
lines.push(`# lism-css Overview`);
|
|
8
|
+
lines.push('');
|
|
9
|
+
lines.push(`> Generated at: ${meta.generatedAt} | Source commit: ${meta.sourceCommit} | Docs version: ${meta.docsVersion}`);
|
|
10
|
+
lines.push('');
|
|
11
|
+
lines.push(`## Description`);
|
|
12
|
+
lines.push('');
|
|
13
|
+
lines.push(data.description);
|
|
14
|
+
lines.push('');
|
|
15
|
+
lines.push(`## Architecture`);
|
|
16
|
+
lines.push('');
|
|
17
|
+
lines.push(data.architecture);
|
|
18
|
+
lines.push('');
|
|
19
|
+
lines.push(`## Packages`);
|
|
20
|
+
lines.push('');
|
|
21
|
+
for (const pkg of data.packages) {
|
|
22
|
+
lines.push(`- **${pkg.name}** (\`${pkg.npmName}\` v${pkg.version}): ${pkg.description}`);
|
|
23
|
+
}
|
|
24
|
+
lines.push('');
|
|
25
|
+
lines.push(`## Breakpoints`);
|
|
26
|
+
lines.push('');
|
|
27
|
+
for (const [key, value] of Object.entries(data.breakpoints)) {
|
|
28
|
+
lines.push(`- \`${key}\`: ${value}`);
|
|
29
|
+
}
|
|
30
|
+
lines.push('');
|
|
31
|
+
lines.push(`## CSS Layers`);
|
|
32
|
+
lines.push('');
|
|
33
|
+
lines.push(data.cssLayers);
|
|
34
|
+
lines.push('');
|
|
35
|
+
lines.push(`## Installation`);
|
|
36
|
+
lines.push('');
|
|
37
|
+
lines.push(data.installation);
|
|
38
|
+
return lines.join('\n');
|
|
39
|
+
}
|
|
40
|
+
export function registerGetOverview(server) {
|
|
41
|
+
server.tool('get_overview', 'Get an overview of the lism-css framework: architecture, design philosophy, packages, breakpoints, installation guide, and CSS layers. Start here to understand the framework before using other tools.', {}, READ_ONLY_ANNOTATIONS, () => {
|
|
42
|
+
try {
|
|
43
|
+
const data = loadJSON('overview.json', OverviewDataSchema);
|
|
44
|
+
return markdownResponse(toMarkdown(data));
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
return error(`Failed to load overview data: ${e instanceof Error ? e.message : String(e)}. The data files may not be built yet. Ensure the server was installed correctly.`);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { loadJSON } from '../lib/load-data.js';
|
|
3
|
+
import { PropsSystemDataSchema } from '../lib/schemas.js';
|
|
4
|
+
import { success, error, notFound, READ_ONLY_ANNOTATIONS } from '../lib/response.js';
|
|
5
|
+
export function registerGetPropsSystem(server) {
|
|
6
|
+
server.tool('get_props_system', 'Get the lism-css Props system reference: how React props map to CSS classes and styles. Optionally filter by a specific prop name. Related: use get_component to see how props are used in specific components.', {
|
|
7
|
+
prop: z.string().optional().describe('Specific prop name to look up (e.g. "p", "fz", "bgc"). Omit to get the full system overview.'),
|
|
8
|
+
}, READ_ONLY_ANNOTATIONS, ({ prop }) => {
|
|
9
|
+
try {
|
|
10
|
+
const data = loadJSON('props-system.json', PropsSystemDataSchema);
|
|
11
|
+
if (!prop) {
|
|
12
|
+
return success(data);
|
|
13
|
+
}
|
|
14
|
+
const propLower = prop.toLowerCase();
|
|
15
|
+
const matched = [];
|
|
16
|
+
for (const cat of data.categories) {
|
|
17
|
+
const found = cat.props.filter((p) => p.prop.toLowerCase() === propLower);
|
|
18
|
+
if (found.length > 0) {
|
|
19
|
+
matched.push({ ...cat, props: found });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (matched.length === 0) {
|
|
23
|
+
const allProps = data.categories.flatMap((c) => c.props.map((p) => p.prop));
|
|
24
|
+
return notFound(`Prop "${prop}" not found. Try search_docs to find related documentation.`, { availableProps: allProps });
|
|
25
|
+
}
|
|
26
|
+
return success({ description: data.description, categories: matched });
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
return error(`Failed to load props system data: ${e instanceof Error ? e.message : String(e)}. The data files may not be built yet. Ensure the server was installed correctly.`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { loadJSON } from '../lib/load-data.js';
|
|
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'];
|
|
6
|
+
export function registerGetTokens(server) {
|
|
7
|
+
server.tool('get_tokens', 'Get design tokens (colors, spacing, font sizes, shadows, etc.) used in lism-css. Use get_overview first to understand the framework, then use this tool to explore specific token categories.', {
|
|
8
|
+
category: z.enum(TOKEN_CATEGORIES).default('all').describe('Token category to retrieve. Use "all" to get all categories.'),
|
|
9
|
+
}, READ_ONLY_ANNOTATIONS, ({ category }) => {
|
|
10
|
+
try {
|
|
11
|
+
const data = loadJSON('tokens.json', z.array(TokenCategorySchema));
|
|
12
|
+
const filtered = category === 'all' ? data : data.filter((c) => c.category === category);
|
|
13
|
+
return success({ tokens: filtered });
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
return error(`Failed to load tokens data: ${e instanceof Error ? e.message : String(e)}. The data files may not be built yet. Ensure the server was installed correctly.`);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { loadJSON } from '../lib/load-data.js';
|
|
3
|
+
import { DocsEntrySchema } from '../lib/schemas.js';
|
|
4
|
+
import { searchDocs } from '../lib/search.js';
|
|
5
|
+
import { success, error, READ_ONLY_ANNOTATIONS } from '../lib/response.js';
|
|
6
|
+
const DOC_CATEGORIES = ['all', 'core-components', 'modules', 'props', 'ui', 'guide'];
|
|
7
|
+
export function registerSearchDocs(server) {
|
|
8
|
+
server.tool('search_docs', "Search lism-css documentation by keyword. Returns matching pages with relevance scores. Use this when other tools don't return the information you need, or to discover available components and features.", {
|
|
9
|
+
query: z.string().describe('Search query (keywords separated by spaces).'),
|
|
10
|
+
category: z.enum(DOC_CATEGORIES).default('all').describe('Filter by documentation category.'),
|
|
11
|
+
limit: z.number().int().min(1).max(20).default(10).describe('Maximum number of results to return.'),
|
|
12
|
+
}, READ_ONLY_ANNOTATIONS, ({ query, category, limit }) => {
|
|
13
|
+
try {
|
|
14
|
+
const entries = loadJSON('docs-index.json', z.array(DocsEntrySchema));
|
|
15
|
+
const results = searchDocs(entries, query, category, limit);
|
|
16
|
+
return success({ query, results });
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
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.`);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lism-css/mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for lism-css documentation and API reference.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"lism-mcp": "./bin/lism-mcp.mjs"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"bin"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@modelcontextprotocol/sdk": "^1.18.1",
|
|
16
|
+
"zod": "^3.24.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^22.0.0",
|
|
20
|
+
"typescript": "~5.8.3",
|
|
21
|
+
"vitest": "^4.0.18"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc -p tsconfig.build.json && cp src/data/*.json dist/data/",
|
|
26
|
+
"dev": "tsc --watch",
|
|
27
|
+
"test": "vitest run"
|
|
28
|
+
}
|
|
29
|
+
}
|