@uidbai/mcp-server 0.2.0 → 0.3.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 (63) hide show
  1. package/README.md +164 -62
  2. package/dist/cli.js +0 -0
  3. package/dist/core/local-fs.d.ts +174 -0
  4. package/dist/core/local-fs.d.ts.map +1 -0
  5. package/dist/core/local-fs.js +263 -0
  6. package/dist/core/local-fs.js.map +1 -0
  7. package/dist/templates/index.d.ts +22 -0
  8. package/dist/templates/index.d.ts.map +1 -0
  9. package/dist/templates/index.js +19 -0
  10. package/dist/templates/index.js.map +1 -0
  11. package/dist/templates/minimal.d.ts +9 -0
  12. package/dist/templates/minimal.d.ts.map +1 -0
  13. package/dist/templates/minimal.js +115 -0
  14. package/dist/templates/minimal.js.map +1 -0
  15. package/dist/templates/standard.d.ts +9 -0
  16. package/dist/templates/standard.d.ts.map +1 -0
  17. package/dist/templates/standard.js +527 -0
  18. package/dist/templates/standard.js.map +1 -0
  19. package/dist/tools/detect-pattern.d.ts +8 -5
  20. package/dist/tools/detect-pattern.d.ts.map +1 -1
  21. package/dist/tools/detect-pattern.js +151 -18
  22. package/dist/tools/detect-pattern.js.map +1 -1
  23. package/dist/tools/get-config.d.ts +1 -1
  24. package/dist/tools/get-config.d.ts.map +1 -1
  25. package/dist/tools/get-config.js +45 -10
  26. package/dist/tools/get-config.js.map +1 -1
  27. package/dist/tools/guide.d.ts +65 -0
  28. package/dist/tools/guide.d.ts.map +1 -0
  29. package/dist/tools/guide.js +304 -0
  30. package/dist/tools/guide.js.map +1 -0
  31. package/dist/tools/index.d.ts +4 -5
  32. package/dist/tools/index.d.ts.map +1 -1
  33. package/dist/tools/index.js +4 -5
  34. package/dist/tools/index.js.map +1 -1
  35. package/dist/tools/init.d.ts +73 -0
  36. package/dist/tools/init.d.ts.map +1 -0
  37. package/dist/tools/init.js +149 -0
  38. package/dist/tools/init.js.map +1 -0
  39. package/dist/tools/list-components.d.ts +18 -3
  40. package/dist/tools/list-components.d.ts.map +1 -1
  41. package/dist/tools/list-components.js +86 -11
  42. package/dist/tools/list-components.js.map +1 -1
  43. package/dist/tools/list-patterns.d.ts +18 -3
  44. package/dist/tools/list-patterns.d.ts.map +1 -1
  45. package/dist/tools/list-patterns.js +85 -10
  46. package/dist/tools/list-patterns.js.map +1 -1
  47. package/dist/tools/registry.d.ts +1 -1
  48. package/dist/tools/registry.d.ts.map +1 -1
  49. package/dist/tools/registry.js +14 -15
  50. package/dist/tools/registry.js.map +1 -1
  51. package/dist/tools/status.d.ts +1 -1
  52. package/dist/tools/status.d.ts.map +1 -1
  53. package/dist/tools/status.js +54 -42
  54. package/dist/tools/status.js.map +1 -1
  55. package/dist/tools/submit-pattern.d.ts +13 -11
  56. package/dist/tools/submit-pattern.d.ts.map +1 -1
  57. package/dist/tools/submit-pattern.js +90 -19
  58. package/dist/tools/submit-pattern.js.map +1 -1
  59. package/dist/tools/update-config.d.ts +16 -8
  60. package/dist/tools/update-config.d.ts.map +1 -1
  61. package/dist/tools/update-config.js +93 -39
  62. package/dist/tools/update-config.js.map +1 -1
  63. package/package.json +1 -1
@@ -2,17 +2,18 @@
2
2
  * UIDB MCP Tool: uidb_detect_pattern
