@adobe/design-data-mcp 0.0.0-size-token-taxonomy-20260929225107
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 +201 -0
- package/README.md +74 -0
- package/package.json +57 -0
- package/src/cli.js +17 -0
- package/src/dataset-freshness.js +95 -0
- package/src/index.js +90 -0
- package/src/tools/design-data.js +414 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Adobe
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# [**@adobe/design-data-mcp**](https://github.com/adobe/spectrum-design-data/tree/main/tools/design-data-mcp)
|
|
2
|
+
|
|
3
|
+
MCP server for [Adobe Spectrum](https://spectrum.adobe.com) design tokens, component schemas,
|
|
4
|
+
and design guidelines. Runs fully in-process via an embedded Spectrum snapshot — no network
|
|
5
|
+
access, no CLI binary, and no configuration required.
|
|
6
|
+
|
|
7
|
+
## Install in Claude Desktop (Extension)
|
|
8
|
+
|
|
9
|
+
Download the latest `design-data.mcpb` from the
|
|
10
|
+
[releases page](https://github.com/adobe/spectrum-design-data/releases) and drag it into
|
|
11
|
+
**Claude Desktop → Settings → Extensions**.
|
|
12
|
+
|
|
13
|
+
No API keys or configuration needed. The extension installs and runs offline.
|
|
14
|
+
|
|
15
|
+
## Setup via npx (Cursor / Claude Desktop manual config)
|
|
16
|
+
|
|
17
|
+
### Cursor
|
|
18
|
+
|
|
19
|
+
Add to `.cursor/mcp-servers.json` in your project root:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"design-data": {
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": ["-y", "@adobe/design-data-mcp@latest"]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Claude Desktop (manual config)
|
|
33
|
+
|
|
34
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"design-data": {
|
|
40
|
+
"command": "npx",
|
|
41
|
+
"args": ["-y", "@adobe/design-data-mcp@latest"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Staying current
|
|
48
|
+
|
|
49
|
+
The embedded Spectrum snapshot is baked into the wasm at build time and travels with the
|
|
50
|
+
package version — there's no separate data update to run. Pin `@latest` (as above) so `npx`
|
|
51
|
+
fetches the newest published version rather than reusing whatever it last cached; `-y` alone
|
|
52
|
+
only skips the install confirmation, it doesn't force a re-fetch. Call `design-data-primer` and
|
|
53
|
+
check `provenance.designDataVersion` to see which dataset version is embedded.
|
|
54
|
+
`design-data-primer` also does a best-effort check against the latest published
|
|
55
|
+
`@adobe/spectrum-design-data` version — if the embedded dataset is behind, it adds a
|
|
56
|
+
`provenance.datasetStatus` field and logs a one-line warning to stderr. This is silent on
|
|
57
|
+
any network failure (offline/air-gapped use is unaffected); set
|
|
58
|
+
`DESIGN_DATA_SKIP_VERSION_CHECK=1` to disable the check entirely.
|
|
59
|
+
|
|
60
|
+
## Tools
|
|
61
|
+
|
|
62
|
+
| Tool | Description |
|
|
63
|
+
| ---------------------------- | ---------------------------------------------------------------------------------- |
|
|
64
|
+
| `design-data-primer` | Session-start overview: token count, mode-sets, components, guidelines, provenance |
|
|
65
|
+
| `design-data-query` | Filter tokens by query expression (`component=button`, `property=color-*`) |
|
|
66
|
+
| `design-data-suggest` | Natural-language token suggestions with Jaccard similarity confidence scores |
|
|
67
|
+
| `design-data-component` | Full component schema (variants, sizes, states, props) by kebab-case ID |
|
|
68
|
+
| `design-data-resolve` | Resolve a token's concrete value for a mode context (colorScheme, scale, contrast) |
|
|
69
|
+
| `design-data-guideline-list` | List available Spectrum design guideline pages, optionally filtered by category |
|
|
70
|
+
| `design-data-guideline` | Full guideline document by slug ID (purpose, rules, accessibility, examples) |
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
Apache-2.0 — see the [project repository](https://github.com/adobe/spectrum-design-data) for details.
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adobe/design-data-mcp",
|
|
3
|
+
"version": "0.0.0-size-token-taxonomy-20260929225107",
|
|
4
|
+
"description": "MCP server for Spectrum design tokens, component schemas, and design guidelines (embedded, offline)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"design-data-mcp": "./src/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src/",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/adobe/spectrum-design-data.git",
|
|
18
|
+
"directory": "tools/design-data-mcp"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/adobe/spectrum-design-data/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/adobe/spectrum-design-data/tree/main/tools/design-data-mcp#readme",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org/",
|
|
27
|
+
"provenance": true
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
31
|
+
"@adobe/design-data": "0.0.0-size-token-taxonomy-20260929225107",
|
|
32
|
+
"@adobe/design-data-wasm": "0.0.0-size-token-taxonomy-20260929225107",
|
|
33
|
+
"@adobe/spectrum-design-data": "0.0.0-size-token-taxonomy-20260929225107"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@anthropic-ai/mcpb": "^2.1.2",
|
|
37
|
+
"ava": "^6.0.1",
|
|
38
|
+
"sharp": "^0.35.1"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20.12.0"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"mcp",
|
|
45
|
+
"spectrum",
|
|
46
|
+
"adobe",
|
|
47
|
+
"design-system",
|
|
48
|
+
"design-tokens",
|
|
49
|
+
"design-data"
|
|
50
|
+
],
|
|
51
|
+
"author": "Adobe",
|
|
52
|
+
"license": "Apache-2.0",
|
|
53
|
+
"scripts": {
|
|
54
|
+
"start": "node src/cli.js",
|
|
55
|
+
"test": "ava"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
// This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
// of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
//
|
|
7
|
+
// Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
// OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
// governing permissions and limitations under the License.
|
|
11
|
+
|
|
12
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
13
|
+
import { createMCPServer } from "./index.js";
|
|
14
|
+
|
|
15
|
+
const server = createMCPServer();
|
|
16
|
+
const transport = new StdioServerTransport();
|
|
17
|
+
await server.connect(transport);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright 2026 Adobe. All rights reserved.
|
|
2
|
+
// This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License. You may obtain a copy
|
|
4
|
+
// of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
//
|
|
6
|
+
// Unless required by applicable law or agreed to in writing, software distributed under
|
|
7
|
+
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
8
|
+
// OF ANY KIND, either express or implied. See the License for the specific language
|
|
9
|
+
// governing permissions and limitations under the License.
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Best-effort runtime check that the embedded dataset (provenance.designDataVersion,
|
|
13
|
+
* baked into @adobe/design-data-wasm at build time) isn't behind the latest published
|
|
14
|
+
* @adobe/spectrum-design-data. See spectrum-design-data-9fe.5 — a plain `npx -y <pkg>`
|
|
15
|
+
* (no @latest tag) can silently reuse a cached older wasm build.
|
|
16
|
+
*
|
|
17
|
+
* Deliberately silent on any failure (offline, registry down, timeout): this is a
|
|
18
|
+
* courtesy signal, never a reason to break the primer response.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const REGISTRY_URL =
|
|
22
|
+
"https://registry.npmjs.org/@adobe/spectrum-design-data/latest";
|
|
23
|
+
const TIMEOUT_MS = 1500;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Numeric major.minor.patch compare. ponytail: ignores prerelease/build tags;
|
|
27
|
+
* add real semver only if a data prerelease ships.
|
|
28
|
+
*/
|
|
29
|
+
export function isBehind(embedded, latest) {
|
|
30
|
+
const a = String(embedded).split(".").map(Number);
|
|
31
|
+
const b = String(latest).split(".").map(Number);
|
|
32
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
33
|
+
const x = a[i] ?? 0;
|
|
34
|
+
const y = b[i] ?? 0;
|
|
35
|
+
if (x !== y) return x < y;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let warned = false;
|
|
41
|
+
let cached; // Promise<status|null>, memoized per process — cleared on failure so a
|
|
42
|
+
// transient network blip doesn't permanently disable the check (see fetchLatest).
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {string} embeddedVersion - provenance.designDataVersion from ds.primer()
|
|
46
|
+
* @returns {Promise<{latestVersion: string, isStale: boolean, message?: string}|null>}
|
|
47
|
+
*/
|
|
48
|
+
export function checkDatasetFreshness(embeddedVersion) {
|
|
49
|
+
if (!embeddedVersion || process.env.DESIGN_DATA_SKIP_VERSION_CHECK) {
|
|
50
|
+
return Promise.resolve(null);
|
|
51
|
+
}
|
|
52
|
+
if (!cached) {
|
|
53
|
+
cached = fetchLatest(embeddedVersion).then((status) => {
|
|
54
|
+
// A null result means the check failed (offline/timeout/registry error) —
|
|
55
|
+
// don't memoize failure, so the next primer call retries instead of being
|
|
56
|
+
// stuck with no freshness signal for the rest of the process.
|
|
57
|
+
if (status === null) cached = undefined;
|
|
58
|
+
return status;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return cached;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function fetchLatest(embeddedVersion) {
|
|
65
|
+
const controller = new AbortController();
|
|
66
|
+
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
67
|
+
try {
|
|
68
|
+
const res = await fetch(REGISTRY_URL, { signal: controller.signal });
|
|
69
|
+
if (!res.ok) return null;
|
|
70
|
+
const { version: latestVersion } = await res.json();
|
|
71
|
+
const isStale = isBehind(embeddedVersion, latestVersion);
|
|
72
|
+
const status = { latestVersion, isStale };
|
|
73
|
+
if (isStale) {
|
|
74
|
+
status.message =
|
|
75
|
+
`Embedded dataset (${embeddedVersion}) is behind the latest published ` +
|
|
76
|
+
`@adobe/spectrum-design-data (${latestVersion}). Reinstall with ` +
|
|
77
|
+
`npx -y @adobe/design-data-mcp@latest to pick up the newer snapshot.`;
|
|
78
|
+
if (!warned) {
|
|
79
|
+
warned = true;
|
|
80
|
+
console.error(`[design-data] ${status.message}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return status;
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
} finally {
|
|
87
|
+
clearTimeout(timer);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Test-only: clear the memoized check + warn-once flag between cases. */
|
|
92
|
+
export function __resetFreshnessCache() {
|
|
93
|
+
warned = false;
|
|
94
|
+
cached = undefined;
|
|
95
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Copyright 2026 Adobe. All rights reserved.
|
|
2
|
+
// This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License. You may obtain a copy
|
|
4
|
+
// of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
//
|
|
6
|
+
// Unless required by applicable law or agreed to in writing, software distributed under
|
|
7
|
+
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
8
|
+
// OF ANY KIND, either express or implied. See the License for the specific language
|
|
9
|
+
// governing permissions and limitations under the License.
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @adobe/design-data-mcp — MCP server for Spectrum design tokens and components.
|
|
13
|
+
*
|
|
14
|
+
* Exposes seven read-only MCP tools backed by @adobe/design-data-wasm running
|
|
15
|
+
* in-process (no CLI binary or npx required). The embedded Spectrum snapshot
|
|
16
|
+
* powers zero-config offline use across Claude Desktop, Cursor, and any
|
|
17
|
+
* MCP-compatible agent.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { readFileSync } from "fs";
|
|
21
|
+
import { fileURLToPath } from "url";
|
|
22
|
+
import { dirname, resolve } from "path";
|
|
23
|
+
|
|
24
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
25
|
+
import {
|
|
26
|
+
CallToolRequestSchema,
|
|
27
|
+
ListToolsRequestSchema,
|
|
28
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
29
|
+
|
|
30
|
+
import { createDesignDataTools } from "./tools/design-data.js";
|
|
31
|
+
|
|
32
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
33
|
+
const packageJson = JSON.parse(
|
|
34
|
+
readFileSync(resolve(__dirname, "../package.json"), "utf8"),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const SERVER_INSTRUCTIONS =
|
|
38
|
+
`This server bundles a snapshot of Spectrum design data (tokens, ` +
|
|
39
|
+
`components, guidelines) baked into its wasm at build time. The data version travels with ` +
|
|
40
|
+
`the package version, so there is nothing to update separately. To get newer Spectrum data, ` +
|
|
41
|
+
`install the latest published package (npx -y @adobe/design-data-mcp@latest — plain ` +
|
|
42
|
+
`"npx -y @adobe/design-data-mcp" can reuse a cached older build). Call design-data-primer ` +
|
|
43
|
+
`and read provenance.designDataVersion to see the embedded dataset version.`;
|
|
44
|
+
|
|
45
|
+
export function createMCPServer() {
|
|
46
|
+
const server = new Server(
|
|
47
|
+
{ name: "design-data", version: packageJson.version },
|
|
48
|
+
{ capabilities: { tools: {} }, instructions: SERVER_INSTRUCTIONS },
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const tools = createDesignDataTools();
|
|
52
|
+
|
|
53
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
54
|
+
tools: tools.map(({ name, description, inputSchema, annotations }) => ({
|
|
55
|
+
name,
|
|
56
|
+
description,
|
|
57
|
+
inputSchema,
|
|
58
|
+
annotations,
|
|
59
|
+
})),
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
63
|
+
const tool = tools.find((t) => t.name === request.params.name);
|
|
64
|
+
if (!tool) {
|
|
65
|
+
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const result = await tool.handler(request.params.arguments ?? {});
|
|
70
|
+
return {
|
|
71
|
+
content: [
|
|
72
|
+
{
|
|
73
|
+
type: "text",
|
|
74
|
+
text:
|
|
75
|
+
typeof result === "string"
|
|
76
|
+
? result
|
|
77
|
+
: JSON.stringify(result, null, 2),
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
};
|
|
81
|
+
} catch (err) {
|
|
82
|
+
return {
|
|
83
|
+
content: [{ type: "text", text: String(err.message) }],
|
|
84
|
+
isError: true,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return server;
|
|
90
|
+
}
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
// Copyright 2026 Adobe. All rights reserved.
|
|
2
|
+
// This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License. You may obtain a copy
|
|
4
|
+
// of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
//
|
|
6
|
+
// Unless required by applicable law or agreed to in writing, software distributed under
|
|
7
|
+
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
8
|
+
// OF ANY KIND, either express or implied. See the License for the specific language
|
|
9
|
+
// governing permissions and limitations under the License.
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* MCP tool definitions for @adobe/design-data-mcp.
|
|
13
|
+
*
|
|
14
|
+
* All tools run in-process via @adobe/design-data-wasm — no CLI binary or npx
|
|
15
|
+
* required. Dataset.embedded() provides the canonical Spectrum snapshot with
|
|
16
|
+
* zero configuration.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { createRequire } from "module";
|
|
20
|
+
import { readFileSync, existsSync } from "fs";
|
|
21
|
+
import { join, dirname, resolve, sep } from "path";
|
|
22
|
+
|
|
23
|
+
import { listGuidelines, loadGuideline } from "@adobe/design-data/guideline";
|
|
24
|
+
|
|
25
|
+
import { checkDatasetFreshness } from "../dataset-freshness.js";
|
|
26
|
+
|
|
27
|
+
let _wasm;
|
|
28
|
+
/** Lazy-load and cache the wasm module (nodejs target, no init() required). */
|
|
29
|
+
async function getWasm() {
|
|
30
|
+
if (!_wasm) _wasm = await import("@adobe/design-data-wasm");
|
|
31
|
+
return _wasm;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let _dataset;
|
|
35
|
+
/**
|
|
36
|
+
* Return the embedded Spectrum dataset, caching it after first access.
|
|
37
|
+
*
|
|
38
|
+
* Dataset.embedded() clones the in-memory graph on every call; caching here
|
|
39
|
+
* avoids that per-request cost.
|
|
40
|
+
*/
|
|
41
|
+
async function getDataset() {
|
|
42
|
+
if (!_dataset) {
|
|
43
|
+
const wasm = await getWasm();
|
|
44
|
+
_dataset = wasm.Dataset.embedded();
|
|
45
|
+
}
|
|
46
|
+
return _dataset;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Return the @adobe/spectrum-design-data package root directory, or null. */
|
|
50
|
+
function resolveSpectrumDataPackage() {
|
|
51
|
+
try {
|
|
52
|
+
const req = createRequire(import.meta.url);
|
|
53
|
+
return dirname(req.resolve("@adobe/spectrum-design-data/package.json"));
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Load a JSON file from a subdirectory of the design-data package.
|
|
61
|
+
* Throws descriptive errors when the package or file is absent.
|
|
62
|
+
*
|
|
63
|
+
* Path safety: the resolved absolute path is asserted to stay within
|
|
64
|
+
* `<pkgRoot>/<subdir>/` so that a crafted `id` value (e.g. `../../etc/passwd`)
|
|
65
|
+
* cannot read files outside the intended data directory.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} subdir - e.g. "components" or "guidelines"
|
|
68
|
+
* @param {string} id - kebab-case slug, e.g. "button" or "colors"
|
|
69
|
+
*/
|
|
70
|
+
function loadDataFile(subdir, id) {
|
|
71
|
+
const pkgRoot = resolveSpectrumDataPackage();
|
|
72
|
+
if (!pkgRoot) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`@adobe/spectrum-design-data is not installed — cannot load ${subdir}/${id}. ` +
|
|
75
|
+
`Install it with: pnpm add @adobe/spectrum-design-data`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Guideline loading (path-traversal guard included) is shared with
|
|
80
|
+
// @adobe/design-data-agent-mcp's describe_guideline tool via
|
|
81
|
+
// @adobe/design-data/guideline — reuse it here instead of duplicating the
|
|
82
|
+
// same containment check.
|
|
83
|
+
if (subdir === "guidelines") {
|
|
84
|
+
try {
|
|
85
|
+
return loadGuideline(resolve(pkgRoot, subdir), id);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
if (err.message.startsWith("Not found:")) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`${err.message} Call design-data-guideline-list to see available guideline IDs.`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const baseDir = resolve(pkgRoot, subdir);
|
|
97
|
+
const filePath = resolve(baseDir, `${id}.json`);
|
|
98
|
+
// Containment check: reject any path that escapes the intended subdirectory.
|
|
99
|
+
if (!filePath.startsWith(baseDir + sep)) {
|
|
100
|
+
throw new Error(`Invalid ${subdir} id: "${id}"`);
|
|
101
|
+
}
|
|
102
|
+
if (!existsSync(filePath)) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
`Not found: "${id}" in ${subdir}/. ` +
|
|
105
|
+
`Call design-data-primer to see available component IDs.`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return JSON.parse(readFileSync(filePath, "utf-8"));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Load the guidelines/manifest.json catalog.
|
|
113
|
+
* Returns null when the package or manifest does not exist.
|
|
114
|
+
*/
|
|
115
|
+
function loadGuidelineManifest() {
|
|
116
|
+
const pkgRoot = resolveSpectrumDataPackage();
|
|
117
|
+
if (!pkgRoot) return null;
|
|
118
|
+
const guidelinesDir = join(pkgRoot, "guidelines");
|
|
119
|
+
if (!existsSync(guidelinesDir)) return null;
|
|
120
|
+
return { guidelines: listGuidelines(guidelinesDir) };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function createDesignDataTools() {
|
|
124
|
+
return [
|
|
125
|
+
// ── primer ─────────────────────────────────────────────────────────────
|
|
126
|
+
{
|
|
127
|
+
name: "design-data-primer",
|
|
128
|
+
annotations: {
|
|
129
|
+
title: "Design Data: Primer",
|
|
130
|
+
readOnlyHint: true,
|
|
131
|
+
openWorldHint: false,
|
|
132
|
+
},
|
|
133
|
+
description:
|
|
134
|
+
"Get a structural overview of the Spectrum design dataset: token count, " +
|
|
135
|
+
"available mode-sets (color-scheme, scale, contrast), component list, " +
|
|
136
|
+
"taxonomy fields, guideline categories, and data provenance. Call this at the " +
|
|
137
|
+
"start of a design-token session to understand what data is available.",
|
|
138
|
+
inputSchema: {
|
|
139
|
+
type: "object",
|
|
140
|
+
properties: {},
|
|
141
|
+
additionalProperties: false,
|
|
142
|
+
},
|
|
143
|
+
async handler() {
|
|
144
|
+
const [wasm, ds] = await Promise.all([getWasm(), getDataset()]);
|
|
145
|
+
|
|
146
|
+
const manifest = loadGuidelineManifest();
|
|
147
|
+
const guidelinesSummary = manifest
|
|
148
|
+
? {
|
|
149
|
+
count: manifest.guidelines.length,
|
|
150
|
+
categories: [
|
|
151
|
+
...new Set(
|
|
152
|
+
manifest.guidelines.map((g) => g.category).filter(Boolean),
|
|
153
|
+
),
|
|
154
|
+
].sort(),
|
|
155
|
+
}
|
|
156
|
+
: null;
|
|
157
|
+
|
|
158
|
+
// Provenance carries source + designDataVersion (the @adobe/spectrum-design-data
|
|
159
|
+
// package version baked into the wasm at build time via EMBEDDED_DATA_VERSION).
|
|
160
|
+
const { provenance } = ds.primer();
|
|
161
|
+
// Best-effort staleness check (spectrum-design-data-9fe.5) — silent on
|
|
162
|
+
// failure, never blocks the primer response.
|
|
163
|
+
const datasetStatus = await checkDatasetFreshness(
|
|
164
|
+
provenance.designDataVersion,
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
// top-level source is the legacy skill-contract field; provenance.source
|
|
169
|
+
// duplicates it intentionally — provenance is the richer metrics object
|
|
170
|
+
// and consumers should prefer it going forward.
|
|
171
|
+
source: "embedded",
|
|
172
|
+
tokenCount: ds.tokenCount(),
|
|
173
|
+
modeSets: {
|
|
174
|
+
colorScheme: wasm.getFieldValues("colorScheme") ?? [],
|
|
175
|
+
scale: wasm.getFieldValues("scale") ?? [],
|
|
176
|
+
contrast: wasm.getFieldValues("contrast") ?? [],
|
|
177
|
+
},
|
|
178
|
+
taxonomyFields: {
|
|
179
|
+
indexed: wasm.getIndexedFields(),
|
|
180
|
+
advisory: wasm.getAdvisoryFields() ?? [],
|
|
181
|
+
},
|
|
182
|
+
components: wasm.getFieldValues("component") ?? [],
|
|
183
|
+
properties: wasm.getFieldValues("property") ?? [],
|
|
184
|
+
guidelines: guidelinesSummary,
|
|
185
|
+
provenance: datasetStatus
|
|
186
|
+
? { ...provenance, datasetStatus }
|
|
187
|
+
: provenance,
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
// ── query ───────────────────────────────────────────────────────────────
|
|
193
|
+
{
|
|
194
|
+
name: "design-data-query",
|
|
195
|
+
annotations: {
|
|
196
|
+
title: "Design Data: Query Tokens",
|
|
197
|
+
readOnlyHint: true,
|
|
198
|
+
openWorldHint: false,
|
|
199
|
+
},
|
|
200
|
+
description:
|
|
201
|
+
"Filter Spectrum tokens by a query expression. " +
|
|
202
|
+
"Expression syntax: `component=button`, `component=button,state=hover`, " +
|
|
203
|
+
"`property=color-*`, `colorScheme=dark`. " +
|
|
204
|
+
"Returns an array of matching token objects.",
|
|
205
|
+
inputSchema: {
|
|
206
|
+
type: "object",
|
|
207
|
+
properties: {
|
|
208
|
+
filter: {
|
|
209
|
+
type: "string",
|
|
210
|
+
description:
|
|
211
|
+
'Query expression, e.g. "component=button" or "property=color-*,component=action-button"',
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
required: ["filter"],
|
|
215
|
+
additionalProperties: false,
|
|
216
|
+
},
|
|
217
|
+
async handler({ filter }) {
|
|
218
|
+
const ds = await getDataset();
|
|
219
|
+
return ds.query(filter);
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
// ── suggest ─────────────────────────────────────────────────────────────
|
|
224
|
+
{
|
|
225
|
+
name: "design-data-suggest",
|
|
226
|
+
annotations: {
|
|
227
|
+
title: "Design Data: Suggest Tokens",
|
|
228
|
+
readOnlyHint: true,
|
|
229
|
+
openWorldHint: false,
|
|
230
|
+
},
|
|
231
|
+
description:
|
|
232
|
+
"Suggest Spectrum tokens matching a natural-language intent using Jaccard similarity " +
|
|
233
|
+
"scoring over token name segments, name-object fields, and description text. " +
|
|
234
|
+
"Returns matches ranked by confidence with token name, layer, value, and name object. " +
|
|
235
|
+
"Use when the user describes what they need rather than knowing the token name.",
|
|
236
|
+
inputSchema: {
|
|
237
|
+
type: "object",
|
|
238
|
+
properties: {
|
|
239
|
+
intent: {
|
|
240
|
+
type: "string",
|
|
241
|
+
description:
|
|
242
|
+
'Natural-language description of the design need, e.g. "primary CTA button background color"',
|
|
243
|
+
},
|
|
244
|
+
limit: {
|
|
245
|
+
type: "number",
|
|
246
|
+
description: "Maximum number of suggestions to return (default: 5)",
|
|
247
|
+
default: 5,
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
required: ["intent"],
|
|
251
|
+
additionalProperties: false,
|
|
252
|
+
},
|
|
253
|
+
async handler({ intent, limit = 5 }) {
|
|
254
|
+
const ds = await getDataset();
|
|
255
|
+
return ds.suggest(intent, undefined, limit);
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
// ── component ───────────────────────────────────────────────────────────
|
|
260
|
+
{
|
|
261
|
+
name: "design-data-component",
|
|
262
|
+
annotations: {
|
|
263
|
+
title: "Design Data: Get Component",
|
|
264
|
+
readOnlyHint: true,
|
|
265
|
+
openWorldHint: false,
|
|
266
|
+
},
|
|
267
|
+
description:
|
|
268
|
+
"Get the full component declaration for a Spectrum component by ID. " +
|
|
269
|
+
"Returns the component's displayName, description, and all available options " +
|
|
270
|
+
"(variants, sizes, states, boolean props, etc.). " +
|
|
271
|
+
"Component IDs are kebab-case, e.g. button, action-button, text-field, picker.",
|
|
272
|
+
inputSchema: {
|
|
273
|
+
type: "object",
|
|
274
|
+
properties: {
|
|
275
|
+
id: {
|
|
276
|
+
type: "string",
|
|
277
|
+
description:
|
|
278
|
+
"Component ID in kebab-case, e.g. button, action-button, picker, text-field",
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
required: ["id"],
|
|
282
|
+
additionalProperties: false,
|
|
283
|
+
},
|
|
284
|
+
async handler({ id }) {
|
|
285
|
+
return loadDataFile("components", id);
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
// ── resolve ─────────────────────────────────────────────────────────────
|
|
290
|
+
{
|
|
291
|
+
name: "design-data-resolve",
|
|
292
|
+
annotations: {
|
|
293
|
+
title: "Design Data: Resolve Token",
|
|
294
|
+
readOnlyHint: true,
|
|
295
|
+
openWorldHint: false,
|
|
296
|
+
},
|
|
297
|
+
description:
|
|
298
|
+
"Resolve the concrete value of a Spectrum token property for a given " +
|
|
299
|
+
"mode-set context (color-scheme, scale, contrast). " +
|
|
300
|
+
"Returns the winning token with its resolved value.",
|
|
301
|
+
inputSchema: {
|
|
302
|
+
type: "object",
|
|
303
|
+
properties: {
|
|
304
|
+
property: {
|
|
305
|
+
type: "string",
|
|
306
|
+
description:
|
|
307
|
+
"Token property name, e.g. background-color-default, accent-color",
|
|
308
|
+
},
|
|
309
|
+
colorScheme: {
|
|
310
|
+
type: "string",
|
|
311
|
+
description: 'Color scheme mode, e.g. "light" or "dark"',
|
|
312
|
+
},
|
|
313
|
+
scale: {
|
|
314
|
+
type: "string",
|
|
315
|
+
description: 'Scale mode, e.g. "desktop" or "mobile"',
|
|
316
|
+
},
|
|
317
|
+
contrast: {
|
|
318
|
+
type: "string",
|
|
319
|
+
description: 'Contrast mode, e.g. "regular" or "high"',
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
required: ["property"],
|
|
323
|
+
additionalProperties: false,
|
|
324
|
+
},
|
|
325
|
+
async handler({ property, colorScheme, scale, contrast }) {
|
|
326
|
+
const ds = await getDataset();
|
|
327
|
+
const context = {};
|
|
328
|
+
if (colorScheme) context.colorScheme = colorScheme;
|
|
329
|
+
if (scale) context.scale = scale;
|
|
330
|
+
if (contrast) context.contrast = contrast;
|
|
331
|
+
const result = ds.resolve(property, context);
|
|
332
|
+
if (!result) {
|
|
333
|
+
throw new Error(
|
|
334
|
+
`No token found for property "${property}" in context ${JSON.stringify(context)}`,
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
return result;
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
// ── guideline-list ──────────────────────────────────────────────────────
|
|
342
|
+
{
|
|
343
|
+
name: "design-data-guideline-list",
|
|
344
|
+
annotations: {
|
|
345
|
+
title: "Design Data: List Guidelines",
|
|
346
|
+
readOnlyHint: true,
|
|
347
|
+
openWorldHint: false,
|
|
348
|
+
},
|
|
349
|
+
description:
|
|
350
|
+
"List available Spectrum design guideline pages. " +
|
|
351
|
+
"Returns catalog entries with slug, title, category, status, and sourceUrl. " +
|
|
352
|
+
"Use this to discover guideline IDs before calling design-data-guideline. " +
|
|
353
|
+
"Optionally filter by category: designing, fundamentals, developing, or support.",
|
|
354
|
+
inputSchema: {
|
|
355
|
+
type: "object",
|
|
356
|
+
properties: {
|
|
357
|
+
category: {
|
|
358
|
+
type: "string",
|
|
359
|
+
enum: ["designing", "fundamentals", "developing", "support"],
|
|
360
|
+
description:
|
|
361
|
+
"Filter results to a specific category (optional). " +
|
|
362
|
+
"Omit to return all guidelines.",
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
additionalProperties: false,
|
|
366
|
+
},
|
|
367
|
+
async handler({ category } = {}) {
|
|
368
|
+
const manifest = loadGuidelineManifest();
|
|
369
|
+
if (!manifest) {
|
|
370
|
+
throw new Error(
|
|
371
|
+
`guidelines/manifest.json not found in @adobe/spectrum-design-data. ` +
|
|
372
|
+
`Run: node tools/s2-docs-to-document-blocks/src/cli.js guideline`,
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
const entries = category
|
|
376
|
+
? manifest.guidelines.filter((g) => g.category === category)
|
|
377
|
+
: manifest.guidelines;
|
|
378
|
+
return { guidelines: entries, total: entries.length };
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
// ── guideline ───────────────────────────────────────────────────────────
|
|
383
|
+
{
|
|
384
|
+
name: "design-data-guideline",
|
|
385
|
+
annotations: {
|
|
386
|
+
title: "Design Data: Get Guideline",
|
|
387
|
+
readOnlyHint: true,
|
|
388
|
+
openWorldHint: false,
|
|
389
|
+
},
|
|
390
|
+
description:
|
|
391
|
+
"Get the full guideline document for a Spectrum design page by ID. " +
|
|
392
|
+
"Returns the guideline's title, category, metadata, and documentBlocks body " +
|
|
393
|
+
"(purpose, guideline, accessibility, do-dont, and examples blocks). " +
|
|
394
|
+
"Call design-data-guideline-list first to discover available guideline IDs. " +
|
|
395
|
+
"The `id` is the `slug` value returned by design-data-guideline-list.",
|
|
396
|
+
inputSchema: {
|
|
397
|
+
type: "object",
|
|
398
|
+
properties: {
|
|
399
|
+
id: {
|
|
400
|
+
type: "string",
|
|
401
|
+
description:
|
|
402
|
+
"Guideline ID (kebab-case slug) as returned by design-data-guideline-list, " +
|
|
403
|
+
"e.g. colors, motion, typography-fundamentals",
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
required: ["id"],
|
|
407
|
+
additionalProperties: false,
|
|
408
|
+
},
|
|
409
|
+
async handler({ id }) {
|
|
410
|
+
return loadDataFile("guidelines", id);
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
];
|
|
414
|
+
}
|