@uidbai/mcp-server 0.1.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.
- package/LICENSE +21 -0
- package/README.md +133 -0
- package/dist/cli.d.ts +13 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +117 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/api-client.d.ts +45 -0
- package/dist/core/api-client.d.ts.map +1 -0
- package/dist/core/api-client.js +98 -0
- package/dist/core/api-client.js.map +1 -0
- package/dist/core/auth.d.ts +42 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/auth.js +198 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/errors.d.ts +32 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +72 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +10 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +124 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +52 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/component-guidance.d.ts +16 -0
- package/dist/prompts/component-guidance.d.ts.map +1 -0
- package/dist/prompts/component-guidance.js +98 -0
- package/dist/prompts/component-guidance.js.map +1 -0
- package/dist/prompts/index.d.ts +6 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +6 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/registry.d.ts +37 -0
- package/dist/prompts/registry.d.ts.map +1 -0
- package/dist/prompts/registry.js +40 -0
- package/dist/prompts/registry.js.map +1 -0
- package/dist/resources/index.d.ts +6 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +6 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/project-config.d.ts +33 -0
- package/dist/resources/project-config.d.ts.map +1 -0
- package/dist/resources/project-config.js +146 -0
- package/dist/resources/project-config.js.map +1 -0
- package/dist/resources/registry.d.ts +20 -0
- package/dist/resources/registry.d.ts.map +1 -0
- package/dist/resources/registry.js +45 -0
- package/dist/resources/registry.js.map +1 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +111 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/ask-intent.d.ts +35 -0
- package/dist/tools/ask-intent.d.ts.map +1 -0
- package/dist/tools/ask-intent.js +50 -0
- package/dist/tools/ask-intent.js.map +1 -0
- package/dist/tools/ask-question.d.ts +40 -0
- package/dist/tools/ask-question.d.ts.map +1 -0
- package/dist/tools/ask-question.js +58 -0
- package/dist/tools/ask-question.js.map +1 -0
- package/dist/tools/detect-pattern.d.ts +48 -0
- package/dist/tools/detect-pattern.d.ts.map +1 -0
- package/dist/tools/detect-pattern.js +64 -0
- package/dist/tools/detect-pattern.js.map +1 -0
- package/dist/tools/finalize.d.ts +35 -0
- package/dist/tools/finalize.d.ts.map +1 -0
- package/dist/tools/finalize.js +51 -0
- package/dist/tools/finalize.js.map +1 -0
- package/dist/tools/get-config.d.ts +28 -0
- package/dist/tools/get-config.d.ts.map +1 -0
- package/dist/tools/get-config.js +48 -0
- package/dist/tools/get-config.js.map +1 -0
- package/dist/tools/index.d.ts +18 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +19 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-components.d.ts +28 -0
- package/dist/tools/list-components.d.ts.map +1 -0
- package/dist/tools/list-components.js +44 -0
- package/dist/tools/list-components.js.map +1 -0
- package/dist/tools/list-patterns.d.ts +28 -0
- package/dist/tools/list-patterns.d.ts.map +1 -0
- package/dist/tools/list-patterns.js +44 -0
- package/dist/tools/list-patterns.js.map +1 -0
- package/dist/tools/login.d.ts +35 -0
- package/dist/tools/login.d.ts.map +1 -0
- package/dist/tools/login.js +100 -0
- package/dist/tools/login.js.map +1 -0
- package/dist/tools/registry.d.ts +50 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +75 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/status.d.ts +28 -0
- package/dist/tools/status.d.ts.map +1 -0
- package/dist/tools/status.js +88 -0
- package/dist/tools/status.js.map +1 -0
- package/dist/tools/submit-pattern.d.ts +67 -0
- package/dist/tools/submit-pattern.d.ts.map +1 -0
- package/dist/tools/submit-pattern.js +94 -0
- package/dist/tools/submit-pattern.js.map +1 -0
- package/dist/tools/update-config.d.ts +48 -0
- package/dist/tools/update-config.d.ts.map +1 -0
- package/dist/tools/update-config.js +94 -0
- package/dist/tools/update-config.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UIDB MCP Prompt: Component Guidance
|
|
3
|
+
*
|
|
4
|
+
* System prompt for guiding component selection.
|
|
5
|
+
*/
|
|
6
|
+
export const componentGuidancePrompt = {
|
|
7
|
+
name: "uidb_component_guidance",
|
|
8
|
+
description: "System prompt for UIDB component selection workflow",
|
|
9
|
+
getPrompt() {
|
|
10
|
+
return `# UIDB Design System Guidance
|
|
11
|
+
|
|
12
|
+
You are helping build UI components using the UIDB design system. Follow these guidelines:
|
|
13
|
+
|
|
14
|
+
## Component Selection Workflow
|
|
15
|
+
|
|
16
|
+
1. **Start with uidb_ask_intent** - Describe what UI you need
|
|
17
|
+
2. **Answer questions with uidb_ask_question** - Follow the guidance flow
|
|
18
|
+
3. **Get code with uidb_finalize** - Implement the recommended code exactly
|
|
19
|
+
|
|
20
|
+
## Key Principles
|
|
21
|
+
|
|
22
|
+
- **Always consult UIDB** before adding ANY UI component
|
|
23
|
+
- **Use semantic colors** (primary, success, error, warning) not hardcoded values
|
|
24
|
+
- **Follow the guidance** even if you think you know the answer
|
|
25
|
+
- **Check for patterns** after building compositions of 3+ components
|
|
26
|
+
|
|
27
|
+
## Semantic Colors
|
|
28
|
+
|
|
29
|
+
| Semantic | Use For | Example |
|
|
30
|
+
|----------|---------|---------|
|
|
31
|
+
| primary | CTAs, brand actions | Submit button, primary links |
|
|
32
|
+
| success | Positive outcomes | Success messages, completed states |
|
|
33
|
+
| error | Destructive actions | Delete buttons, error messages |
|
|
34
|
+
| warning | Attention needed | Warning alerts, caution states |
|
|
35
|
+
| neutral | Default states | Secondary buttons, inactive items |
|
|
36
|
+
|
|
37
|
+
## After Building UI
|
|
38
|
+
|
|
39
|
+
When you've built a UI composition with 3+ components:
|
|
40
|
+
1. Call uidb_detect_pattern to check if it's reusable
|
|
41
|
+
2. If detected, call uidb_submit_pattern to document it
|
|
42
|
+
|
|
43
|
+
This helps maintain consistency across the project.
|
|
44
|
+
|
|
45
|
+
## Available Tools
|
|
46
|
+
|
|
47
|
+
- uidb_ask_intent - Start component guidance
|
|
48
|
+
- uidb_ask_question - Continue guidance Q&A
|
|
49
|
+
- uidb_finalize - Get final component code
|
|
50
|
+
- uidb_list_components - See available components
|
|
51
|
+
- uidb_detect_pattern - Check for patterns
|
|
52
|
+
- uidb_submit_pattern - Document a pattern
|
|
53
|
+
- uidb_list_patterns - See existing patterns
|
|
54
|
+
- uidb_get_config - Get theme configuration
|
|
55
|
+
- uidb_update_config - Update theme settings
|
|
56
|
+
- uidb_status - Check connection status`;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
export const patternDetectionPrompt = {
|
|
60
|
+
name: "uidb_pattern_detection",
|
|
61
|
+
description: "System prompt for pattern detection workflow",
|
|
62
|
+
getPrompt() {
|
|
63
|
+
return `# UIDB Pattern Detection
|
|
64
|
+
|
|
65
|
+
After building a UI composition with 3+ components, check if it should be documented as a reusable pattern.
|
|
66
|
+
|
|
67
|
+
## When to Check for Patterns
|
|
68
|
+
|
|
69
|
+
- You've combined 3 or more components together
|
|
70
|
+
- The composition serves a specific purpose (e.g., user profile card, navigation header)
|
|
71
|
+
- You think this composition might be reused elsewhere
|
|
72
|
+
|
|
73
|
+
## How to Submit a Pattern
|
|
74
|
+
|
|
75
|
+
1. Call uidb_detect_pattern with:
|
|
76
|
+
- description: What you built
|
|
77
|
+
- components_used: List of component names
|
|
78
|
+
- context: Where it's used
|
|
79
|
+
|
|
80
|
+
2. If is_pattern is true, call uidb_submit_pattern with:
|
|
81
|
+
- name: A descriptive name
|
|
82
|
+
- description: What it does and when to use it
|
|
83
|
+
- components: The component names
|
|
84
|
+
- code_template: The JSX/TSX code
|
|
85
|
+
- category: One of (identity, navigation, data-display, feedback, layout, forms)
|
|
86
|
+
- use_cases: Where this pattern should be used
|
|
87
|
+
|
|
88
|
+
## Pattern Categories
|
|
89
|
+
|
|
90
|
+
- **identity**: User avatars, profile cards, team members
|
|
91
|
+
- **navigation**: Headers, sidebars, breadcrumbs, tabs
|
|
92
|
+
- **data-display**: Tables, lists, cards, stats
|
|
93
|
+
- **feedback**: Alerts, toasts, progress indicators
|
|
94
|
+
- **layout**: Page layouts, grids, containers
|
|
95
|
+
- **forms**: Form groups, input combinations, validation displays`;
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=component-guidance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-guidance.js","sourceRoot":"","sources":["../../src/prompts/component-guidance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE,qDAAqD;IAElE,SAAS;QACP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCA8C6B,CAAC;IACvC,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EAAE,8CAA8C;IAE3D,SAAS;QACP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kEAgCuD,CAAC;IACjE,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UIDB MCP Server - Prompt Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all MCP prompts.
|
|
5
|
+
*/
|
|
6
|
+
export interface MCPPrompt {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
getPrompt: (args?: Record<string, string>) => string;
|
|
10
|
+
arguments?: Array<{
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
export declare const prompts: MCPPrompt[];
|
|
17
|
+
/**
|
|
18
|
+
* Get a prompt by name
|
|
19
|
+
*/
|
|
20
|
+
export declare function getPrompt(name: string): MCPPrompt | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Get all prompt definitions for MCP ListPrompts response
|
|
23
|
+
*/
|
|
24
|
+
export declare function getPromptDefinitions(): {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
arguments: {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
required?: boolean;
|
|
31
|
+
}[];
|
|
32
|
+
}[];
|
|
33
|
+
/**
|
|
34
|
+
* Get prompt content by name
|
|
35
|
+
*/
|
|
36
|
+
export declare function getPromptContent(name: string, args?: Record<string, string>): string | null;
|
|
37
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/prompts/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC;IACrD,SAAS,CAAC,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC,CAAC;CACJ;AAMD,eAAO,MAAM,OAAO,EAAE,SAAS,EAG9B,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE7D;AAED;;GAEG;AACH,wBAAgB,oBAAoB;;;;cAzB1B,MAAM;qBACC,MAAM;mBACR,OAAO;;IA6BrB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,MAAM,GAAG,IAAI,CAQf"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UIDB MCP Server - Prompt Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all MCP prompts.
|
|
5
|
+
*/
|
|
6
|
+
import { componentGuidancePrompt, patternDetectionPrompt, } from "./component-guidance.js";
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Prompt Registry
|
|
9
|
+
// ============================================================================
|
|
10
|
+
export const prompts = [
|
|
11
|
+
componentGuidancePrompt,
|
|
12
|
+
patternDetectionPrompt,
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Get a prompt by name
|
|
16
|
+
*/
|
|
17
|
+
export function getPrompt(name) {
|
|
18
|
+
return prompts.find((prompt) => prompt.name === name);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get all prompt definitions for MCP ListPrompts response
|
|
22
|
+
*/
|
|
23
|
+
export function getPromptDefinitions() {
|
|
24
|
+
return prompts.map((prompt) => ({
|
|
25
|
+
name: prompt.name,
|
|
26
|
+
description: prompt.description,
|
|
27
|
+
arguments: prompt.arguments || [],
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get prompt content by name
|
|
32
|
+
*/
|
|
33
|
+
export function getPromptContent(name, args) {
|
|
34
|
+
const prompt = getPrompt(name);
|
|
35
|
+
if (!prompt) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return prompt.getPrompt(args);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/prompts/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AAiBjC,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,OAAO,GAAgB;IAClC,uBAAuB;IACvB,sBAAsB;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE;KAClC,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,IAA6B;IAE7B,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAE/B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UIDB MCP Resource: Project Config
|
|
3
|
+
*
|
|
4
|
+
* Exposes project configuration as an MCP resource.
|
|
5
|
+
*/
|
|
6
|
+
export interface MCPResource {
|
|
7
|
+
uri: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get project config resource
|
|
14
|
+
*/
|
|
15
|
+
export declare function getProjectConfigResource(): Promise<{
|
|
16
|
+
resource: MCPResource;
|
|
17
|
+
content: string;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Get project components resource
|
|
21
|
+
*/
|
|
22
|
+
export declare function getProjectComponentsResource(): Promise<{
|
|
23
|
+
resource: MCPResource;
|
|
24
|
+
content: string;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Get project patterns resource
|
|
28
|
+
*/
|
|
29
|
+
export declare function getProjectPatternsResource(): Promise<{
|
|
30
|
+
resource: MCPResource;
|
|
31
|
+
content: string;
|
|
32
|
+
}>;
|
|
33
|
+
//# sourceMappingURL=project-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../../src/resources/project-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC;IACxD,QAAQ,EAAE,WAAW,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAoDD;AAED;;GAEG;AACH,wBAAsB,4BAA4B,IAAI,OAAO,CAAC;IAC5D,QAAQ,EAAE,WAAW,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAsDD;AAED;;GAEG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC;IAC1D,QAAQ,EAAE,WAAW,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAsDD"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UIDB MCP Resource: Project Config
|
|
3
|
+
*
|
|
4
|
+
* Exposes project configuration as an MCP resource.
|
|
5
|
+
*/
|
|
6
|
+
import { apiClient } from "../core/api-client.js";
|
|
7
|
+
import { loadCredentials } from "../core/auth.js";
|
|
8
|
+
/**
|
|
9
|
+
* Get project config resource
|
|
10
|
+
*/
|
|
11
|
+
export async function getProjectConfigResource() {
|
|
12
|
+
const credentials = await loadCredentials();
|
|
13
|
+
if (!credentials) {
|
|
14
|
+
return {
|
|
15
|
+
resource: {
|
|
16
|
+
uri: "uidb://project/config",
|
|
17
|
+
name: "Project Config",
|
|
18
|
+
description: "UIDB design system configuration (not authenticated)",
|
|
19
|
+
mimeType: "application/json",
|
|
20
|
+
},
|
|
21
|
+
content: JSON.stringify({
|
|
22
|
+
error: "Not authenticated",
|
|
23
|
+
message: "Run 'npx @uidbai/mcp-server login' to connect",
|
|
24
|
+
}, null, 2),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const config = await apiClient.get("/api/config");
|
|
29
|
+
return {
|
|
30
|
+
resource: {
|
|
31
|
+
uri: `uidb://project/${credentials.projectSlug}/config`,
|
|
32
|
+
name: `${credentials.projectSlug} Config`,
|
|
33
|
+
description: `Design system configuration for ${credentials.projectSlug}`,
|
|
34
|
+
mimeType: "application/json",
|
|
35
|
+
},
|
|
36
|
+
content: JSON.stringify(config, null, 2),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return {
|
|
41
|
+
resource: {
|
|
42
|
+
uri: `uidb://project/${credentials.projectSlug}/config`,
|
|
43
|
+
name: `${credentials.projectSlug} Config`,
|
|
44
|
+
description: "Failed to load config",
|
|
45
|
+
mimeType: "application/json",
|
|
46
|
+
},
|
|
47
|
+
content: JSON.stringify({
|
|
48
|
+
error: "Failed to load config",
|
|
49
|
+
message: error instanceof Error ? error.message : "Unknown error",
|
|
50
|
+
}, null, 2),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get project components resource
|
|
56
|
+
*/
|
|
57
|
+
export async function getProjectComponentsResource() {
|
|
58
|
+
const credentials = await loadCredentials();
|
|
59
|
+
if (!credentials) {
|
|
60
|
+
return {
|
|
61
|
+
resource: {
|
|
62
|
+
uri: "uidb://project/components",
|
|
63
|
+
name: "Components",
|
|
64
|
+
description: "Available UI components (not authenticated)",
|
|
65
|
+
mimeType: "application/json",
|
|
66
|
+
},
|
|
67
|
+
content: JSON.stringify({
|
|
68
|
+
error: "Not authenticated",
|
|
69
|
+
message: "Run 'npx @uidbai/mcp-server login' to connect",
|
|
70
|
+
}, null, 2),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const response = await apiClient.get("/api/component/list");
|
|
75
|
+
return {
|
|
76
|
+
resource: {
|
|
77
|
+
uri: `uidb://project/${credentials.projectSlug}/components`,
|
|
78
|
+
name: `${credentials.projectSlug} Components`,
|
|
79
|
+
description: `Available UI components for ${credentials.projectSlug}`,
|
|
80
|
+
mimeType: "application/json",
|
|
81
|
+
},
|
|
82
|
+
content: JSON.stringify(response.components, null, 2),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
return {
|
|
87
|
+
resource: {
|
|
88
|
+
uri: `uidb://project/${credentials.projectSlug}/components`,
|
|
89
|
+
name: `${credentials.projectSlug} Components`,
|
|
90
|
+
description: "Failed to load components",
|
|
91
|
+
mimeType: "application/json",
|
|
92
|
+
},
|
|
93
|
+
content: JSON.stringify({
|
|
94
|
+
error: "Failed to load components",
|
|
95
|
+
message: error instanceof Error ? error.message : "Unknown error",
|
|
96
|
+
}, null, 2),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get project patterns resource
|
|
102
|
+
*/
|
|
103
|
+
export async function getProjectPatternsResource() {
|
|
104
|
+
const credentials = await loadCredentials();
|
|
105
|
+
if (!credentials) {
|
|
106
|
+
return {
|
|
107
|
+
resource: {
|
|
108
|
+
uri: "uidb://project/patterns",
|
|
109
|
+
name: "Patterns",
|
|
110
|
+
description: "Documented UI patterns (not authenticated)",
|
|
111
|
+
mimeType: "application/json",
|
|
112
|
+
},
|
|
113
|
+
content: JSON.stringify({
|
|
114
|
+
error: "Not authenticated",
|
|
115
|
+
message: "Run 'npx @uidbai/mcp-server login' to connect",
|
|
116
|
+
}, null, 2),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const response = await apiClient.get("/api/pattern/list");
|
|
121
|
+
return {
|
|
122
|
+
resource: {
|
|
123
|
+
uri: `uidb://project/${credentials.projectSlug}/patterns`,
|
|
124
|
+
name: `${credentials.projectSlug} Patterns`,
|
|
125
|
+
description: `Documented UI patterns for ${credentials.projectSlug}`,
|
|
126
|
+
mimeType: "application/json",
|
|
127
|
+
},
|
|
128
|
+
content: JSON.stringify(response.patterns, null, 2),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
return {
|
|
133
|
+
resource: {
|
|
134
|
+
uri: `uidb://project/${credentials.projectSlug}/patterns`,
|
|
135
|
+
name: `${credentials.projectSlug} Patterns`,
|
|
136
|
+
description: "Failed to load patterns",
|
|
137
|
+
mimeType: "application/json",
|
|
138
|
+
},
|
|
139
|
+
content: JSON.stringify({
|
|
140
|
+
error: "Failed to load patterns",
|
|
141
|
+
message: error instanceof Error ? error.message : "Unknown error",
|
|
142
|
+
}, null, 2),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=project-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config.js","sourceRoot":"","sources":["../../src/resources/project-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAUlD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAI5C,MAAM,WAAW,GAAG,MAAM,eAAe,EAAE,CAAC;IAE5C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO;YACL,QAAQ,EAAE;gBACR,GAAG,EAAE,uBAAuB;gBAC5B,IAAI,EAAE,gBAAgB;gBACtB,WAAW,EAAE,sDAAsD;gBACnE,QAAQ,EAAE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
|
|
|
1
|
+
/**
|
|
2
|
+
* UIDB MCP Server - Resource Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all MCP resources.
|
|
5
|
+
*/
|
|
6
|
+
import { MCPResource } from "./project-config.js";
|
|
7
|
+
export type ResourceType = "config" | "components" | "patterns";
|
|
8
|
+
/**
|
|
9
|
+
* List all available resources
|
|
10
|
+
*/
|
|
11
|
+
export declare function listResources(): Promise<MCPResource[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Read a resource by URI
|
|
14
|
+
*/
|
|
15
|
+
export declare function readResource(uri: string): Promise<{
|
|
16
|
+
resource: MCPResource;
|
|
17
|
+
content: string;
|
|
18
|
+
} | null>;
|
|
19
|
+
export { MCPResource };
|
|
20
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/resources/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAM7B,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAQhE;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAQ5D;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvD,QAAQ,EAAE,WAAW,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,IAAI,CAAC,CA0BR;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UIDB MCP Server - Resource Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all MCP resources.
|
|
5
|
+
*/
|
|
6
|
+
import { getProjectConfigResource, getProjectComponentsResource, getProjectPatternsResource, } from "./project-config.js";
|
|
7
|
+
const resourceFetchers = {
|
|
8
|
+
config: getProjectConfigResource,
|
|
9
|
+
components: getProjectComponentsResource,
|
|
10
|
+
patterns: getProjectPatternsResource,
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* List all available resources
|
|
14
|
+
*/
|
|
15
|
+
export async function listResources() {
|
|
16
|
+
const resources = await Promise.all([
|
|
17
|
+
getProjectConfigResource(),
|
|
18
|
+
getProjectComponentsResource(),
|
|
19
|
+
getProjectPatternsResource(),
|
|
20
|
+
]);
|
|
21
|
+
return resources.map((r) => r.resource);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Read a resource by URI
|
|
25
|
+
*/
|
|
26
|
+
export async function readResource(uri) {
|
|
27
|
+
// Parse URI: uidb://project/{slug}/{type}
|
|
28
|
+
const match = uri.match(/^uidb:\/\/project\/([^/]+)\/?(config|components|patterns)?$/);
|
|
29
|
+
if (!match) {
|
|
30
|
+
// Try simple URIs like uidb://project/config
|
|
31
|
+
const simpleMatch = uri.match(/^uidb:\/\/project\/(config|components|patterns)$/);
|
|
32
|
+
if (simpleMatch) {
|
|
33
|
+
const type = simpleMatch[1];
|
|
34
|
+
return resourceFetchers[type]();
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const type = (match[2] || "config");
|
|
39
|
+
const fetcher = resourceFetchers[type];
|
|
40
|
+
if (!fetcher) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return fetcher();
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/resources/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,0BAA0B,GAE3B,MAAM,qBAAqB,CAAC;AAQ7B,MAAM,gBAAgB,GAAG;IACvB,MAAM,EAAE,wBAAwB;IAChC,UAAU,EAAE,4BAA4B;IACxC,QAAQ,EAAE,0BAA0B;CACrC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAClC,wBAAwB,EAAE;QAC1B,4BAA4B,EAAE;QAC9B,0BAA0B,EAAE;KAC7B,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAI5C,0CAA0C;IAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CACrB,6DAA6D,CAC9D,CAAC;IAEF,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,6CAA6C;QAC7C,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAC3B,kDAAkD,CACnD,CAAC;QACF,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAiB,CAAC;YAC5C,OAAO,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAiB,CAAC;IACpD,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEvC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,OAAO,EAAE,CAAC;AACnB,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UIDB MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Main MCP server implementation using the official MCP SDK.
|
|
5
|
+
*/
|
|
6
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
7
|
+
export declare function createServer(): Server;
|
|
8
|
+
export declare function runServer(): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AA0BnE,wBAAgB,YAAY,IAAI,MAAM,CA0FrC;AAMD,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAgB/C"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UIDB MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Main MCP server implementation using the official MCP SDK.
|
|
5
|
+
*/
|
|
6
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
7
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
+
import { getToolDefinitions, executeTool } from "./tools/index.js";
|
|
10
|
+
import { listResources, readResource } from "./resources/index.js";
|
|
11
|
+
import { getPromptDefinitions, getPromptContent } from "./prompts/index.js";
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Server Configuration
|
|
14
|
+
// ============================================================================
|
|
15
|
+
const SERVER_NAME = "uidb-mcp-server";
|
|
16
|
+
const SERVER_VERSION = "0.1.0";
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Create and Configure Server
|
|
19
|
+
// ============================================================================
|
|
20
|
+
export function createServer() {
|
|
21
|
+
const server = new Server({
|
|
22
|
+
name: SERVER_NAME,
|
|
23
|
+
version: SERVER_VERSION,
|
|
24
|
+
}, {
|
|
25
|
+
capabilities: {
|
|
26
|
+
tools: {},
|
|
27
|
+
resources: {},
|
|
28
|
+
prompts: {},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Tools Handler
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
35
|
+
return {
|
|
36
|
+
tools: getToolDefinitions(),
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
40
|
+
const { name, arguments: args } = request.params;
|
|
41
|
+
return executeTool(name, args || {});
|
|
42
|
+
});
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Resources Handler
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
47
|
+
const resources = await listResources();
|
|
48
|
+
return { resources };
|
|
49
|
+
});
|
|
50
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
51
|
+
const { uri } = request.params;
|
|
52
|
+
const result = await readResource(uri);
|
|
53
|
+
if (!result) {
|
|
54
|
+
throw new Error(`Resource not found: ${uri}`);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
contents: [
|
|
58
|
+
{
|
|
59
|
+
uri: result.resource.uri,
|
|
60
|
+
mimeType: result.resource.mimeType,
|
|
61
|
+
text: result.content,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
// Prompts Handler
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
|
70
|
+
return {
|
|
71
|
+
prompts: getPromptDefinitions(),
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
75
|
+
const { name, arguments: args } = request.params;
|
|
76
|
+
const content = getPromptContent(name, args);
|
|
77
|
+
if (!content) {
|
|
78
|
+
throw new Error(`Prompt not found: ${name}`);
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
messages: [
|
|
82
|
+
{
|
|
83
|
+
role: "user",
|
|
84
|
+
content: {
|
|
85
|
+
type: "text",
|
|
86
|
+
text: content,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
return server;
|
|
93
|
+
}
|
|
94
|
+
// ============================================================================
|
|
95
|
+
// Run Server
|
|
96
|
+
// ============================================================================
|
|
97
|
+
export async function runServer() {
|
|
98
|
+
const server = createServer();
|
|
99
|
+
const transport = new StdioServerTransport();
|
|
100
|
+
await server.connect(transport);
|
|
101
|
+
// Handle graceful shutdown
|
|
102
|
+
process.on("SIGINT", async () => {
|
|
103
|
+
await server.close();
|
|
104
|
+
process.exit(0);
|
|
105
|
+
});
|
|
106
|
+
process.on("SIGTERM", async () => {
|
|
107
|
+
await server.close();
|
|
108
|
+
process.exit(0);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE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