@primer/mcp 0.3.0 → 0.3.1

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/src/server.ts CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  type TokenWithGuidelines,
19
19
  getValidGroupsList,
20
20
  groupHints,
21
+ runStylelint,
21
22
  } from './primitives'
22
23
  import packageJson from '../package.json' with {type: 'json'}
23
24
 
@@ -479,7 +480,7 @@ server.registerTool(
479
480
  'find_tokens',
480
481
  {
481
482
  description:
482
- "Search for specific tokens. Tip: If you only provide a 'group' and leave 'query' empty, it returns all tokens in that category. Avoid property-by-property searching.",
483
+ 'Search for specific tokens. Tip: If you only provide a \'group\' and leave \'query\' empty, it returns all tokens in that category. Avoid property-by-property searching. COLOR RESOLUTION: If a user asks for "pink" or "blue", do not search for the color name. Use the semantic intent: blue->accent, red->danger, green->success. Always check both "emphasis" and "muted" variants for background colors. After identifying tokens and writing CSS, you MUST validate the result using lint_css.',
483
484
  inputSchema: {
484
485
  query: z
485
486
  .string()
@@ -680,6 +681,42 @@ server.registerTool(
680
681
  },
681
682
  )
682
683
 
684
+ server.registerTool(
685
+ 'lint_css',
686
+ {
687
+ description:
688
+ 'REQUIRED FINAL STEP. Use this to validate your CSS. You cannot complete a task involving CSS without a successful run of this tool.',
689
+ inputSchema: {css: z.string()},
690
+ },
691
+ async ({css}) => {
692
+ try {
693
+ // --fix flag tells Stylelint to repair what it can
694
+ const {stdout} = await runStylelint(css)
695
+
696
+ return {
697
+ content: [
698
+ {
699
+ type: 'text',
700
+ text: stdout || '✅ Stylelint passed (or was successfully autofixed).',
701
+ },
702
+ ],
703
+ }
704
+ } catch (error: unknown) {
705
+ // If Stylelint still has errors it CANNOT fix, it will land here
706
+ const errorOutput =
707
+ error instanceof Error && 'stdout' in error ? (error as Error & {stdout: string}).stdout : String(error)
708
+ return {
709
+ content: [
710
+ {
711
+ type: 'text',
712
+ text: `❌ Errors without autofix remaining:\n${errorOutput}`,
713
+ },
714
+ ],
715
+ }
716
+ }
717
+ },
718
+ )
719
+
683
720
  // -----------------------------------------------------------------------------
684
721
  // Foundations
685
722
  // -----------------------------------------------------------------------------