@synergy-design-system/mcp 3.7.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +207 -18
  3. package/dist/middleware/index.d.ts +1 -0
  4. package/dist/middleware/index.js +1 -0
  5. package/dist/middleware/logging.d.ts +5 -5
  6. package/dist/middleware/logging.js +72 -0
  7. package/dist/prompts/component-rules.d.ts +2 -0
  8. package/dist/prompts/component-rules.js +36 -0
  9. package/dist/prompts/index.d.ts +1 -0
  10. package/dist/prompts/index.js +1 -0
  11. package/dist/resources/index.d.ts +1 -0
  12. package/dist/resources/index.js +1 -0
  13. package/dist/resources/intent-categories-list.d.ts +7 -0
  14. package/dist/resources/intent-categories-list.js +25 -0
  15. package/dist/server.js +23 -6
  16. package/dist/tools/component-info.js +5 -2
  17. package/dist/tools/index.d.ts +5 -0
  18. package/dist/tools/index.js +5 -0
  19. package/dist/tools/intent-categories-list.d.ts +6 -0
  20. package/dist/tools/intent-categories-list.js +26 -0
  21. package/dist/tools/intent-component-guide.d.ts +6 -0
  22. package/dist/tools/intent-component-guide.js +33 -0
  23. package/dist/tools/intent-component-validate.d.ts +6 -0
  24. package/dist/tools/intent-component-validate.js +169 -0
  25. package/dist/tools/intent-options.d.ts +6 -0
  26. package/dist/tools/intent-options.js +48 -0
  27. package/dist/tools/intent-task-recommendations.d.ts +6 -0
  28. package/dist/tools/intent-task-recommendations.js +54 -0
  29. package/dist/tools/token-info.js +26 -5
  30. package/dist/tools/tokens-list.d.ts +1 -1
  31. package/dist/tools/tokens-list.js +3 -1
  32. package/dist/types/prompt-response.d.ts +14 -0
  33. package/dist/types/prompt-response.js +1 -0
  34. package/dist/utilities/config.d.ts +78 -1
  35. package/dist/utilities/config.js +132 -3
  36. package/dist/utilities/index.d.ts +1 -0
  37. package/dist/utilities/index.js +1 -0
  38. package/dist/utilities/intent.d.ts +27 -0
  39. package/dist/utilities/intent.js +26 -0
  40. package/dist/utilities/metadata.d.ts +16 -0
  41. package/dist/utilities/metadata.js +109 -14
  42. package/package.json +2 -2
  43. package/rules/token-info.md +9 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1271](https://github.com/synergy-design-system/synergy-design-system/pull/1271) [`74917ea`](https://github.com/synergy-design-system/synergy-design-system/commit/74917ea30e2d26780202c382c7f157c63e3833ef) Thanks [@kirchsuSICKAG](https://github.com/kirchsuSICKAG)! - Released on: 2026-05-28
8
+
9
+ feat: ✨ `<syn-chart>` ([#1205](https://github.com/synergy-design-system/synergy-design-system/issues/1205))
10
+
11
+ This release adds an experimental MVP for the new `<syn-chart>` component for data visualization based on [Apache ECharts](https://echarts.apache.org).
12
+ It is available for Web Component, React, Angular and Vue
13
+
14
+ > ⚠️ **Experimental:** The API or behavior may change in future releases without a major version bump.
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [[`74917ea`](https://github.com/synergy-design-system/synergy-design-system/commit/74917ea30e2d26780202c382c7f157c63e3833ef)]:
19
+ - @synergy-design-system/metadata@3.9.0
20
+
21
+ ## 3.8.0
22
+
23
+ ### Minor Changes
24
+
25
+ - [#1276](https://github.com/synergy-design-system/synergy-design-system/pull/1276) [`a6b68f2`](https://github.com/synergy-design-system/synergy-design-system/commit/a6b68f2126ee0c63f2e9f5a91d96e97c2486e3c9) Thanks [@schilchSICKAG](https://github.com/schilchSICKAG)! - Released on: 2026-05-21
26
+
27
+ feat: ✨ component context guidelines ([#1187](https://github.com/synergy-design-system/synergy-design-system/issues/1187))
28
+ - Correct `@since` flags for all components
29
+ - Updated component usage rules (beta)
30
+ - Add missing rules files
31
+ - Create overviews for all components
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [[`a6b68f2`](https://github.com/synergy-design-system/synergy-design-system/commit/a6b68f2126ee0c63f2e9f5a91d96e97c2486e3c9)]:
36
+ - @synergy-design-system/metadata@3.8.0
37
+
3
38
  ## 3.7.0
4
39
 
5
40
  ### Minor Changes
package/README.md CHANGED
@@ -145,6 +145,12 @@ Example:
145
145
  // "toon": Encode structured data to compact toon text format
146
146
  "compression": "none",
147
147
 
148
+ // Experimental feature toggles
149
+ "experimentalFeatures": {
150
+ // Enables experimental intent policy tools
151
+ "intentTools": true,
152
+ },
153
+
148
154
  // Default parameters for each endpoint can be overridden
149
155
  "tools": {
150
156
  "assetInfo": {
@@ -156,11 +162,36 @@ Example:
156
162
  // Defines which type of information to return.
157
163
  // full = filtered source files,
158
164
  // examples = markdown examples,
159
- // interface = markdown API overview.
165
+ // interface = markdown API overview,
166
+ // rules = markdown usage, design, and accessibility guidance.
160
167
  // Note that examples and interface are only available
161
168
  // for vanilla components at the moment.
162
169
  "layer": "full",
163
170
  },
171
+ "intentCategoriesList": {
172
+ // Default phases for intent-categories-list
173
+ "includePhases": ["experimental"],
174
+ },
175
+ "intentComponentGuide": {
176
+ // Framework profile used when omitted in tool call
177
+ "framework": "vanilla",
178
+ "includePhases": ["experimental"],
179
+ },
180
+ "intentComponentValidate": {
181
+ "framework": "vanilla",
182
+ "includePhases": ["experimental"],
183
+ },
184
+ "intentOptions": {
185
+ "framework": "vanilla",
186
+ "includeDiagnostics": false,
187
+ "includePhases": ["experimental"],
188
+ "maxAlternatives": 5,
189
+ },
190
+ "intentTaskRecommendations": {
191
+ "framework": "vanilla",
192
+ "includePhases": ["experimental"],
193
+ "maxAlternatives": 5,
194
+ },
164
195
  "tokenInfo": {
165
196
  // If you are preferring scss, use "sass" here
166
197
  "type": "css",
@@ -169,6 +200,33 @@ Example:
169
200
  }
170
201
  ```
171
202
 
203
+ #### Enabling Experimental Intent Endpoints
204
+
205
+ Intent tools are experimental and disabled by default.
206
+ Enable them explicitly with:
207
+
208
+ ```jsonc
209
+ {
210
+ "experimentalFeatures": {
211
+ "intentTools": true,
212
+ },
213
+ }
214
+ ```
215
+
216
+ When enabled, these additional features become available:
217
+
218
+ #### Resources
219
+
220
+ - `synergy://intent-categories/list`
221
+
222
+ #### Tools
223
+
224
+ - `intent-categories-list`
225
+ - `intent-component-guide`
226
+ - `intent-component-validate`
227
+ - `intent-task-recommendations`
228
+ - `intent-options`
229
+
172
230
  #### CLI Override Precedence
173
231
 
174
232
  CLI flags take precedence over configuration file values:
@@ -301,7 +359,9 @@ This lets you change per-tool defaults without modifying the MCP server code.
301
359
 
302
360
  ## Available Resources
303
361
 
304
- The MCP server currently registers 5 resources. Resources expose static, read-only data that does not change during server runtime. Clients that support MCP resources can read them directly without calling a tool.
362
+ The MCP server currently registers 5 stable resources by default. Resources expose static, read-only data that does not change during server runtime. Clients that support MCP resources can read them directly without calling a tool.
363
+
364
+ When `experimentalFeatures.intentTools` is enabled, 1 additional intent resource is registered.
305
365
 
306
366
  Resource identifier reference (exact values used by the server):
307
367
 
@@ -310,6 +370,7 @@ Resource identifier reference (exact values used by the server):
310
370
  - `synergy://component-clusters/list` → name: `component-clusters-list`
311
371
  - `synergy://styles/list` → name: `styles-list`
312
372
  - `synergy://templates/list` → name: `templates-list`
373
+ - `synergy://intent-categories/list` → name: `intent-categories-list` (experimental)
313
374
 
314
375
  ### 1. `synergy://components/list`
315
376
 
@@ -397,9 +458,33 @@ Resource identifier reference (exact values used by the server):
397
458
  ["app-shell", "dashboard", "form", ...]
398
459
  ```
399
460
 
461
+ ### 6. `synergy://intent-categories/list` (experimental)
462
+
463
+ **Name:** `intent-categories-list`
464
+
465
+ **MIME type:** `application/json`
466
+
467
+ **Description:** Available intent categories in the Synergy intent policy layer.
468
+
469
+ **Registration:** Only available when `experimentalFeatures.intentTools` is `true`.
470
+
471
+ **Example:**
472
+
473
+ ```json
474
+ {
475
+ "data": [
476
+ {
477
+ "description": "User actions and commands",
478
+ "id": "action",
479
+ "label": "Action"
480
+ }
481
+ ]
482
+ }
483
+ ```
484
+
400
485
  ## Available Tools
401
486
 
402
- The MCP server currently registers 16 tools.
487
+ The MCP server currently registers 16 stable tools by default.
403
488
 
404
489
  ### 1. `component-list`
405
490
 
@@ -450,13 +535,14 @@ Example prompts:
450
535
 
451
536
  - `component` (string, required): The component name. Must start with `syn-`, for example `syn-button`.
452
537
  - `framework` (string, optional): `react`, `vue`, `angular`, or `vanilla`. Defaults to the runtime config value, which is `vanilla` by default.
453
- - `layer` (string, optional): `full`, `examples`, or `interface`. Defaults to the runtime config value, which is `full` by default. `examples` and `interface` are currently only available for vanilla components.
538
+ - `layer` (string, optional): `full`, `examples`, `interface`, or `rules`. Defaults to the runtime config value, which is `full` by default. `examples` and `interface` are currently only available for vanilla components. `rules` returns component usage, design, and accessibility guidance.
454
539
 
455
540
  **Example prompts:**
456
541
 
457
542
  - "How do I use syn-button in React?"
458
543
  - "Show me the interface docs for syn-dialog"
459
544
  - "Give me examples for syn-card"
545
+ - "Show me the rules for syn-accordion"
460
546
 
461
547
  ### 4. `asset-list`
462
548
 
@@ -649,6 +735,110 @@ Example prompts:
649
735
  - "Show me the setup instructions for tokens"
650
736
  - "Give me the Synergy assets setup and limitations"
651
737
 
738
+ ### Experimental Tools (Intent Policy)
739
+
740
+ The following endpoints are experimental and are only registered when `experimentalFeatures.intentTools` is set to `true`.
741
+
742
+ ### 17. `intent-categories-list` (experimental)
743
+
744
+ **Description:** List available intent categories in the intent policy layer.
745
+
746
+ **Parameters:**
747
+
748
+ - `includePhases` (array, optional): Intent phases to include. Defaults to runtime config `tools.intentCategoriesList.includePhases` (`["experimental"]` by default).
749
+
750
+ **Example prompts:**
751
+
752
+ - "List intent categories"
753
+ - "Show experimental intent categories"
754
+
755
+ ### 18. `intent-component-guide` (experimental)
756
+
757
+ **Description:** Answer the question: What can I do with a component in the intent system?
758
+
759
+ **Parameters:**
760
+
761
+ - `component` (string, required): Component tag, for example `syn-button`.
762
+ - `framework` (string, optional): `react-wrapper`, `react-web-components`, `angular`, `vue`, or `vanilla`. Defaults to runtime config `tools.intentComponentGuide.framework`.
763
+ - `includePhases` (array, optional): Defaults to runtime config `tools.intentComponentGuide.includePhases`.
764
+
765
+ **Example prompts:**
766
+
767
+ - "What can I do with syn-button?"
768
+ - "Show intent guide for syn-button in react-web-components"
769
+
770
+ ### 19. `intent-component-validate` (experimental)
771
+
772
+ **Description:** Answer the question: Do I use a component correctly for a specific intent?
773
+
774
+ **Parameters:**
775
+
776
+ - `component` (string, required): Component tag, for example `syn-button`.
777
+ - `intent` (string, required): Intent id, for example `action.submit`.
778
+ - `markup` (string, required): Template/markup source to lint. The tool derives structure internally.
779
+ - `framework` (string, optional): Defaults to runtime config `tools.intentComponentValidate.framework`.
780
+ - `includePhases` (array, optional): Defaults to runtime config `tools.intentComponentValidate.includePhases`.
781
+
782
+ **Example prompts:**
783
+
784
+ - "Do I use syn-button right for action.submit?"
785
+ - "Validate this syn-button markup for action.submit: <syn-button type=\"submit\" variant=\"filled\">Send</syn-button>"
786
+
787
+ ### 20. `intent-task-recommendations` (experimental)
788
+
789
+ **Description:** Answer the question: What does Synergy provide for a specific task intent?
790
+
791
+ **Parameters:**
792
+
793
+ - `taskId` (string, required): Intent id representing the task.
794
+ - `framework` (string, optional): Defaults to runtime config `tools.intentTaskRecommendations.framework`.
795
+ - `includePhases` (array, optional): Defaults to runtime config `tools.intentTaskRecommendations.includePhases`.
796
+ - `maxAlternatives` (number, optional): Defaults to runtime config `tools.intentTaskRecommendations.maxAlternatives`.
797
+ - `preferredTargets` (array, optional): Preferred target ids.
798
+ - `avoidTargets` (array, optional): Target ids to avoid.
799
+ - `content` (string, optional): Optional snippet content.
800
+
801
+ **Example prompts:**
802
+
803
+ - "What does Synergy provide to submit a form?"
804
+ - "Recommend components for action.submit"
805
+
806
+ ### 21. `intent-options` (experimental)
807
+
808
+ **Description:** Answer the question: What are my renderable options for a specific intent?
809
+
810
+ **Parameters:**
811
+
812
+ - `intentId` (string, required): Intent id to resolve.
813
+ - `framework` (string, optional): Defaults to runtime config `tools.intentOptions.framework`.
814
+ - `includePhases` (array, optional): Defaults to runtime config `tools.intentOptions.includePhases`.
815
+ - `includeDiagnostics` (boolean, optional): Defaults to runtime config `tools.intentOptions.includeDiagnostics`.
816
+ - `maxAlternatives` (number, optional): Defaults to runtime config `tools.intentOptions.maxAlternatives`.
817
+ - `content` (string, optional): Optional preview content.
818
+
819
+ **Example prompts:**
820
+
821
+ - "What are my renderable options for navigation.link-list.grouped?"
822
+ - "Show intent options for action.submit"
823
+
824
+ ## Available Prompts
825
+
826
+ The MCP server currently registers 1 prompt.
827
+
828
+ ### 1. `explain-component-rules`
829
+
830
+ **Description:** Explains the usage rules, design guidelines, and accessibility considerations for a Synergy component.
831
+
832
+ **Parameters:**
833
+
834
+ - `component` (string, required): The component name. Must start with `syn-`, for example `syn-button`.
835
+
836
+ **Example prompts:**
837
+
838
+ - "Explain the rules for syn-button"
839
+ - "What are the design and accessibility guidelines for syn-dialog?"
840
+ - "Give me the usage guidance for syn-accordion"
841
+
652
842
  ## Usage Examples
653
843
 
654
844
  ### Command Line Interface
@@ -741,6 +931,7 @@ Once connected to an AI assistant, you can use prompts like:
741
931
 
742
932
  ```text
743
933
  Show me how to use syn-button in React
934
+ Explain the rules for syn-accordion
744
935
  Give me the interface docs for syn-select
745
936
  What token formats are available?
746
937
  How do I set up Synergy for Vue?
@@ -759,7 +950,7 @@ src/
759
950
  ├── bin/
760
951
  │ ├── clean.js # Removes dist/ before builds
761
952
  │ └── start.ts # CLI entry point for syn-mcp
762
- ├── server.ts # MCP server creation, tool and resource registration
953
+ ├── server.ts # MCP server creation, tool, prompt and resource registration
763
954
  ├── middleware/ # Tool execution middleware pipeline
764
955
  │ ├── compose.ts # composeMiddlewares (reduceRight composition)
765
956
  │ ├── compression.ts # withCompressionMiddleware (experimental)
@@ -767,10 +958,14 @@ src/
767
958
  │ ├── logging.ts # withToolLoggingMiddleware
768
959
  │ ├── types.ts # ToolMiddleware, ToolMiddlewareContext, RawToolHandler, WithErrorHandlerOptions
769
960
  │ └── index.ts # Middleware module entrypoint
961
+ ├── prompts/ # MCP prompt implementations
962
+ │ ├── component-rules.ts
963
+ │ └── index.ts
770
964
  ├── resources/ # MCP resource implementations (static, read-only data)
771
965
  │ ├── component-list.ts
772
966
  │ ├── asset-list.ts
773
967
  │ ├── component-cluster-list.ts
968
+ │ ├── intent-categories-list.ts
774
969
  │ ├── styles-list.ts
775
970
  │ ├── templates-list.ts
776
971
  │ └── index.ts
@@ -782,6 +977,11 @@ src/
782
977
  │ ├── component-list.ts
783
978
  │ ├── davinci-migration-info.ts
784
979
  │ ├── davinci-migration-list.ts
980
+ │ ├── intent-categories-list.ts
981
+ │ ├── intent-component-guide.ts
982
+ │ ├── intent-component-validate.ts
983
+ │ ├── intent-options.ts
984
+ │ ├── intent-task-recommendations.ts
785
985
  │ ├── migration-info.ts
786
986
  │ ├── migration-list.ts
787
987
  │ ├── setup.ts
@@ -793,20 +993,8 @@ src/
793
993
  │ ├── tokens-list.ts
794
994
  │ └── index.ts
795
995
  ├── transports/ # Transport factory and implementations
796
- │ ├── http.ts
797
- │ ├── stdio.ts
798
- │ └── index.ts
799
996
  ├── types/ # Shared type definitions
800
- └── tool-response.ts
801
- └── utilities/ # Runtime config, metadata adapters, and CLI helpers
802
- ├── cli.ts
803
- ├── config.ts
804
- ├── davinci.ts
805
- ├── metadata.ts
806
- ├── migration.ts
807
- ├── rules.ts
808
- ├── server.ts
809
- └── index.ts
997
+ └── utilities/ # Runtime config, metadata adapters, intent defaults, and CLI helpers
810
998
  rules/ # Markdown guidance files prepended to selected tool output
811
999
  test/
812
1000
  ├── e2e/ # End-to-end MCP tests
@@ -913,6 +1101,7 @@ The MCP server is intentionally small:
913
1101
  - `src/bin/start.ts` parses CLI arguments, loads optional runtime config, resolves overrides, and starts the selected transport.
914
1102
  - `src/transports/` contains the transport factory and runtime implementations for stdio and HTTP/HTTPS.
915
1103
  - `src/server.ts` creates the `McpServer` instance and registers all exported tools from `src/tools/index.ts` and all exported resources from `src/resources/index.ts`.
1104
+ - `src/server.ts` applies feature-flag gating generically: exports whose factory names start with `intent` are only registered when `experimentalFeatures.intentTools` is enabled.
916
1105
  - Tool implementations in `src/tools/` call the public APIs of `@synergy-design-system/metadata` to retrieve data.
917
1106
  - Resource implementations in `src/resources/` expose static, read-only data that does not change during server runtime. Resources bypass the tool middleware pipeline entirely — no compression, logging, or error wrapping is applied.
918
1107
  - Utilities in `src/utilities/` handle runtime config, MCP response shaping, DaVinci migration extraction, and package migration document loading.
@@ -7,3 +7,4 @@ export { composeMiddlewares } from './compose.js';
7
7
  export { withCompressionMiddleware } from './compression.js';
8
8
  export { withErrorHandlingMiddleware } from './error-handler.js';
9
9
  export { withToolLoggingMiddleware } from './logging.js';
10
+ export { withPromptLoggingMiddleware } from './logging.js';
@@ -6,3 +6,4 @@ export { composeMiddlewares } from './compose.js';
6
6
  export { withCompressionMiddleware } from './compression.js';
7
7
  export { withErrorHandlingMiddleware } from './error-handler.js';
8
8
  export { withToolLoggingMiddleware } from './logging.js';
9
+ export { withPromptLoggingMiddleware } from './logging.js';
@@ -1,8 +1,3 @@
1
- /**
2
- * Logging middleware for tool execution.
3
- * Records tool call duration, token count, success/error state, and parameters.
4
- * Respects logging config: early-exits if logging is disabled to avoid token counting overhead.
5
- */
6
1
  import type { ToolMiddleware } from './types.js';
7
2
  /**
8
3
  * Middleware that logs details about tool execution, including duration, success/failure, token count, and parameters.
@@ -12,3 +7,8 @@ import type { ToolMiddleware } from './types.js';
12
7
  * @returns A new handler function that wraps the original tool logic with logging functionality.
13
8
  */
14
9
  export declare const withToolLoggingMiddleware: ToolMiddleware<Record<string, unknown>>;
10
+ /**
11
+ * Middleware that logs prompt execution details.
12
+ * Token counting is based on the resolved prompt text payload.
13
+ */
14
+ export declare const withPromptLoggingMiddleware: ToolMiddleware<Record<string, unknown>>;
@@ -6,6 +6,31 @@
6
6
  import { logToolCall } from '../utilities/logger.js';
7
7
  import { countTextTokens, toTextPayload, } from '../utilities/token-counter.js';
8
8
  import { toContentArray } from '../utilities/metadata.js';
9
+ const isPromptResponse = (value) => {
10
+ if (!value || typeof value !== 'object') {
11
+ return false;
12
+ }
13
+ const maybePrompt = value;
14
+ return typeof maybePrompt.description === 'string' && Array.isArray(maybePrompt.messages);
15
+ };
16
+ const toPromptTextPayload = (result) => {
17
+ const lines = result.flatMap((entry) => {
18
+ if (typeof entry === 'string') {
19
+ return [entry];
20
+ }
21
+ if (isPromptResponse(entry)) {
22
+ return entry.messages
23
+ .map(message => {
24
+ if (message.content.type === 'text')
25
+ return message.content.text;
26
+ return '';
27
+ })
28
+ .filter(Boolean);
29
+ }
30
+ return [JSON.stringify(entry)];
31
+ });
32
+ return lines.join('\n\n');
33
+ };
9
34
  /**
10
35
  * Middleware that logs details about tool execution, including duration, success/failure, token count, and parameters.
11
36
  * It checks the logging configuration and skips logging (and token counting) if logging is disabled to optimize performance.
@@ -62,3 +87,50 @@ export const withToolLoggingMiddleware = (next, context) => async (args) => {
62
87
  });
63
88
  }
64
89
  };
90
+ /**
91
+ * Middleware that logs prompt execution details.
92
+ * Token counting is based on the resolved prompt text payload.
93
+ */
94
+ export const withPromptLoggingMiddleware = (next, context) => async (args) => {
95
+ if (context.config.logging.localFile.path === null) {
96
+ return next(args);
97
+ }
98
+ const startedAt = process.hrtime.bigint();
99
+ let success = false;
100
+ let errorMessage;
101
+ let tokenCount;
102
+ try {
103
+ const result = await next(args);
104
+ success = true;
105
+ const textPayload = toPromptTextPayload(result);
106
+ tokenCount = await countTextTokens(textPayload);
107
+ return result;
108
+ }
109
+ catch (error) {
110
+ errorMessage = error instanceof Error ? error.message : String(error);
111
+ throw error;
112
+ }
113
+ finally {
114
+ const durationMs = Number(process.hrtime.bigint() - startedAt) / 1_000_000;
115
+ const internalProps = new Set([
116
+ 'requestId',
117
+ 'signal',
118
+ 'requestInfo',
119
+ 'sessionId',
120
+ ]);
121
+ const loggableParameters = {};
122
+ Object.entries(args).forEach(([key, value]) => {
123
+ if (!internalProps.has(key)) {
124
+ loggableParameters[key] = value;
125
+ }
126
+ });
127
+ await logToolCall({
128
+ durationMs,
129
+ errorMessage,
130
+ parameters: loggableParameters,
131
+ success,
132
+ tokenCount,
133
+ toolName: `prompt:${context.toolName}`,
134
+ });
135
+ }
136
+ };
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare const explainComponentRules: (server: McpServer) => void;
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ import { getRulesForComponent, } from '@synergy-design-system/metadata';
3
+ import { promptHandler, } from '../utilities/index.js';
4
+ export const explainComponentRules = (server) => {
5
+ server.registerPrompt('explain-component-rules', {
6
+ argsSchema: {
7
+ component: z
8
+ .string()
9
+ .startsWith('syn-')
10
+ .describe('The name of the component to get rules for.'),
11
+ },
12
+ description: 'Explains the usage rules, design guidelines, and accessibility considerations for a Synergy component.',
13
+ title: 'Explain component rules',
14
+ }, promptHandler('explain-component-rules', async ({ component }) => {
15
+ const metadata = await getRulesForComponent(component);
16
+ const rulesEntries = metadata.data?.rules ?? [];
17
+ const warningsList = metadata.data?.warnings ?? [];
18
+ const rulesMarkdown = rulesEntries.map((entry) => entry.content).join('\n\n');
19
+ const warnings = warningsList.length > 0
20
+ ? `\n\nWarnings:\n${warningsList.map((warning) => `- ${warning}`).join('\n')}`
21
+ : '';
22
+ return [
23
+ `
24
+ You are an expert on the Synergy Design System.
25
+
26
+ Base the explanation strictly on the provided data as seen below.
27
+ Do not speculate or invent any rules.
28
+ Structure the information clearly for a human reader.`,
29
+ rulesMarkdown && rulesMarkdown.trim().length > 0
30
+ ? `${rulesMarkdown}${warnings}`
31
+ : `No rules markdown is available for ${component}.${warnings}`,
32
+ ];
33
+ }, {
34
+ description: ({ component }) => `Explain design system rules for ${component}`,
35
+ }));
36
+ };
@@ -0,0 +1 @@
1
+ export * from './component-rules.js';
@@ -0,0 +1 @@
1
+ export * from './component-rules.js';
@@ -1,5 +1,6 @@
1
1
  export * from './asset-list.js';
2
2
  export * from './component-cluster-list.js';
3
3
  export * from './component-list.js';
4
+ export * from './intent-categories-list.js';
4
5
  export * from './styles-list.js';
5
6
  export * from './templates-list.js';
@@ -1,5 +1,6 @@
1
1
  export * from './asset-list.js';
2
2
  export * from './component-cluster-list.js';
3
3
  export * from './component-list.js';
4
+ export * from './intent-categories-list.js';
4
5
  export * from './styles-list.js';
5
6
  export * from './templates-list.js';
@@ -0,0 +1,7 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ /**
3
+ * Registers a static MCP resource that lists all available intent categories in the Synergy Design System.
4
+ * Clients that support resources can read this directly without calling a tool.
5
+ * @param server - The MCP server instance to register the resource on.
6
+ */
7
+ export declare const intentCategoriesListResource: (server: McpServer) => void;
@@ -0,0 +1,25 @@
1
+ import { experimental_listIntentCategories as listIntentCategories, } from '@synergy-design-system/metadata';
2
+ const RESOURCE_URI = 'synergy://intent-categories/list';
3
+ /**
4
+ * Registers a static MCP resource that lists all available intent categories in the Synergy Design System.
5
+ * Clients that support resources can read this directly without calling a tool.
6
+ * @param server - The MCP server instance to register the resource on.
7
+ */
8
+ export const intentCategoriesListResource = (server) => {
9
+ server.registerResource('intent-categories-list', RESOURCE_URI, {
10
+ description: 'Available intent categories in the Synergy Design System.',
11
+ mimeType: 'application/json',
12
+ title: 'Available intent categories',
13
+ }, async (_uri) => {
14
+ const categories = await listIntentCategories();
15
+ return {
16
+ contents: [
17
+ {
18
+ mimeType: 'application/json',
19
+ text: JSON.stringify(categories, null, 2),
20
+ uri: RESOURCE_URI,
21
+ },
22
+ ],
23
+ };
24
+ });
25
+ };
package/dist/server.js CHANGED
@@ -1,24 +1,41 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import * as resources from './resources/index.js';
3
+ import * as prompts from './prompts/index.js';
3
4
  import * as tools from './tools/index.js';
4
5
  import { getVersion } from './utilities/cli.js';
6
+ import { getRuntimeConfig } from './utilities/config.js';
7
+ /**
8
+ * Determines if a tool, prompt, or resource should be registered based on feature flags.
9
+ * Items with names starting with 'intent' are gated by the intentTools experimental flag.
10
+ */
11
+ const shouldRegisterItem = (name, config) => {
12
+ // Make sure to only load intent-related items if the intentTools experimental feature is enabled
13
+ if (name.toLowerCase().startsWith('intent')) {
14
+ return config.experimentalFeatures?.intentTools === true;
15
+ }
16
+ return true;
17
+ };
5
18
  /**
6
19
  * Creates a new instance of the MCP server configured for the Synergy Design System.
7
20
  * @returns A new instance of the MCP server configured for the Synergy Design System.
8
21
  */
9
22
  export const createServer = () => {
10
23
  const version = getVersion();
24
+ const config = getRuntimeConfig();
11
25
  const server = new McpServer({
12
26
  description: 'A server for the Synergy Design System that provides tools to interact with components and resources.',
13
27
  name: 'synergy design system',
14
28
  title: 'Synergy Design System MCP Server',
15
29
  version,
16
30
  });
17
- Object.values(tools).forEach(tool => {
18
- tool(server);
19
- });
20
- Object.values(resources).forEach(resource => {
21
- resource(server);
22
- });
31
+ Object.entries(prompts)
32
+ .filter(([name]) => shouldRegisterItem(name, config))
33
+ .forEach(([, prompt]) => prompt(server));
34
+ Object.entries(tools)
35
+ .filter(([name]) => shouldRegisterItem(name, config))
36
+ .forEach(([, tool]) => tool(server));
37
+ Object.entries(resources)
38
+ .filter(([name]) => shouldRegisterItem(name, config))
39
+ .forEach(([, resource]) => resource(server));
23
40
  return server;
24
41
  };
@@ -12,9 +12,9 @@ export const componentInfoTool = (server) => {
12
12
  inputSchema: {
13
13
  component: z.string().startsWith('syn-').describe('The name of the component to get information about.'),
14
14
  framework: z.enum(['react', 'vue', 'angular', 'vanilla']).optional().describe('The framework of the component, e.g., "react", "vue", etc.'),
15
- layer: z.enum(['full', 'examples', 'interface'])
15
+ layer: z.enum(['full', 'examples', 'interface', 'rules'])
16
16
  .optional()
17
- .describe('Defines which type of information to return. full = filtered source files (useful for debugging), examples = markdown examples, interface = markdown API overview. Examples and interface are only available for vanilla components at the moment.'),
17
+ .describe('Defines which type of information to return. full = filtered source files (useful for debugging), examples = markdown examples, interface = markdown API overview, rules = Usage guidelines and rules for the component. Examples and interface are only available for vanilla components at the moment.'),
18
18
  },
19
19
  title: 'Component info',
20
20
  }, toolHandler('component-info', async ({ component, framework, layer, }) => {
@@ -39,6 +39,9 @@ export const componentInfoTool = (server) => {
39
39
  case 'examples':
40
40
  finalContent = metadata.data.examples?.map((entry) => entry.content) ?? [];
41
41
  break;
42
+ case 'rules':
43
+ finalContent = metadata.data.rules?.map((entry) => entry.content) ?? [];
44
+ break;
42
45
  default:
43
46
  finalContent = [metadata.data];
44
47
  }