@ama-styling/mcp 0.0.0 → 15.1.0-prerelease.7
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 +26 -0
- package/README.md +91 -0
- package/package.json +138 -2
- package/src/cli.d.ts +3 -0
- package/src/cli.d.ts.map +1 -0
- package/src/cli.js +35 -0
- package/src/cli.js.map +1 -0
- package/src/helpers/load-metadata.d.ts +40 -0
- package/src/helpers/load-metadata.d.ts.map +1 -0
- package/src/helpers/load-metadata.js +50 -0
- package/src/helpers/load-metadata.js.map +1 -0
- package/src/helpers/safe-regex.d.ts +17 -0
- package/src/helpers/safe-regex.d.ts.map +1 -0
- package/src/helpers/safe-regex.js +49 -0
- package/src/helpers/safe-regex.js.map +1 -0
- package/src/server/mcp-server.d.ts +18 -0
- package/src/server/mcp-server.d.ts.map +1 -0
- package/src/server/mcp-server.js +79 -0
- package/src/server/mcp-server.js.map +1 -0
- package/src/tools/find-design-token.d.ts +96 -0
- package/src/tools/find-design-token.d.ts.map +1 -0
- package/src/tools/find-design-token.js +229 -0
- package/src/tools/find-design-token.js.map +1 -0
- package/src/tools/list-design-tokens.d.ts +18 -0
- package/src/tools/list-design-tokens.d.ts.map +1 -0
- package/src/tools/list-design-tokens.js +91 -0
- package/src/tools/list-design-tokens.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright Amadeus SAS
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
4
|
+
are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
7
|
+
list of conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation and/or
|
|
11
|
+
other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
+
may be used to endorse or promote products derived from this software without
|
|
15
|
+
specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
21
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
22
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
23
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
24
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<h1 align="center">Ama Styling MCP</h1>
|
|
2
|
+
<p align="center">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/AmadeusITGroup/otter/main/assets/logo/otter.png" alt="Super cute Otter!" width="40%"/>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<br />
|
|
7
|
+
<br />
|
|
8
|
+
|
|
9
|
+
> [!WARNING]
|
|
10
|
+
> [Experimental](https://github.com/AmadeusITGroup/otter/blob/main/README.md#experimental)
|
|
11
|
+
|
|
12
|
+
## Description
|
|
13
|
+
|
|
14
|
+
An MCP (Model Context Protocol) server that exposes design token metadata to AI assistants for token discovery and recommendation.
|
|
15
|
+
It reads a `styling.metadata.json` file and provides tools for listing, filtering, and finding the best design tokens to use in CSS.
|
|
16
|
+
|
|
17
|
+
## Tools
|
|
18
|
+
|
|
19
|
+
| Tool | Description |
|
|
20
|
+
|------|-------------|
|
|
21
|
+
| `list_design_tokens` | List available design tokens with their descriptions, values, types, categories, and tags. Supports optional filtering by category, tag, type, or name pattern (regex). |
|
|
22
|
+
| `find_design_token` | Given a CSS property and semantic context, recommends the best matching design tokens to use instead of hardcoded values. |
|
|
23
|
+
|
|
24
|
+
## How to use with VSCode
|
|
25
|
+
|
|
26
|
+
To add the Design Tokens MCP server, you should first activate MCP with `"chat.mcp.enabled": true`.
|
|
27
|
+
|
|
28
|
+
Then, in your `.vscode/mcp.json` add:
|
|
29
|
+
|
|
30
|
+
```json5
|
|
31
|
+
{
|
|
32
|
+
"AmaStyling": {
|
|
33
|
+
"type": "stdio",
|
|
34
|
+
"command": "npx",
|
|
35
|
+
"args": [
|
|
36
|
+
"-y", "-p", "@ama-styling/mcp", "ama-styling-mcp-start",
|
|
37
|
+
"--metadata", "./path/to/styling.metadata.json"
|
|
38
|
+
],
|
|
39
|
+
"env": {
|
|
40
|
+
// Help us improve Otter by setting this to true.
|
|
41
|
+
// More details on our privacy policy: https://github.com/AmadeusITGroup/otter/blob/main/PRIVACY.md
|
|
42
|
+
"O3R_METRICS": true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## CLI Options
|
|
49
|
+
|
|
50
|
+
| Option | Description | Default |
|
|
51
|
+
|--------|-------------|---------|
|
|
52
|
+
| `-m, --metadata <path>` | Path to the `styling.metadata.json` file | `./styling.metadata.json` |
|
|
53
|
+
| `--cache-path <path>` | Path to the cache file | `.cache/@ama-styling/mcp` |
|
|
54
|
+
| `--log-level <level>` | Log level: `debug`, `info`, `warn`, `error` | `info` |
|
|
55
|
+
|
|
56
|
+
## Metadata file format
|
|
57
|
+
|
|
58
|
+
The server expects a JSON file with the following structure:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"variables": {
|
|
63
|
+
"--color-primary": {
|
|
64
|
+
"name": "--color-primary",
|
|
65
|
+
"defaultValue": "#3b82f6",
|
|
66
|
+
"type": "color",
|
|
67
|
+
"category": "brand",
|
|
68
|
+
"tags": ["primary", "interactive"],
|
|
69
|
+
"description": "Primary brand color for interactive elements",
|
|
70
|
+
"label": "Primary Color"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Each variable entry supports:
|
|
77
|
+
|
|
78
|
+
| Field | Type | Description |
|
|
79
|
+
|-------|------|-------------|
|
|
80
|
+
| `name` | `string` | CSS custom property name (required) |
|
|
81
|
+
| `defaultValue` | `string` | Default value for the variable (required) |
|
|
82
|
+
| `type` | `"color" \| "string"` | Value type |
|
|
83
|
+
| `category` | `string` | Token category |
|
|
84
|
+
| `tags` | `string[]` | Categorization tags |
|
|
85
|
+
| `description` | `string` | Human-readable description |
|
|
86
|
+
| `label` | `string` | Display label |
|
|
87
|
+
| `references` | `CssVariable[]` | Other tokens this variable references |
|
|
88
|
+
| `component` | `{ library, name }` | Component association |
|
|
89
|
+
|
|
90
|
+
> [!NOTE]
|
|
91
|
+
> This metadata file is typically generated by the `@ama-styling/style-dictionary` package as part of the design token build pipeline.
|
package/package.json
CHANGED
|
@@ -1,7 +1,143 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ama-styling/mcp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.1.0-prerelease.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
|
-
}
|
|
6
|
+
},
|
|
7
|
+
"description": "Experimental package -- MCP module to expose design token information to AI assistants",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"mcp",
|
|
10
|
+
"styling",
|
|
11
|
+
"design-tokens",
|
|
12
|
+
"otter-module"
|
|
13
|
+
],
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"bin": {
|
|
16
|
+
"ama-styling-mcp-start": "./src/cli.js"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
"./package.json": {
|
|
20
|
+
"default": "./package.json"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"nx": "nx",
|
|
25
|
+
"ng": "yarn nx",
|
|
26
|
+
"build": "yarn nx build ama-styling-mcp",
|
|
27
|
+
"compile": "tsc -b ./tsconfig.build.json",
|
|
28
|
+
"postbuild": "yarn cpy package.json dist && patch-package-json-main"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@ama-mcp/core": "~15.1.0-prerelease.7",
|
|
32
|
+
"@modelcontextprotocol/server": "~2.0.0",
|
|
33
|
+
"@o3r/telemetry": "~15.1.0-prerelease.7",
|
|
34
|
+
"commander": "^14.0.0",
|
|
35
|
+
"tslib": "^2.6.2",
|
|
36
|
+
"zod": "~4.4.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@ama-mcp/core": "~15.1.0-prerelease.7",
|
|
40
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
41
|
+
"@modelcontextprotocol/server": "~2.0.0",
|
|
42
|
+
"@nx/eslint": "~23.1.0",
|
|
43
|
+
"@nx/eslint-plugin": "~23.1.0",
|
|
44
|
+
"@nx/js": "~23.1.0",
|
|
45
|
+
"@nx/vitest": "~23.1.0",
|
|
46
|
+
"@o3r/build-helpers": "^15.1.0-prerelease.7",
|
|
47
|
+
"@o3r/eslint-config": "^15.1.0-prerelease.7",
|
|
48
|
+
"@o3r/eslint-plugin": "^15.1.0-prerelease.7",
|
|
49
|
+
"@stylistic/eslint-plugin": "~5.10.0",
|
|
50
|
+
"@types/node": "~24.13.0",
|
|
51
|
+
"@typescript-eslint/parser": "~8.67.0",
|
|
52
|
+
"@vitest/coverage-istanbul": "^4.0.18",
|
|
53
|
+
"cpy-cli": "^6.0.0",
|
|
54
|
+
"eslint": "~9.39.0",
|
|
55
|
+
"eslint-import-resolver-node": "~0.4.0",
|
|
56
|
+
"eslint-import-resolver-typescript": "~4.4.0",
|
|
57
|
+
"eslint-plugin-import": "~2.32.0",
|
|
58
|
+
"eslint-plugin-import-newlines": "~1.4.0",
|
|
59
|
+
"eslint-plugin-jsdoc": "~61.7.0",
|
|
60
|
+
"eslint-plugin-prefer-arrow": "~1.2.3",
|
|
61
|
+
"eslint-plugin-unicorn": "~62.0.0",
|
|
62
|
+
"eslint-plugin-unused-imports": "~4.4.0",
|
|
63
|
+
"eslint-plugin-vitest": "~0.5.0",
|
|
64
|
+
"globals": "^16.0.0",
|
|
65
|
+
"jsonc-eslint-parser": "~2.4.0",
|
|
66
|
+
"typescript": "~6.0.3",
|
|
67
|
+
"typescript-eslint": "~8.67.0",
|
|
68
|
+
"vitest": "~4.1.0",
|
|
69
|
+
"zod": "~4.4.0"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": "^22.22.3 || ^24.15.0 || ^26.0.0"
|
|
73
|
+
},
|
|
74
|
+
"contributors": [
|
|
75
|
+
{
|
|
76
|
+
"name": "Yannick Adam",
|
|
77
|
+
"url": "https://github.com/yannickadam",
|
|
78
|
+
"email": "yannickadam@users.noreply.github.com"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "Kilian Panot",
|
|
82
|
+
"url": "https://github.com/kpanot",
|
|
83
|
+
"email": "kpanot@users.noreply.github.com"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "Jeremy Bourgeois",
|
|
87
|
+
"url": "https://github.com/jbourgeois-1A",
|
|
88
|
+
"email": "jbourgeois-1A@users.noreply.github.com"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "Pierre Henri Ginoux",
|
|
92
|
+
"url": "https://github.com/pginoux-1A",
|
|
93
|
+
"email": "pginoux-1A@users.noreply.github.com"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "Mircea Vasile Rednic",
|
|
97
|
+
"url": "https://github.com/mrednic-1A",
|
|
98
|
+
"email": "mrednic-1A@users.noreply.github.com"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "Stephane Dalle",
|
|
102
|
+
"url": "https://github.com/sdalle-1A",
|
|
103
|
+
"email": "sdalle-1A@users.noreply.github.com"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "Nicolas Hoffmann",
|
|
107
|
+
"url": "https://github.com/nhoffmann-1A",
|
|
108
|
+
"email": "nhoffmann-1A@users.noreply.github.com"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "Victor Scaiceanu",
|
|
112
|
+
"url": "https://github.com/vscaiceanu-1a",
|
|
113
|
+
"email": "vscaiceanu-1A@users.noreply.github.com"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"name": "Florian Paul",
|
|
117
|
+
"url": "https://github.com/fpaul-1A",
|
|
118
|
+
"email": "fpaul-1A@users.noreply.github.com"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "Corinne Paulve",
|
|
122
|
+
"url": "https://github.com/cpaulve-1A",
|
|
123
|
+
"email": "cpaulve-1A@users.noreply.github.com"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "Matthieu Crouzet",
|
|
127
|
+
"url": "https://github.com/matthieu-crouzet",
|
|
128
|
+
"email": "matthieu-crouzet@users.noreply.github.com"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "Salome Do",
|
|
132
|
+
"url": "https://github.com/sdo-1A",
|
|
133
|
+
"email": "sdo-1A@users.noreply.github.com"
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
"bugs": "https://github.com/AmadeusITGroup/otter/issues",
|
|
137
|
+
"repository": {
|
|
138
|
+
"type": "git",
|
|
139
|
+
"url": "git+https://github.com/AmadeusITGroup/otter.git"
|
|
140
|
+
},
|
|
141
|
+
"license": "BSD-3-Clause",
|
|
142
|
+
"homepage": "https://amadeusitgroup.github.io/otter/"
|
|
7
143
|
}
|
package/src/cli.d.ts
ADDED
package/src/cli.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":""}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const core_1 = require("@ama-mcp/core");
|
|
5
|
+
const stdio_1 = require("@modelcontextprotocol/server/stdio");
|
|
6
|
+
const telemetry_1 = require("@o3r/telemetry");
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const mcp_server_1 = require("./server/mcp-server");
|
|
9
|
+
const run = async () => {
|
|
10
|
+
const program = new commander_1.Command();
|
|
11
|
+
program
|
|
12
|
+
.name('ama-styling-mcp-start')
|
|
13
|
+
.description('Design Tokens MCP Server\n\n'
|
|
14
|
+
+ 'Exposes design token metadata to AI assistants for token discovery and recommendation.')
|
|
15
|
+
.option('-m, --metadata <path>', 'Path to the styling.metadata.json file', './styling.metadata.json')
|
|
16
|
+
.option('--cache-path <path>', 'Path to the cache file', '.cache/@ama-styling/mcp')
|
|
17
|
+
.option('--log-level <level>', 'Log level (debug, info, warn, error)', 'info');
|
|
18
|
+
const { metadata, cachePath, logLevel } = program.parse().opts();
|
|
19
|
+
const logger = new core_1.MCPLogger('@ama-styling/mcp', logLevel);
|
|
20
|
+
try {
|
|
21
|
+
const server = await (0, mcp_server_1.createStylingMcpServer)({
|
|
22
|
+
metadataPath: metadata,
|
|
23
|
+
cacheFilePath: cachePath
|
|
24
|
+
}, logger);
|
|
25
|
+
const transport = new stdio_1.StdioServerTransport();
|
|
26
|
+
await server.connect(transport);
|
|
27
|
+
logger.info('Server connected...');
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
logger.error('Failed to start Design Tokens MCP server:', error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
void (0, telemetry_1.createCliWithMetrics)(run, '@ama-styling/mcp')();
|
|
35
|
+
//# sourceMappingURL=cli.js.map
|
package/src/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";;;AACA,wCAGuB;AACvB,8DAE4C;AAC5C,8CAEwB;AACxB,yCAEmB;AACnB,oDAE6B;AAE7B,MAAM,GAAG,GAAG,KAAK,IAAmB,EAAE;IACpC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;IAC9B,OAAO;SACJ,IAAI,CAAC,uBAAuB,CAAC;SAC7B,WAAW,CACV,8BAA8B;UAC5B,wFAAwF,CAC3F;SACA,MAAM,CAAC,uBAAuB,EAAE,wCAAwC,EAAE,yBAAyB,CAAC;SACpG,MAAM,CAAC,qBAAqB,EAAE,wBAAwB,EAAE,yBAAyB,CAAC;SAClF,MAAM,CAAC,qBAAqB,EAAE,sCAAsC,EAAE,MAAM,CAAC,CAAC;IAEjF,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,EAI1D,CAAC;IACL,MAAM,MAAM,GAAG,IAAI,gBAAS,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;IAE3D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAA,mCAAsB,EACzC;YACE,YAAY,EAAE,QAAQ;YACtB,aAAa,EAAE,SAAS;SACzB,EACD,MAAM,CACP,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,4BAAoB,EAAE,CAAC;QAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;QACjE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEF,KAAK,IAAA,gCAAoB,EAAC,GAAG,EAAE,kBAAkB,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a CSS variable design token
|
|
3
|
+
*/
|
|
4
|
+
export interface CssVariable {
|
|
5
|
+
/** CSS custom property name */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Default value for the variable */
|
|
8
|
+
defaultValue: string;
|
|
9
|
+
/** Other tokens this variable references */
|
|
10
|
+
references?: CssVariable[];
|
|
11
|
+
/** Categorization tags */
|
|
12
|
+
tags?: string[];
|
|
13
|
+
/** Human-readable description */
|
|
14
|
+
description?: string;
|
|
15
|
+
/** Display label */
|
|
16
|
+
label?: string;
|
|
17
|
+
/** Value type */
|
|
18
|
+
type?: 'string' | 'color';
|
|
19
|
+
/** Token category */
|
|
20
|
+
category?: string;
|
|
21
|
+
/** Component association */
|
|
22
|
+
component?: {
|
|
23
|
+
library: string;
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Metadata structure for CSS design tokens
|
|
29
|
+
*/
|
|
30
|
+
export interface CssMetadata {
|
|
31
|
+
/** Map of variable name to variable definition */
|
|
32
|
+
variables: Record<string, CssVariable>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Load and validate a styling metadata JSON file.
|
|
36
|
+
* @param filePath Path to the styling.metadata.json file
|
|
37
|
+
* @returns Parsed and validated CSS metadata
|
|
38
|
+
*/
|
|
39
|
+
export declare function loadMetadata(filePath: string): Promise<CssMetadata>;
|
|
40
|
+
//# sourceMappingURL=load-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-metadata.d.ts","sourceRoot":"","sources":["../../../src/helpers/load-metadata.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,WAAW,EAAE,CAAC;IAC3B,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC1B,qBAAqB;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,SAAS,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACxC;AAqBD;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAsBzE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadMetadata = loadMetadata;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const cssVariableSchema = zod_1.z.object({
|
|
7
|
+
name: zod_1.z.string(),
|
|
8
|
+
defaultValue: zod_1.z.string(),
|
|
9
|
+
references: zod_1.z.lazy(() => zod_1.z.array(cssVariableSchema)).optional(),
|
|
10
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
11
|
+
description: zod_1.z.string().optional(),
|
|
12
|
+
label: zod_1.z.string().optional(),
|
|
13
|
+
type: zod_1.z.enum(['string', 'color']).optional(),
|
|
14
|
+
category: zod_1.z.string().optional(),
|
|
15
|
+
component: zod_1.z.object({
|
|
16
|
+
library: zod_1.z.string(),
|
|
17
|
+
name: zod_1.z.string()
|
|
18
|
+
}).optional()
|
|
19
|
+
});
|
|
20
|
+
const cssMetadataSchema = zod_1.z.object({
|
|
21
|
+
variables: zod_1.z.record(zod_1.z.string(), cssVariableSchema)
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Load and validate a styling metadata JSON file.
|
|
25
|
+
* @param filePath Path to the styling.metadata.json file
|
|
26
|
+
* @returns Parsed and validated CSS metadata
|
|
27
|
+
*/
|
|
28
|
+
async function loadMetadata(filePath) {
|
|
29
|
+
let content;
|
|
30
|
+
try {
|
|
31
|
+
content = await (0, promises_1.readFile)(filePath, 'utf8');
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
35
|
+
throw new Error(`Failed to read metadata file at "${filePath}": ${message}`);
|
|
36
|
+
}
|
|
37
|
+
let parsed;
|
|
38
|
+
try {
|
|
39
|
+
parsed = JSON.parse(content);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
throw new Error(`Failed to parse metadata file at "${filePath}": invalid JSON`);
|
|
43
|
+
}
|
|
44
|
+
const result = cssMetadataSchema.safeParse(parsed);
|
|
45
|
+
if (!result.success) {
|
|
46
|
+
throw new Error(`Invalid metadata shape in "${filePath}": ${result.error.message}`);
|
|
47
|
+
}
|
|
48
|
+
return result.data;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=load-metadata.js.map
|
|
@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MAAM,IAAA,mBAAQ,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,oCAAoC,QAAQ,MAAM,OAAO,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,qCAAqC,QAAQ,iBAAiB,CAAC,CAAC;IAClF,CAAC;IAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACtF,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of regex safety validation
|
|
3
|
+
*/
|
|
4
|
+
export interface RegexSafetyResult {
|
|
5
|
+
/** Whether the regex is considered safe */
|
|
6
|
+
safe: boolean;
|
|
7
|
+
/** Error message if the regex is unsafe */
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Validate that a regex pattern is safe from catastrophic backtracking (ReDoS).
|
|
12
|
+
* Checks pattern length and detects common dangerous constructs like nested quantifiers.
|
|
13
|
+
* @param pattern The regex pattern string to validate
|
|
14
|
+
* @returns Validation result indicating whether the pattern is safe
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateRegexSafety(pattern: string): RegexSafetyResult;
|
|
17
|
+
//# sourceMappingURL=safe-regex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-regex.d.ts","sourceRoot":"","sources":["../../../src/helpers/safe-regex.ts"],"names":[],"mappings":"AAuBA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,IAAI,EAAE,OAAO,CAAC;IACd,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAmBtE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateRegexSafety = validateRegexSafety;
|
|
4
|
+
/**
|
|
5
|
+
* Maximum allowed length for a user-provided regex pattern.
|
|
6
|
+
*/
|
|
7
|
+
const MAX_REGEX_LENGTH = 200;
|
|
8
|
+
/**
|
|
9
|
+
* Patterns that indicate potential catastrophic backtracking (ReDoS).
|
|
10
|
+
* These detect nested quantifiers and overlapping alternations that can
|
|
11
|
+
* cause exponential time complexity.
|
|
12
|
+
*/
|
|
13
|
+
const UNSAFE_PATTERNS = [
|
|
14
|
+
// Nested quantifiers: (a+)+, (a*)+, (a+)*, (a*)*
|
|
15
|
+
/(\(.+[+*]\))[+*]/,
|
|
16
|
+
// Quantifier on a group that contains a quantifier: (x+y+)+
|
|
17
|
+
/\([^)]*[+*][^)]*[+*][^)]*\)[+*]/,
|
|
18
|
+
// Overlapping character classes with quantifier: ([\s\S]+)+, (.+.+)+
|
|
19
|
+
/\(.+\+.+\+\)[+*]/,
|
|
20
|
+
// Overlapping alternation with quantifier: (a|a)+, (\d|\d+)+
|
|
21
|
+
/\([^)]*\|[^)]*\)[+*]/,
|
|
22
|
+
// Group with quantifier repeated via {n,}: (a+){2,}, (a*){3,}
|
|
23
|
+
/\([^)]*[+*][^)]*\)\{[^}]*,/
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Validate that a regex pattern is safe from catastrophic backtracking (ReDoS).
|
|
27
|
+
* Checks pattern length and detects common dangerous constructs like nested quantifiers.
|
|
28
|
+
* @param pattern The regex pattern string to validate
|
|
29
|
+
* @returns Validation result indicating whether the pattern is safe
|
|
30
|
+
*/
|
|
31
|
+
function validateRegexSafety(pattern) {
|
|
32
|
+
if (pattern.length > MAX_REGEX_LENGTH) {
|
|
33
|
+
return {
|
|
34
|
+
safe: false,
|
|
35
|
+
error: `Regex pattern is too long (${pattern.length} characters). Maximum allowed length is ${MAX_REGEX_LENGTH}.`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
for (const unsafePattern of UNSAFE_PATTERNS) {
|
|
39
|
+
if (unsafePattern.test(pattern)) {
|
|
40
|
+
return {
|
|
41
|
+
safe: false,
|
|
42
|
+
error: 'Regex pattern contains constructs that could cause catastrophic backtracking'
|
|
43
|
+
+ ' (e.g., nested quantifiers). Please simplify the pattern.'
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { safe: true };
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=safe-regex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-regex.js","sourceRoot":"","sources":["../../../src/helpers/safe-regex.ts"],"names":[],"mappings":";;AAuCA,kDAmBC;AA1DD;;GAEG;AACH,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B;;;;GAIG;AACH,MAAM,eAAe,GAAa;IAChC,iDAAiD;IACjD,kBAAkB;IAClB,4DAA4D;IAC5D,iCAAiC;IACjC,qEAAqE;IACrE,kBAAkB;IAClB,6DAA6D;IAC7D,sBAAsB;IACtB,8DAA8D;IAC9D,4BAA4B;CAC7B,CAAC;AAYF;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,OAAe;IACjD,IAAI,OAAO,CAAC,MAAM,GAAG,gBAAgB,EAAE,CAAC;QACtC,OAAO;YACL,IAAI,EAAE,KAAK;YACX,KAAK,EAAE,8BAA8B,OAAO,CAAC,MAAM,2CAA2C,gBAAgB,GAAG;SAClH,CAAC;IACJ,CAAC;IAED,KAAK,MAAM,aAAa,IAAI,eAAe,EAAE,CAAC;QAC5C,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,OAAO;gBACL,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,8EAA8E;sBACjF,2DAA2D;aAChE,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AmaMcpServer, type CacheToolOptions, type MCPLogger } from '@ama-mcp/core';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the styling MCP server
|
|
4
|
+
*/
|
|
5
|
+
export interface StylingMcpServerOptions extends CacheToolOptions {
|
|
6
|
+
/** Path to the styling.metadata.json file */
|
|
7
|
+
metadataPath: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a Design Tokens MCP server instance.
|
|
11
|
+
* The server starts immediately and registers tools. Metadata is loaded
|
|
12
|
+
* asynchronously in the background (and cached) so the server is responsive
|
|
13
|
+
* as soon as possible. Tools await the metadata promise when called.
|
|
14
|
+
* @param options Server options
|
|
15
|
+
* @param logger Logger instance
|
|
16
|
+
*/
|
|
17
|
+
export declare function createStylingMcpServer(options: StylingMcpServerOptions, logger: MCPLogger): Promise<AmaMcpServer>;
|
|
18
|
+
//# sourceMappingURL=mcp-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../../src/server/mcp-server.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,YAAY,EAEZ,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAEf,MAAM,eAAe,CAAC;AAqBvB;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAC/D,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,YAAY,CAAC,CA2EvB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStylingMcpServer = createStylingMcpServer;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const core_1 = require("@ama-mcp/core");
|
|
7
|
+
const telemetry_1 = require("@o3r/telemetry");
|
|
8
|
+
const load_metadata_1 = require("../helpers/load-metadata");
|
|
9
|
+
const find_design_token_1 = require("../tools/find-design-token");
|
|
10
|
+
const list_design_tokens_1 = require("../tools/list-design-tokens");
|
|
11
|
+
/** URI prefix for design-token resources */
|
|
12
|
+
const RESOURCE_URI_PREFIX = 'ama-styling';
|
|
13
|
+
/** Cache key for the metadata */
|
|
14
|
+
const METADATA_CACHE_KEY = 'metadata';
|
|
15
|
+
/**
|
|
16
|
+
* Create a Design Tokens MCP server instance.
|
|
17
|
+
* The server starts immediately and registers tools. Metadata is loaded
|
|
18
|
+
* asynchronously in the background (and cached) so the server is responsive
|
|
19
|
+
* as soon as possible. Tools await the metadata promise when called.
|
|
20
|
+
* @param options Server options
|
|
21
|
+
* @param logger Logger instance
|
|
22
|
+
*/
|
|
23
|
+
async function createStylingMcpServer(options, logger) {
|
|
24
|
+
const { metadataPath, ...cacheOptions } = options;
|
|
25
|
+
const { name, version } = JSON.parse(await (0, promises_1.readFile)((0, node_path_1.join)(__dirname, '..', '..', 'package.json'), 'utf8'));
|
|
26
|
+
const server = new core_1.AmaMcpServer(logger, { name, version });
|
|
27
|
+
void (0, telemetry_1.sendGenAIEventMetricsIfAuthorized)(name, 'registrationStart', { logger });
|
|
28
|
+
// Initialize cache
|
|
29
|
+
const cacheManager = new core_1.CacheManager({
|
|
30
|
+
logger,
|
|
31
|
+
...cacheOptions
|
|
32
|
+
});
|
|
33
|
+
await cacheManager.initialize();
|
|
34
|
+
// Mutable metadata reference — starts with cached data, updated after fresh load
|
|
35
|
+
let currentMetadata = cacheManager.get(METADATA_CACHE_KEY);
|
|
36
|
+
if (currentMetadata) {
|
|
37
|
+
core_1.resourceRegistry.set(`${RESOURCE_URI_PREFIX}://metadata`, JSON.stringify(currentMetadata, null, 2));
|
|
38
|
+
logger.info?.('Restored metadata from cache');
|
|
39
|
+
}
|
|
40
|
+
// Load fresh metadata asynchronously and update the mutable reference
|
|
41
|
+
const metadataPromise = (async () => {
|
|
42
|
+
try {
|
|
43
|
+
const metadata = await (0, load_metadata_1.loadMetadata)(metadataPath);
|
|
44
|
+
currentMetadata = metadata;
|
|
45
|
+
core_1.resourceRegistry.set(`${RESOURCE_URI_PREFIX}://metadata`, JSON.stringify(metadata, null, 2));
|
|
46
|
+
void cacheManager.set(METADATA_CACHE_KEY, metadata);
|
|
47
|
+
logger.info?.('Design token metadata loaded successfully');
|
|
48
|
+
return metadata;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
52
|
+
logger.error?.(`Failed to load metadata: ${message}`);
|
|
53
|
+
if (currentMetadata) {
|
|
54
|
+
return currentMetadata;
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
})();
|
|
59
|
+
// Async getter: returns current data if available, otherwise awaits loading
|
|
60
|
+
const getMetadata = () => {
|
|
61
|
+
if (currentMetadata) {
|
|
62
|
+
return Promise.resolve(currentMetadata);
|
|
63
|
+
}
|
|
64
|
+
return metadataPromise;
|
|
65
|
+
};
|
|
66
|
+
// Register tools immediately — they await getMetadata() on each call
|
|
67
|
+
(0, list_design_tokens_1.registerListDesignTokensTool)(server, {
|
|
68
|
+
getMetadata,
|
|
69
|
+
uriPrefix: RESOURCE_URI_PREFIX,
|
|
70
|
+
logger
|
|
71
|
+
});
|
|
72
|
+
(0, find_design_token_1.registerFindDesignTokenTool)(server, {
|
|
73
|
+
getMetadata,
|
|
74
|
+
logger
|
|
75
|
+
});
|
|
76
|
+
void (0, telemetry_1.sendGenAIEventMetricsIfAuthorized)(name, 'registrationEnd', { logger });
|
|
77
|
+
return server;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../../../src/server/mcp-server.ts"],"names":[],"mappings":";;AAiDA,wDA8EC;AA/HD,+CAE0B;AAC1B,yCAEmB;AACnB,wCAMuB;AACvB,8CAEwB;AACxB,4DAGkC;AAClC,kEAEoC;AACpC,oEAEqC;AAErC,4CAA4C;AAC5C,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAE1C,iCAAiC;AACjC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAUtC;;;;;;;GAOG;AACI,KAAK,UAAU,sBAAsB,CAC1C,OAAgC,EAChC,MAAiB;IAEjB,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAClC,MAAM,IAAA,mBAAQ,EAAC,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAC/B,CAAC;IAEvC,MAAM,MAAM,GAAG,IAAI,mBAAY,CAC7B,MAAM,EACN,EAAE,IAAI,EAAE,OAAO,EAAE,CAClB,CAAC;IAEF,KAAK,IAAA,6CAAiC,EAAC,IAAI,EAAE,mBAAmB,EAAE,EAAE,MAAM,EA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YACzB,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,4EAA4E;IAC5E,MAAM,WAAW,GAAG,GAAyB,EAAE;QAC7C,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC,CAAC;IAEF,qEAAqE;IACrE,IAAA,iDAA4B,EAAC,MAAM,EAAE;QACnC,WAAW;QACX,SAAS,EAAE,mBAAmB;QAC9B,MAAM;KACP,CAAC,CAAC;IAEH,IAAA,+CAA2B,EAAC,MAAM,EAAE;QAClC,WAAW;QACX,MAAM;KACP,CAAC,CAAC;IAEH,KAAK,IAAA,6CAAiC,EAAC,IAAI,EAAE,iBAAiB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAE5E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { ToolDefinition } from '@ama-mcp/core';
|
|
2
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
3
|
+
import type { CssMetadata, CssVariable } from '../helpers/load-metadata';
|
|
4
|
+
/** CSS properties that typically accept color values */
|
|
5
|
+
export declare const COLOR_CSS_PROPERTIES: string[];
|
|
6
|
+
/**
|
|
7
|
+
* Result of a design token recommendation
|
|
8
|
+
*/
|
|
9
|
+
export interface TokenRecommendation {
|
|
10
|
+
/** Token name */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Token default value */
|
|
13
|
+
defaultValue: string;
|
|
14
|
+
/** Token description */
|
|
15
|
+
description?: string;
|
|
16
|
+
/** Token type */
|
|
17
|
+
type?: string;
|
|
18
|
+
/** Relevance score */
|
|
19
|
+
score: number;
|
|
20
|
+
/** Explanation of why this token was recommended */
|
|
21
|
+
reason: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Tokenize a string into lowercase words by splitting on spaces and punctuation.
|
|
25
|
+
* @param text Input text
|
|
26
|
+
* @returns Array of lowercase word tokens
|
|
27
|
+
*/
|
|
28
|
+
export declare function tokenize(text: string): string[];
|
|
29
|
+
/**
|
|
30
|
+
* Result of a scoring function
|
|
31
|
+
*/
|
|
32
|
+
export interface ScoringResult {
|
|
33
|
+
/** Score contribution (positive or negative) */
|
|
34
|
+
score: number;
|
|
35
|
+
/** Human-readable reasons for the score */
|
|
36
|
+
reasons: string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Compute type compatibility score between a CSS property and a token.
|
|
40
|
+
* @param cssProperty The CSS property being styled
|
|
41
|
+
* @param tokenType The token's type field
|
|
42
|
+
* @returns Score adjustment and reasons
|
|
43
|
+
*/
|
|
44
|
+
export declare function scoreTypeCompatibility(cssProperty: string, tokenType?: string): ScoringResult;
|
|
45
|
+
/**
|
|
46
|
+
* Score name match between context words and token name segments.
|
|
47
|
+
* @param tokenName The token name (e.g., "--color-primary")
|
|
48
|
+
* @param contextWords Tokenized context words
|
|
49
|
+
* @returns Score and reasons
|
|
50
|
+
*/
|
|
51
|
+
export declare function scoreNameMatch(tokenName: string, contextWords: string[]): ScoringResult;
|
|
52
|
+
/**
|
|
53
|
+
* Score description and label match.
|
|
54
|
+
* @param description Token description
|
|
55
|
+
* @param label Token label
|
|
56
|
+
* @param contextWords Tokenized context words
|
|
57
|
+
* @returns Score and reasons
|
|
58
|
+
*/
|
|
59
|
+
export declare function scoreDescriptionMatch(description: string | undefined, label: string | undefined, contextWords: string[]): ScoringResult;
|
|
60
|
+
/**
|
|
61
|
+
* Score tag match.
|
|
62
|
+
* @param tags Token tags
|
|
63
|
+
* @param contextWords Tokenized context words
|
|
64
|
+
* @returns Score and reasons
|
|
65
|
+
*/
|
|
66
|
+
export declare function scoreTagMatch(tags: string[] | undefined, contextWords: string[]): ScoringResult;
|
|
67
|
+
/**
|
|
68
|
+
* Score category match.
|
|
69
|
+
* @param category Token category
|
|
70
|
+
* @param contextWords Tokenized context words
|
|
71
|
+
* @returns Score and reasons
|
|
72
|
+
*/
|
|
73
|
+
export declare function scoreCategoryMatch(category: string | undefined, contextWords: string[]): ScoringResult;
|
|
74
|
+
/**
|
|
75
|
+
* Score a token against the given CSS property and semantic context.
|
|
76
|
+
* @param token The design token to score
|
|
77
|
+
* @param cssProperty The CSS property being styled
|
|
78
|
+
* @param contextWords Tokenized context words
|
|
79
|
+
* @returns Object with total score and reasons
|
|
80
|
+
*/
|
|
81
|
+
export declare function scoreToken(token: CssVariable, cssProperty: string, contextWords: string[]): ScoringResult;
|
|
82
|
+
/**
|
|
83
|
+
* Options for the find design token tool
|
|
84
|
+
* @experimental
|
|
85
|
+
*/
|
|
86
|
+
export interface FindDesignTokenOptions extends ToolDefinition {
|
|
87
|
+
/** Async getter that returns the metadata (awaits loading if not yet available) */
|
|
88
|
+
getMetadata: () => Promise<CssMetadata>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Register the find_design_token tool on the MCP server.
|
|
92
|
+
* @param server MCP server instance
|
|
93
|
+
* @param options Tool options
|
|
94
|
+
*/
|
|
95
|
+
export declare function registerFindDesignTokenTool(server: McpServer, options: FindDesignTokenOptions): void;
|
|
96
|
+
//# sourceMappingURL=find-design-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-design-token.d.ts","sourceRoot":"","sources":["../../../src/tools/find-design-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,SAAS,EACV,MAAM,8BAA8B,CAAC;AAItC,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAElC,wDAAwD;AACxD,eAAO,MAAM,oBAAoB,UAUhC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,YA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BAAuB,SAAQ,cAAc;IAC5D,mFAAmF;IACnF,WAAW,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;CACzC;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAgFpG"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.COLOR_CSS_PROPERTIES = void 0;
|
|
4
|
+
exports.tokenize = tokenize;
|
|
5
|
+
exports.scoreTypeCompatibility = scoreTypeCompatibility;
|
|
6
|
+
exports.scoreNameMatch = scoreNameMatch;
|
|
7
|
+
exports.scoreDescriptionMatch = scoreDescriptionMatch;
|
|
8
|
+
exports.scoreTagMatch = scoreTagMatch;
|
|
9
|
+
exports.scoreCategoryMatch = scoreCategoryMatch;
|
|
10
|
+
exports.scoreToken = scoreToken;
|
|
11
|
+
exports.registerFindDesignTokenTool = registerFindDesignTokenTool;
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
/** CSS properties that typically accept color values */
|
|
14
|
+
exports.COLOR_CSS_PROPERTIES = [
|
|
15
|
+
'color',
|
|
16
|
+
'background-color',
|
|
17
|
+
'border-color',
|
|
18
|
+
'outline-color',
|
|
19
|
+
'text-decoration-color',
|
|
20
|
+
'fill',
|
|
21
|
+
'stroke',
|
|
22
|
+
'background',
|
|
23
|
+
'border'
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Tokenize a string into lowercase words by splitting on spaces and punctuation.
|
|
27
|
+
* @param text Input text
|
|
28
|
+
* @returns Array of lowercase word tokens
|
|
29
|
+
*/
|
|
30
|
+
function tokenize(text) {
|
|
31
|
+
return text
|
|
32
|
+
.toLowerCase()
|
|
33
|
+
.split(/[\s\-_.,;:!?/\\()[\]{}]+/)
|
|
34
|
+
.filter((word) => word.length > 0);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Compute type compatibility score between a CSS property and a token.
|
|
38
|
+
* @param cssProperty The CSS property being styled
|
|
39
|
+
* @param tokenType The token's type field
|
|
40
|
+
* @returns Score adjustment and reasons
|
|
41
|
+
*/
|
|
42
|
+
function scoreTypeCompatibility(cssProperty, tokenType) {
|
|
43
|
+
const isColorProperty = exports.COLOR_CSS_PROPERTIES.includes(cssProperty.toLowerCase());
|
|
44
|
+
if (isColorProperty && tokenType === 'color') {
|
|
45
|
+
return { score: 3, reasons: ['color type matches color CSS property'] };
|
|
46
|
+
}
|
|
47
|
+
if (isColorProperty && tokenType && tokenType !== 'color') {
|
|
48
|
+
return { score: -1, reasons: [`token type "${tokenType}" does not match color CSS property`] };
|
|
49
|
+
}
|
|
50
|
+
if (!isColorProperty && tokenType === 'color') {
|
|
51
|
+
return { score: -1, reasons: [`color token does not match non-color CSS property "${cssProperty}"`] };
|
|
52
|
+
}
|
|
53
|
+
return { score: 0, reasons: ['no type compatibility signal'] };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Score name match between context words and token name segments.
|
|
57
|
+
* @param tokenName The token name (e.g., "--color-primary")
|
|
58
|
+
* @param contextWords Tokenized context words
|
|
59
|
+
* @returns Score and reasons
|
|
60
|
+
*/
|
|
61
|
+
function scoreNameMatch(tokenName, contextWords) {
|
|
62
|
+
let score = 0;
|
|
63
|
+
const reasons = [];
|
|
64
|
+
const tokenNameParts = tokenName.toLowerCase().split('-').filter((part) => part.length > 0);
|
|
65
|
+
for (const word of contextWords) {
|
|
66
|
+
if (tokenNameParts.includes(word)) {
|
|
67
|
+
score += 2;
|
|
68
|
+
reasons.push(`name contains "${word}"`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { score, reasons };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Score description and label match.
|
|
75
|
+
* @param description Token description
|
|
76
|
+
* @param label Token label
|
|
77
|
+
* @param contextWords Tokenized context words
|
|
78
|
+
* @returns Score and reasons
|
|
79
|
+
*/
|
|
80
|
+
function scoreDescriptionMatch(description, label, contextWords) {
|
|
81
|
+
let score = 0;
|
|
82
|
+
const reasons = [];
|
|
83
|
+
const descriptionWords = tokenize(description || '');
|
|
84
|
+
const labelWords = tokenize(label || '');
|
|
85
|
+
for (const word of contextWords) {
|
|
86
|
+
if (descriptionWords.includes(word)) {
|
|
87
|
+
score += 1;
|
|
88
|
+
reasons.push(`description contains "${word}"`);
|
|
89
|
+
}
|
|
90
|
+
if (labelWords.includes(word)) {
|
|
91
|
+
score += 1;
|
|
92
|
+
reasons.push(`label contains "${word}"`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return { score, reasons };
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Score tag match.
|
|
99
|
+
* @param tags Token tags
|
|
100
|
+
* @param contextWords Tokenized context words
|
|
101
|
+
* @returns Score and reasons
|
|
102
|
+
*/
|
|
103
|
+
function scoreTagMatch(tags, contextWords) {
|
|
104
|
+
let score = 0;
|
|
105
|
+
const reasons = [];
|
|
106
|
+
if (tags) {
|
|
107
|
+
for (const word of contextWords) {
|
|
108
|
+
if (tags.some((tag) => tag.toLowerCase() === word)) {
|
|
109
|
+
score += 1.5;
|
|
110
|
+
reasons.push(`tag matches "${word}"`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return { score, reasons };
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Score category match.
|
|
118
|
+
* @param category Token category
|
|
119
|
+
* @param contextWords Tokenized context words
|
|
120
|
+
* @returns Score and reasons
|
|
121
|
+
*/
|
|
122
|
+
function scoreCategoryMatch(category, contextWords) {
|
|
123
|
+
let score = 0;
|
|
124
|
+
const reasons = [];
|
|
125
|
+
if (category) {
|
|
126
|
+
const categoryLower = category.toLowerCase();
|
|
127
|
+
for (const word of contextWords) {
|
|
128
|
+
if (categoryLower === word || categoryLower.includes(word)) {
|
|
129
|
+
score += 1.5;
|
|
130
|
+
reasons.push(`category matches "${word}"`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return { score, reasons };
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Score a token against the given CSS property and semantic context.
|
|
138
|
+
* @param token The design token to score
|
|
139
|
+
* @param cssProperty The CSS property being styled
|
|
140
|
+
* @param contextWords Tokenized context words
|
|
141
|
+
* @returns Object with total score and reasons
|
|
142
|
+
*/
|
|
143
|
+
function scoreToken(token, cssProperty, contextWords) {
|
|
144
|
+
const results = [
|
|
145
|
+
() => scoreTypeCompatibility(cssProperty, token.type),
|
|
146
|
+
() => scoreNameMatch(token.name, contextWords),
|
|
147
|
+
() => scoreDescriptionMatch(token.description, token.label, contextWords),
|
|
148
|
+
() => scoreTagMatch(token.tags, contextWords),
|
|
149
|
+
() => scoreCategoryMatch(token.category, contextWords)
|
|
150
|
+
];
|
|
151
|
+
return results.map((fn) => fn()).reduce((acc, result) => {
|
|
152
|
+
acc.score += result.score;
|
|
153
|
+
acc.reasons.push(...result.reasons);
|
|
154
|
+
return acc;
|
|
155
|
+
}, { score: 0, reasons: [] });
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Register the find_design_token tool on the MCP server.
|
|
159
|
+
* @param server MCP server instance
|
|
160
|
+
* @param options Tool options
|
|
161
|
+
*/
|
|
162
|
+
function registerFindDesignTokenTool(server, options) {
|
|
163
|
+
const { getMetadata, toolName = 'find_design_token', toolTitle = 'Find Design Token', toolDescription = 'Given a CSS property and semantic context, recommends the best matching'
|
|
164
|
+
+ ' design tokens to use instead of hardcoded values.' } = options;
|
|
165
|
+
server.registerTool(toolName, {
|
|
166
|
+
title: toolTitle,
|
|
167
|
+
description: toolDescription,
|
|
168
|
+
annotations: {
|
|
169
|
+
readOnlyHint: true,
|
|
170
|
+
openWorldHint: false
|
|
171
|
+
},
|
|
172
|
+
inputSchema: zod_1.z.object({
|
|
173
|
+
cssProperty: zod_1.z.string()
|
|
174
|
+
.describe('The CSS property (e.g., "background-color", "font-size", "border-radius")'),
|
|
175
|
+
context: zod_1.z.string()
|
|
176
|
+
.describe('Semantic context describing the use case (e.g., "primary button background")'),
|
|
177
|
+
maxResults: zod_1.z.number().optional().default(5)
|
|
178
|
+
.describe('Maximum number of recommendations to return')
|
|
179
|
+
})
|
|
180
|
+
}, async ({ cssProperty, context, maxResults }) => {
|
|
181
|
+
const metadata = await getMetadata();
|
|
182
|
+
const contextWords = tokenize(context);
|
|
183
|
+
const tokens = Object.values(metadata.variables);
|
|
184
|
+
const scored = tokens
|
|
185
|
+
.map((token) => {
|
|
186
|
+
const { score, reasons } = scoreToken(token, cssProperty, contextWords);
|
|
187
|
+
return {
|
|
188
|
+
name: token.name,
|
|
189
|
+
defaultValue: token.defaultValue,
|
|
190
|
+
description: token.description,
|
|
191
|
+
type: token.type,
|
|
192
|
+
score,
|
|
193
|
+
reason: reasons.length > 0 ? reasons.join(', ') : 'no specific match'
|
|
194
|
+
};
|
|
195
|
+
})
|
|
196
|
+
.filter((item) => item.score > 0)
|
|
197
|
+
.toSorted((a, b) => b.score - a.score)
|
|
198
|
+
.slice(0, maxResults);
|
|
199
|
+
if (scored.length === 0) {
|
|
200
|
+
return {
|
|
201
|
+
content: [
|
|
202
|
+
{
|
|
203
|
+
type: 'text',
|
|
204
|
+
text: JSON.stringify({
|
|
205
|
+
message: `No matching design tokens found for CSS property "${cssProperty}"`
|
|
206
|
+
+ ` with context "${context}". Consider checking available tokens`
|
|
207
|
+
+ ' with list_design_tokens.',
|
|
208
|
+
reasons: [
|
|
209
|
+
`No tokens scored positively for the given CSS property "${cssProperty}" and context "${context}" combination`,
|
|
210
|
+
`${tokens.length} token(s) were evaluated but none matched the provided criteria`
|
|
211
|
+
],
|
|
212
|
+
suggestions: [
|
|
213
|
+
'Try broader context terms',
|
|
214
|
+
'Use list_design_tokens to see all available tokens',
|
|
215
|
+
'Check if the design system has tokens for this property type'
|
|
216
|
+
]
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
content: [
|
|
224
|
+
{ type: 'text', text: JSON.stringify(scored) }
|
|
225
|
+
]
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=find-design-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-design-token.js","sourceRoot":"","sources":["../../../src/tools/find-design-token.ts"],"names":[],"mappings":";;;AAkDA,4BAKC;AAkBD,wDAgBC;AAQD,wCAeC;AASD,sDAqBC;AAQD,sCAgBC;AAQD,gDAiBC;AASD,gCAqBC;AAgBD,kEAgFC;AAvTD,6BAEa;AAMb,wDAAwD;AAC3C,QAAA,oBAAoB,GAAG;IAClC,OAAO;IACP,kBAAkB;IAClB,cAAc;IACd,eAAe;IACf,uBAAuB;IACvB,MAAM;IACN,QAAQ;IACR,YAAY;IACZ,QAAQ;CACT,CAAC;AAoBF;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,IAAI;SACR,WAAW,EAAE;SACb,KAAK,CAAC,0BAA0B,CAAC;SACjC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACvC,CAAC;AAYD;;;;;GAKG;AACH,SAAgB,sBAAsB,CACpC,WAAmB,EACnB,SAAkB;IAElB,MAAM,eAAe,GAAG,4BAAoB,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC;IAEjF,IAAI,eAAe,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QAC7C,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,uCAAuC,CAAC,EAAE,CAAC;IAC1E,CAAC;IACD,IAAI,eAAe,IAAI,SAAS,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;QA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extprotocol/server';
|
|
3
|
+
import type { CssMetadata } from '../helpers/load-metadata';
|
|
4
|
+
/**
|
|
5
|
+
* Options for the list design tokens tool
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export interface ListDesignTokensOptions extends ToolDefinition, ResourceToolOptions {
|
|
9
|
+
/** Async getter that returns the metadata (awaits loading if not yet available) */
|
|
10
|
+
getMetadata: () => Promise<CssMetadata>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Register the list_design_tokens tool and the metadata resource.
|
|
14
|
+
* @param server MCP server instance
|
|
15
|
+
* @param options Tool options
|
|
16
|
+
*/
|
|
17
|
+
export declare function registerListDesignTokensTool(server: McpServer, options: ListDesignTokensOptions): void;
|
|
18
|
+
//# sourceMappingURL=list-design-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-design-tokens.d.ts","sourceRoot":"","sources":["../../../src/tools/list-design-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,SAAS,EACV,MAAM,8BAA8B,CAAC;AAItC,OAAO,KAAK,EACV,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAKlC;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,cAAc,EAAE,mBAAmB;IAClF,mFAAmF;IACnF,WAAW,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;CACzC;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAsGtG"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerListDesignTokensTool = registerListDesignTokensTool;
|
|
4
|
+
const core_1 = require("@ama-mcp/core");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const safe_regex_1 = require("../helpers/safe-regex");
|
|
7
|
+
/**
|
|
8
|
+
* Register the list_design_tokens tool and the metadata resource.
|
|
9
|
+
* @param server MCP server instance
|
|
10
|
+
* @param options Tool options
|
|
11
|
+
*/
|
|
12
|
+
function registerListDesignTokensTool(server, options) {
|
|
13
|
+
const { getMetadata, logger, uriPrefix, toolName = 'list_design_tokens', toolTitle = 'List Design Tokens', toolDescription = 'List available design tokens with their descriptions, values, types,'
|
|
14
|
+
+ ' categories, and tags. Supports optional filtering.' } = options;
|
|
15
|
+
const metadataUri = `${uriPrefix}://metadata`;
|
|
16
|
+
server.registerResource('Design Tokens Metadata', metadataUri, {
|
|
17
|
+
title: 'Design Tokens Metadata',
|
|
18
|
+
description: 'Full design token metadata including all variables,'
|
|
19
|
+
+ ' their values, types, categories, and tags.',
|
|
20
|
+
mimeType: 'application/json'
|
|
21
|
+
}, () => {
|
|
22
|
+
const content = core_1.resourceRegistry.get(metadataUri);
|
|
23
|
+
return {
|
|
24
|
+
contents: [{
|
|
25
|
+
uri: metadataUri,
|
|
26
|
+
text: content ?? JSON.stringify({ variables: {} })
|
|
27
|
+
}]
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
server.registerTool(toolName, {
|
|
31
|
+
title: toolTitle,
|
|
32
|
+
description: toolDescription,
|
|
33
|
+
annotations: {
|
|
34
|
+
readOnlyHint: true,
|
|
35
|
+
openWorldHint: false
|
|
36
|
+
},
|
|
37
|
+
inputSchema: zod_1.z.object({
|
|
38
|
+
category: zod_1.z.string().optional()
|
|
39
|
+
.describe('Filter tokens by category'),
|
|
40
|
+
tag: zod_1.z.string().optional()
|
|
41
|
+
.describe('Filter tokens by tag'),
|
|
42
|
+
type: zod_1.z.enum(['color', 'string']).optional()
|
|
43
|
+
.describe('Filter tokens by type'),
|
|
44
|
+
namePattern: zod_1.z.string().optional()
|
|
45
|
+
.describe('Filter tokens by name pattern (regex)')
|
|
46
|
+
})
|
|
47
|
+
}, async ({ category, tag, type, namePattern }) => {
|
|
48
|
+
const metadata = await getMetadata();
|
|
49
|
+
const warnings = [];
|
|
50
|
+
let tokens = Object.values(metadata.variables);
|
|
51
|
+
if (category) {
|
|
52
|
+
tokens = tokens.filter((token) => token.category === category);
|
|
53
|
+
}
|
|
54
|
+
if (tag) {
|
|
55
|
+
tokens = tokens.filter((token) => token.tags?.includes(tag));
|
|
56
|
+
}
|
|
57
|
+
if (type) {
|
|
58
|
+
tokens = tokens.filter((token) => token.type === type);
|
|
59
|
+
}
|
|
60
|
+
if (namePattern) {
|
|
61
|
+
const safetyCheck = (0, safe_regex_1.validateRegexSafety)(namePattern);
|
|
62
|
+
if (safetyCheck.safe) {
|
|
63
|
+
try {
|
|
64
|
+
const regex = new RegExp(namePattern);
|
|
65
|
+
tokens = tokens.filter((token) => regex.test(token.name));
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const warning = `Invalid regex pattern "${namePattern}": ${error instanceof Error ? error.message : String(error)}. `
|
|
69
|
+
+ 'Returning tokens without name filtering. Please provide a valid regular expression.';
|
|
70
|
+
logger?.warn?.(warning);
|
|
71
|
+
warnings.push(warning);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const warning = `Unsafe regex pattern ignored: ${safetyCheck.error}. `
|
|
76
|
+
+ 'Returning tokens without name filtering. Please simplify the pattern.';
|
|
77
|
+
logger?.warn?.(warning);
|
|
78
|
+
warnings.push(warning);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const result = warnings.length > 0
|
|
82
|
+
? { warnings, tokens }
|
|
83
|
+
: { tokens };
|
|
84
|
+
return {
|
|
85
|
+
content: [
|
|
86
|
+
{ type: 'text', text: JSON.stringify(result) }
|
|
87
|
+
]
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=list-design-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1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