3
3
  *
4
4
  * Check if a UI composition is a reusable pattern.
5
+ * Uses LLM via UIDB API for intelligent detection, falls back to local heuristics.
5
6
  */
6
7
  import { apiClient } from "../core/api-client.js";
7
- import { formatErrorResponse } from "../core/errors.js";
8
+ import { readPatternsIndex, UIDBNotFoundError, } from "../core/local-fs.js";
8
9
  export const detectPatternTool = {
9
10
  name: "uidb_detect_pattern",
10
11
  description: `Check if a UI composition (3+ components) is a reusable pattern.
11
12
 
12
- Use this after building a multi-component UI to see if it should be documented as a pattern.
13
- If a pattern is detected, use uidb_submit_pattern to add it to the design system.
13
+ Use this after building a multi-component UI to see if it should be documented.
14
+ If is_pattern is true, use uidb_submit_pattern to add it to the design system.
14
15
 
15
- Example: After building a user profile card with Avatar, Text, and Flex components.`,
16
+ Example: After building a user profile card with Avatar, Text, and Badge components.`,
16
17
  inputSchema: {
17
18
  type: "object",
18
19
  properties: {
@@ -34,26 +35,77 @@ Example: After building a user profile card with Avatar, Text, and Flex componen
34
35
  },
35
36
  async execute(args) {
36
37
  try {
37
- const response = await apiClient.post("/api/pattern/detect", {
38
- description: args.description,
39
- components_used: args.components_used,
40
- ...(args.context && { context: args.context }),
41
- });
42
- return {
43
- content: [
44
- {
45
- type: "text",
46
- text: JSON.stringify(response, null, 2),
47
- },
48
- ],
49
- };
38
+ // First, check against existing patterns locally
39
+ const existingPatterns = await checkExistingPatterns(args);
40
+ if (existingPatterns.exists) {
41
+ return {
42
+ content: [
43
+ {
44
+ type: "text",
45
+ text: JSON.stringify({
46
+ is_pattern: false,
47
+ reason: "Similar pattern already exists",
48
+ existing_pattern: existingPatterns.pattern,
49
+ suggestion: "Consider using the existing pattern instead",
50
+ }, null, 2),
51
+ },
52
+ ],
53
+ };
54
+ }
55
+ // Try LLM detection via API
56
+ try {
57
+ const response = await apiClient.post("/api/pattern/detect", {
58
+ description: args.description,
59
+ components_used: args.components_used,
60
+ ...(args.context && { context: args.context }),
61
+ });
62
+ return {
63
+ content: [
64
+ {
65
+ type: "text",
66
+ text: JSON.stringify(response, null, 2),
67
+ },
68
+ ],
69
+ };
70
+ }
71
+ catch {
72
+ // Fall back to local heuristics
73
+ const localResult = detectPatternLocally(args);
74
+ return {
75
+ content: [
76
+ {
77
+ type: "text",
78
+ text: JSON.stringify(localResult, null, 2),
79
+ },
80
+ ],
81
+ };
82
+ }
50
83
  }
51
84
  catch (error) {
85
+ if (error instanceof UIDBNotFoundError) {
86
+ return {
87
+ content: [
88
+ {
89
+ type: "text",
90
+ text: JSON.stringify({
91
+ error: "NOT_INITIALIZED",
92
+ message: "No .uidb folder found. Run uidb_init first.",
93
+ }, null, 2),
94
+ },
95
+ ],
96
+ isError: true,
97
+ };
98
+ }
52
99
  return {
53
100
  content: [
54
101
  {
55
102
  type: "text",
56
- text: formatErrorResponse(error),
103
+ text: JSON.stringify({
104
+ error: "DETECT_FAILED",
105
+ message: error instanceof Error
106
+ ? error.message
107
+ : "Failed to detect pattern",
108
+ }, null, 2),
57
109
  },
58
110
  ],
59
111
  isError: true,
@@ -61,4 +113,85 @@ Example: After building a user profile card with Avatar, Text, and Flex componen
61
113
  }
62
114
  },
63
115
  };
116
+ /**
117
+ * Check if a similar pattern already exists locally
118
+ */
119
+ async function checkExistingPatterns(args) {
120
+ try {
121
+ const index = await readPatternsIndex();
122
+ const descLower = args.description.toLowerCase();
123
+ for (const pattern of index.patterns) {
124
+ // Check if description matches
125
+ const patternWords = pattern.description.toLowerCase().split(" ");
126
+ let matchCount = 0;
127
+ for (const word of patternWords) {
128
+ if (word.length > 3 && descLower.includes(word))
129
+ matchCount++;
130
+ }
131
+ // If more than 50% of words match, consider it a duplicate
132
+ if (matchCount > patternWords.length * 0.5) {
133
+ return { exists: true, pattern: pattern.name };
134
+ }
135
+ }
136
+ return { exists: false };
137
+ }
138
+ catch {
139
+ return { exists: false };
140
+ }
141
+ }
142
+ /**
143
+ * Local heuristic-based pattern detection
144
+ */
145
+ function detectPatternLocally(args) {
146
+ const componentCount = args.components_used.length;
147
+ // Not a pattern if fewer than 3 components
148
+ if (componentCount < 3) {
149
+ return {
150
+ is_pattern: false,
151
+ confidence: "high",
152
+ reason: "Fewer than 3 components - too simple to be a reusable pattern",
153
+ };
154
+ }
155
+ // Likely a pattern if 3+ components with semantic meaning
156
+ const hasInteractiveComponent = args.components_used.some((c) => ["Button", "IconButton", "Link", "Switch", "Checkbox"].includes(c));
157
+ const hasLayoutComponent = args.components_used.some((c) => ["Card", "Flex", "Box", "Grid"].includes(c));
158
+ const hasDataComponent = args.components_used.some((c) => ["Avatar", "Badge", "Text", "Heading"].includes(c));
159
+ const diversityScore = (hasInteractiveComponent ? 1 : 0) +
160
+ (hasLayoutComponent ? 1 : 0) +
161
+ (hasDataComponent ? 1 : 0);
162
+ if (diversityScore >= 2 && componentCount >= 3) {
163
+ // Suggest a category based on components
164
+ let suggestedCategory = "layout";
165
+ if (args.components_used.includes("Avatar"))
166
+ suggestedCategory = "identity";
167
+ if (args.components_used.includes("TextField") ||
168
+ args.components_used.includes("Select"))
169
+ suggestedCategory = "forms";
170
+ if (args.components_used.includes("Callout"))
171
+ suggestedCategory = "feedback";
172
+ if (args.components_used.includes("Tabs") ||
173
+ args.components_used.includes("DropdownMenu"))
174
+ suggestedCategory = "navigation";
175
+ // Generate suggested name from description
176
+ const words = args.description
177
+ .split(" ")
178
+ .filter((w) => w.length > 2)
179
+ .slice(0, 3);
180
+ const suggestedName = words
181
+ .map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
182
+ .join("");
183
+ return {
184
+ is_pattern: true,
185
+ confidence: componentCount >= 5 ? "high" : "medium",
186
+ suggested_name: suggestedName || "CustomPattern",
187
+ suggested_category: suggestedCategory,
188
+ reason: `${componentCount} components with diverse functionality - good candidate for reuse`,
189
+ };
190
+ }
191
+ return {
192
+ is_pattern: false,
193
+ confidence: "medium",
194
+ reason: "Components don't form a semantically meaningful reusable unit",
195
+ };
196
+ }
64
197
  //# sourceMappingURL=detect-pattern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"detect-pattern.js","sourceRoot":"","sources":["../../src/tools/detect-pattern.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE;;;;;oFAKqE;IAElF,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,kFAAkF;aACrF;YACD,eAAe,EAAE;gBACf,IAAI,EAAE,OAAO;gBACb,KAAK,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EnC,2CAA2C;QAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW;aAC3B,KAAK,CAAC,GAAG,CAAC;aACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;aAC3B,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACf,MAAM,aAAa,GAAG,KAAK;aACxB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;aAChE,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,OAAO;YACL,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,cAAc,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;YACnD,cAAc,EAAE,aAAa,IAAI,eAAe;YAChD,kBAAkB,EAAE,iBAAiB;YACrC,MAAM,EAAE,GAAG,cAAc,mEAAmE;SAC7F,CAAC;IACJ,CAAC;IAED,OAAO;QACL,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,QAAQ;QACpB,MAAM,EAAE,+DAA+D;KACxE,CAAC;AACJ,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * UIDB MCP Tool: uidb_get_config
3
3
  *
4
- * Get the project's design system configuration.
4
+ * Get the project's design system configuration from the local .uidb folder.
5
5
  */
6
6
  export declare const getConfigTool: {
7
7
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"get-config.d.ts","sourceRoot":"","sources":["../../src/tools/get-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;CAyCzB,CAAC"}
1
+ {"version":3,"file":"get-config.d.ts","sourceRoot":"","sources":["../../src/tools/get-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;CA2FzB,CAAC"}
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * UIDB MCP Tool: uidb_get_config
3
3
  *
4
- * Get the project's design system configuration.
4
+ * Get the project's design system configuration from the local .uidb folder.
5
5
  */
6
- import { apiClient } from "../core/api-client.js";
7
- import { formatErrorResponse } from "../core/errors.js";
6
+ import { readConfig, readManifest, UIDBNotFoundError } from "../core/local-fs.js";
8
7
  export const getConfigTool = {
9
8
  name: "uidb_get_config",
10
- description: `Get the current design system configuration for this project.
9
+ description: `Get the current design system configuration from .uidb/config.json.
11
10
 
12
11
  Returns:
13
- - accentColor: Primary brand color (e.g., 'blue', 'violet', 'green')
14
- - grayColor: Neutral color palette (e.g., 'slate', 'gray', 'mauve')
15
- - radius: Border radius scale (none, small, medium, large, full)
12
+ - theme.accentColor: Primary brand color (e.g., 'blue', 'violet', 'green')
13
+ - theme.grayColor: Neutral color palette (e.g., 'slate', 'gray', 'mauve')
14
+ - theme.radius: Border radius scale (none, small, medium, large, full)
15
+ - appearance: Color scheme (light, dark)
16
16
 
17
17
  Use these values when building UI to ensure consistency with the project theme.`,
18
18
  inputSchema: {
@@ -22,22 +22,57 @@ Use these values when building UI to ensure consistency with the project theme.`
22
22
  },
23
23
  async execute() {
24
24
  try {
25
- const response = await apiClient.get("/api/config");
25
+ const [config, manifest] = await Promise.all([
26
+ readConfig(),
27
+ readManifest().catch(() => null),
28
+ ]);
26
29
  return {
27
30
  content: [
28
31
  {
29
32
  type: "text",
30
- text: JSON.stringify(response, null, 2),
33
+ text: JSON.stringify({
34
+ project: manifest?.name || "Unknown",
35
+ config: {
36
+ accentColor: config.theme.accentColor,
37
+ grayColor: config.theme.grayColor,
38
+ radius: config.theme.radius,
39
+ appearance: config.appearance || "light",
40
+ scaling: config.scaling || "100%",
41
+ },
42
+ usage: {
43
+ radix_theme: `<Theme accentColor="${config.theme.accentColor}" grayColor="${config.theme.grayColor}" radius="${config.theme.radius}">`,
44
+ import: "import config from '../.uidb/config.json';",
45
+ },
46
+ }, null, 2),
31
47
  },
32
48
  ],
33
49
  };
34
50
  }
35
51
  catch (error) {
52
+ if (error instanceof UIDBNotFoundError) {
53
+ return {
54
+ content: [
55
+ {
56
+ type: "text",
57
+ text: JSON.stringify({
58
+ error: "NOT_INITIALIZED",
59
+ message: "No .uidb folder found. Run uidb_init first.",
60
+ }, null, 2),
61
+ },
62
+ ],
63
+ isError: true,
64
+ };
65
+ }
36
66
  return {
37
67
  content: [
38
68
  {
39
69
  type: "text",
40
- text: formatErrorResponse(error),
70
+ text: JSON.stringify({
71
+ error: "READ_FAILED",
72
+ message: error instanceof Error
73
+ ? error.message
74
+ : "Failed to read config",
75
+ }, null, 2),
41
76
  },
42
77
  ],
43
78
  isError: true,
@@ -1 +1 @@
1
- {"version":3,"file":"get-config.js","sourceRoot":"","sources":["../../src/tools/get-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE;;;;;;;gFAOiE;IAE9E,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;KACb;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,CAAgB,aAAa,CAAC,CAAC;YAEnE,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;qBACxC;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;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AAM,CAAC,KAAK,CAAC,WAAW,gBAAgB,MAAM,CAAC,KAAK,CAAC,SAAS,aAAa,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI;gCACtI,MAAM,EAAE,4CAA4C;6BACrD;yBACF,EACD,IAAI,EACJ,CAAC,CACF;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,iBAAiB,EAAE,CAAC;gBACvC,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAe;4BACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;gCACE,KAAK,EAAE,iBAAiB;gCACxB,OAAO,EAAE,6CAA6C;6BACvD,EACD,IAAI,EACJ,CAAC,CACF;yBACF;qBACF;oBACD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;4BACE,KAAK,EAAE,aAAa;4BACpB,OAAO,EACL,KAAK,YAAY,KAAK;gCACpB,CAAC,CAAC,KAAK,CAAC,OAAO;gCACf,CAAC,CAAC,uBAAuB;yBAC9B,EACD,IAAI,EACJ,CAAC,CACF;qBACF;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * UIDB MCP Tool: uidb_guide
3
+ *
4
+ * Unified component guidance tool. Replaces the multi-step ask_intent/ask_question/finalize flow.
5
+ * Reads local .uidb/ files and optionally calls UIDB API for LLM-powered recommendations.
6
+ */
7
+ interface GuideInput {
8
+ description: string;
9
+ context?: {
10
+ file?: string;
11
+ existing_components?: string[];
12
+ };
13
+ use_llm?: boolean;
14
+ }
15
+ export declare const guideTool: {
16
+ name: string;
17
+ description: string;
18
+ inputSchema: {
19
+ type: "object";
20
+ properties: {
21
+ description: {
22
+ type: string;
23
+ description: string;
24
+ };
25
+ context: {
26
+ type: string;
27
+ properties: {
28
+ file: {
29
+ type: string;
30
+ description: string;
31
+ };
32
+ existing_components: {
33
+ type: string;
34
+ items: {
35
+ type: string;
36
+ };
37
+ description: string;
38
+ };
39
+ };
40
+ description: string;
41
+ };
42
+ use_llm: {
43
+ type: string;
44
+ description: string;
45
+ default: boolean;
46
+ };
47
+ };
48
+ required: string[];
49
+ };
50
+ execute(args: GuideInput): Promise<{
51
+ content: {
52
+ type: "text";
53
+ text: string;
54
+ }[];
55
+ isError?: undefined;
56
+ } | {
57
+ content: {
58
+ type: "text";
59
+ text: string;
60
+ }[];
61
+ isError: boolean;
62
+ }>;
63
+ };
64
+ export {};
65
+ //# sourceMappingURL=guide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guide.d.ts","sourceRoot":"","sources":["../../src/tools/guide.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;KAChC,CAAC;IACF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAyBD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA8CA,UAAU;;;;;;;;;;;;;CA2E/B,CAAC"}