@primeuicom/mcp 0.1.5 → 0.1.7
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/README.md +170 -18
- package/dist/instructions.d.ts +173 -0
- package/dist/instructions.js +252 -0
- package/dist/instructions.js.map +1 -0
- package/dist/lib/fs.js +3 -5
- package/dist/lib/fs.js.map +1 -1
- package/dist/server.js +8 -101
- package/dist/server.js.map +1 -1
- package/dist/services/project-sync-service.js +2 -0
- package/dist/services/project-sync-service.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,22 +1,94 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @primeuicom/mcp
|
|
2
2
|
|
|
3
|
-
PrimeUI MCP
|
|
3
|
+
PrimeUI MCP connects AI agents to PrimeUI so they can discover project pages, create exports, download export artifacts, and automate PrimeUI-powered workflows directly from your coding environment.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Purpose and goals
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
PrimeUI MCP is the integration layer between PrimeUI and MCP-compatible agents.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- `PRIMEUI_API_KEY`
|
|
9
|
+
Core goals:
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
- Give agents a reliable way to read PrimeUI project metadata and page inventory.
|
|
12
|
+
- Let agents trigger and monitor PrimeUI exports.
|
|
13
|
+
- Let agents download export bundles into a local workspace for code-level operations.
|
|
14
|
+
- Provide a stable MCP tool contract for PrimeUI workflows.
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
## Requirements
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
- An MCP client that supports `stdio` servers.
|
|
19
|
+
- A working Node.js runtime (the server is launched via `npx`).
|
|
20
|
+
- A valid PrimeUI API key (`PRIMEUI_API_KEY`).
|
|
21
|
+
|
|
22
|
+
## PrimeUI API KEY
|
|
23
|
+
|
|
24
|
+
- PrimeUI provides this key together with the exported project.
|
|
25
|
+
- In practice, it is preconfigured in the exported project's `.mcp.json` for the `primeui` server entry.
|
|
26
|
+
|
|
27
|
+
## Getting started
|
|
28
|
+
|
|
29
|
+
The setup below works in any MCP client that supports `.mcp.json` with `stdio` command servers (for example: Codex CLI, Cursor, Cline, and other compatible clients).
|
|
30
|
+
|
|
31
|
+
Create or update `.mcp.json`:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"mcpServers": {
|
|
36
|
+
"primeui": {
|
|
37
|
+
"type": "stdio",
|
|
38
|
+
"command": "npx",
|
|
39
|
+
"args": ["-y", "@primeuicom/mcp@latest"],
|
|
40
|
+
"env": {
|
|
41
|
+
"PRIMEUI_API_KEY": "your-primeui-api-key"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Optional environment variables:
|
|
49
|
+
|
|
50
|
+
- `PRIMEUI_API_BASE_URL`: custom PrimeUI app base URL (default: `https://app.primeui.com/`).
|
|
51
|
+
- `PRIMEUI_PROJECT_ROOT`: absolute path to the target local project root. If omitted, current working directory is used.
|
|
52
|
+
|
|
53
|
+
Notes:
|
|
54
|
+
|
|
55
|
+
- API root is normalized to `/api/v1`.
|
|
56
|
+
- Temporary export files are written under `.primeui/temp/`.
|
|
57
|
+
|
|
58
|
+
## Install in common MCP clients
|
|
59
|
+
|
|
60
|
+
If your CLI command syntax differs by client version, use the JSON config from Getting started with the same `primeui` server block.
|
|
61
|
+
|
|
62
|
+
<details>
|
|
63
|
+
<summary>Codex CLI</summary>
|
|
64
|
+
|
|
65
|
+
Use the Codex MCP add command:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
codex mcp add primeui -- npx -y @primeuicom/mcp@latest
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Then set `PRIMEUI_API_KEY` in the MCP server env for `primeui`.
|
|
72
|
+
|
|
73
|
+
</details>
|
|
74
|
+
|
|
75
|
+
<details>
|
|
76
|
+
<summary>Claude Code</summary>
|
|
77
|
+
|
|
78
|
+
Add the server:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
claude mcp add primeui -- npx -y @primeuicom/mcp@latest
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Then configure server environment variables (at minimum `PRIMEUI_API_KEY`).
|
|
85
|
+
|
|
86
|
+
</details>
|
|
87
|
+
|
|
88
|
+
<details>
|
|
89
|
+
<summary>Cursor</summary>
|
|
90
|
+
|
|
91
|
+
Add the same server config to your Cursor MCP configuration:
|
|
20
92
|
|
|
21
93
|
```json
|
|
22
94
|
{
|
|
@@ -26,24 +98,104 @@ Example `.mcp.json`:
|
|
|
26
98
|
"command": "npx",
|
|
27
99
|
"args": ["-y", "@primeuicom/mcp@latest"],
|
|
28
100
|
"env": {
|
|
29
|
-
"PRIMEUI_API_KEY": "
|
|
101
|
+
"PRIMEUI_API_KEY": "your-primeui-api-key"
|
|
30
102
|
}
|
|
31
103
|
}
|
|
32
104
|
}
|
|
33
105
|
}
|
|
34
106
|
```
|
|
35
107
|
|
|
36
|
-
|
|
108
|
+
</details>
|
|
37
109
|
|
|
38
|
-
|
|
110
|
+
<details>
|
|
111
|
+
<summary>VS Code MCP-compatible setup</summary>
|
|
39
112
|
|
|
40
|
-
|
|
113
|
+
If your setup supports VS Code MCP server registration via CLI:
|
|
41
114
|
|
|
42
115
|
```bash
|
|
43
|
-
|
|
116
|
+
code --add-mcp '{"name":"primeui","command":"npx","args":["-y","@primeuicom/mcp@latest"],"env":{"PRIMEUI_API_KEY":"your-primeui-api-key"}}'
|
|
44
117
|
```
|
|
45
118
|
|
|
119
|
+
If your setup uses JSON config instead, use the same `.mcp.json` example from Getting started.
|
|
120
|
+
|
|
121
|
+
</details>
|
|
122
|
+
|
|
123
|
+
<details>
|
|
124
|
+
<summary>Cline / other JSON-config clients</summary>
|
|
125
|
+
|
|
126
|
+
Use the same `.mcp.json` server block from Getting started and provide `PRIMEUI_API_KEY`.
|
|
127
|
+
|
|
128
|
+
</details>
|
|
129
|
+
|
|
130
|
+
<details>
|
|
131
|
+
<summary>Gemini CLI</summary>
|
|
132
|
+
|
|
133
|
+
Add PrimeUI MCP:
|
|
134
|
+
|
|
46
135
|
```bash
|
|
47
|
-
|
|
136
|
+
gemini mcp add primeui npx -y @primeuicom/mcp@latest
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Then configure `PRIMEUI_API_KEY` for that server entry.
|
|
140
|
+
|
|
141
|
+
</details>
|
|
142
|
+
|
|
143
|
+
<details>
|
|
144
|
+
<summary>Windsurf</summary>
|
|
145
|
+
|
|
146
|
+
Use the same JSON server configuration shown in Getting started:
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"mcpServers": {
|
|
151
|
+
"primeui": {
|
|
152
|
+
"type": "stdio",
|
|
153
|
+
"command": "npx",
|
|
154
|
+
"args": ["-y", "@primeuicom/mcp@latest"],
|
|
155
|
+
"env": {
|
|
156
|
+
"PRIMEUI_API_KEY": "your-primeui-api-key"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
</details>
|
|
164
|
+
|
|
165
|
+
## Tools
|
|
166
|
+
|
|
167
|
+
Available tools:
|
|
48
168
|
|
|
169
|
+
| Tool | What it does | Input |
|
|
170
|
+
| --- | --- | --- |
|
|
171
|
+
| `primeui_get_project_info` | Returns project metadata and page list, including export readiness and source paths. | none |
|
|
172
|
+
| `primeui_list_exports` | Lists existing exports with ID, status, and creation time. | none |
|
|
173
|
+
| `primeui_create_export` | Starts a new export and returns created export info plus page snapshot. | none |
|
|
174
|
+
| `primeui_download_export` | Downloads and extracts a completed export into `.primeui/temp/exports/<exportId>/`. | `id` (export ID) |
|
|
175
|
+
| `primeui_clear_temp` | Clears `.primeui/temp/` and recreates baseline temp layout. | none |
|
|
176
|
+
|
|
177
|
+
## Your first prompt
|
|
178
|
+
|
|
179
|
+
Try this in your MCP-enabled agent:
|
|
180
|
+
|
|
181
|
+
```text
|
|
182
|
+
Use PrimeUI MCP to get my project info, list pages that are ready to export, then create a new export and tell me which export ID was created.
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Next step:
|
|
186
|
+
|
|
187
|
+
```text
|
|
188
|
+
Download that export with PrimeUI MCP and show me the local extracted projectPath and pagePath for the /pricing page.
|
|
49
189
|
```
|
|
190
|
+
|
|
191
|
+
## Runtime behavior
|
|
192
|
+
|
|
193
|
+
- PrimeUI MCP uses bearer authentication with `PRIMEUI_API_KEY`.
|
|
194
|
+
- If `PRIMEUI_API_BASE_URL` is not set, it uses `https://app.primeui.com/`.
|
|
195
|
+
- Downloaded archives are validated as ZIP payloads before extraction.
|
|
196
|
+
|
|
197
|
+
## Troubleshooting
|
|
198
|
+
|
|
199
|
+
- `PRIMEUI_API_KEY is required`: add or fix `PRIMEUI_API_KEY` in MCP server env.
|
|
200
|
+
- `Failed to extract zip`: verify local file permissions and retry.
|
|
201
|
+
- API contract mismatch errors: your client/server versions may be out of sync; update to latest package and verify PrimeUI backend version.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { z } from "zod/v3";
|
|
2
|
+
export declare const initialInstructions: string;
|
|
3
|
+
export declare const toolGetProjectInfo: {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {};
|
|
7
|
+
outputSchema: {
|
|
8
|
+
projectId: z.ZodString;
|
|
9
|
+
projectName: z.ZodString;
|
|
10
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
11
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
title: z.ZodString;
|
|
14
|
+
slug: z.ZodString;
|
|
15
|
+
pageType: z.ZodString;
|
|
16
|
+
isReadyToExport: z.ZodBoolean;
|
|
17
|
+
pagePath: z.ZodString;
|
|
18
|
+
componentsPath: z.ZodString;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
slug: string;
|
|
23
|
+
pageType: string;
|
|
24
|
+
isReadyToExport: boolean;
|
|
25
|
+
pagePath: string;
|
|
26
|
+
componentsPath: string;
|
|
27
|
+
}, {
|
|
28
|
+
id: string;
|
|
29
|
+
title: string;
|
|
30
|
+
slug: string;
|
|
31
|
+
pageType: string;
|
|
32
|
+
isReadyToExport: boolean;
|
|
33
|
+
pagePath: string;
|
|
34
|
+
componentsPath: string;
|
|
35
|
+
}>, "many">;
|
|
36
|
+
};
|
|
37
|
+
annotations: {
|
|
38
|
+
readOnlyHint: boolean;
|
|
39
|
+
destructiveHint: boolean;
|
|
40
|
+
idempotentHint: boolean;
|
|
41
|
+
openWorldHint: boolean;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare const toolListExports: {
|
|
45
|
+
title: string;
|
|
46
|
+
description: string;
|
|
47
|
+
inputSchema: {};
|
|
48
|
+
outputSchema: {
|
|
49
|
+
exports: z.ZodArray<z.ZodObject<{
|
|
50
|
+
id: z.ZodString;
|
|
51
|
+
status: z.ZodEnum<["in_progress", "completed", "failed"]>;
|
|
52
|
+
createdAt: z.ZodString;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
id: string;
|
|
55
|
+
status: "in_progress" | "completed" | "failed";
|
|
56
|
+
createdAt: string;
|
|
57
|
+
}, {
|
|
58
|
+
id: string;
|
|
59
|
+
status: "in_progress" | "completed" | "failed";
|
|
60
|
+
createdAt: string;
|
|
61
|
+
}>, "many">;
|
|
62
|
+
};
|
|
63
|
+
annotations: {
|
|
64
|
+
readOnlyHint: boolean;
|
|
65
|
+
destructiveHint: boolean;
|
|
66
|
+
idempotentHint: boolean;
|
|
67
|
+
openWorldHint: boolean;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export declare const toolCreateExport: {
|
|
71
|
+
title: string;
|
|
72
|
+
description: string;
|
|
73
|
+
inputSchema: {};
|
|
74
|
+
outputSchema: {
|
|
75
|
+
export: z.ZodObject<{
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
status: z.ZodEnum<["in_progress", "completed", "failed"]>;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
id: string;
|
|
80
|
+
status: "in_progress" | "completed" | "failed";
|
|
81
|
+
}, {
|
|
82
|
+
id: string;
|
|
83
|
+
status: "in_progress" | "completed" | "failed";
|
|
84
|
+
}>;
|
|
85
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
title: z.ZodString;
|
|
88
|
+
slug: z.ZodString;
|
|
89
|
+
pageType: z.ZodString;
|
|
90
|
+
isReadyToExport: z.ZodBoolean;
|
|
91
|
+
pagePath: z.ZodString;
|
|
92
|
+
componentsPath: z.ZodString;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
id: string;
|
|
95
|
+
title: string;
|
|
96
|
+
slug: string;
|
|
97
|
+
pageType: string;
|
|
98
|
+
isReadyToExport: boolean;
|
|
99
|
+
pagePath: string;
|
|
100
|
+
componentsPath: string;
|
|
101
|
+
}, {
|
|
102
|
+
id: string;
|
|
103
|
+
title: string;
|
|
104
|
+
slug: string;
|
|
105
|
+
pageType: string;
|
|
106
|
+
isReadyToExport: boolean;
|
|
107
|
+
pagePath: string;
|
|
108
|
+
componentsPath: string;
|
|
109
|
+
}>, "many">;
|
|
110
|
+
};
|
|
111
|
+
annotations: {
|
|
112
|
+
readOnlyHint: boolean;
|
|
113
|
+
destructiveHint: boolean;
|
|
114
|
+
idempotentHint: boolean;
|
|
115
|
+
openWorldHint: boolean;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
export declare const toolDownloadExport: {
|
|
119
|
+
title: string;
|
|
120
|
+
description: string;
|
|
121
|
+
inputSchema: {
|
|
122
|
+
id: z.ZodString;
|
|
123
|
+
};
|
|
124
|
+
outputSchema: {
|
|
125
|
+
exportId: z.ZodString;
|
|
126
|
+
projectPath: z.ZodString;
|
|
127
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
128
|
+
id: z.ZodString;
|
|
129
|
+
title: z.ZodString;
|
|
130
|
+
slug: z.ZodString;
|
|
131
|
+
pageType: z.ZodString;
|
|
132
|
+
isReadyToExport: z.ZodBoolean;
|
|
133
|
+
pagePath: z.ZodString;
|
|
134
|
+
componentsPath: z.ZodString;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
id: string;
|
|
137
|
+
title: string;
|
|
138
|
+
slug: string;
|
|
139
|
+
pageType: string;
|
|
140
|
+
isReadyToExport: boolean;
|
|
141
|
+
pagePath: string;
|
|
142
|
+
componentsPath: string;
|
|
143
|
+
}, {
|
|
144
|
+
id: string;
|
|
145
|
+
title: string;
|
|
146
|
+
slug: string;
|
|
147
|
+
pageType: string;
|
|
148
|
+
isReadyToExport: boolean;
|
|
149
|
+
pagePath: string;
|
|
150
|
+
componentsPath: string;
|
|
151
|
+
}>, "many">;
|
|
152
|
+
};
|
|
153
|
+
annotations: {
|
|
154
|
+
readOnlyHint: boolean;
|
|
155
|
+
destructiveHint: boolean;
|
|
156
|
+
idempotentHint: boolean;
|
|
157
|
+
openWorldHint: boolean;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
export declare const toolClearTemp: {
|
|
161
|
+
title: string;
|
|
162
|
+
description: string;
|
|
163
|
+
inputSchema: {};
|
|
164
|
+
outputSchema: {
|
|
165
|
+
success: z.ZodBoolean;
|
|
166
|
+
};
|
|
167
|
+
annotations: {
|
|
168
|
+
readOnlyHint: boolean;
|
|
169
|
+
destructiveHint: boolean;
|
|
170
|
+
idempotentHint: boolean;
|
|
171
|
+
openWorldHint: boolean;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { z } from "zod/v3";
|
|
2
|
+
const pageSchema = z.object({
|
|
3
|
+
id: z.string().describe("Stable PrimeUI page identifier. Use this to match the same page across tool responses."),
|
|
4
|
+
title: z.string().describe("Human-readable page title. Show this to the user when confirming which pages to import."),
|
|
5
|
+
slug: z
|
|
6
|
+
.string()
|
|
7
|
+
.describe("PrimeUI route slug, for example '/', '/pricing', '/docs/getting-started'. Use to match user intent."),
|
|
8
|
+
pageType: z
|
|
9
|
+
.string()
|
|
10
|
+
.describe("PrimeUI page type classification (for example landing, docs, pricing, blogIndex, legal)."),
|
|
11
|
+
isReadyToExport: z
|
|
12
|
+
.boolean()
|
|
13
|
+
.describe("True when this page has an active export-ready variant. Only ready pages are expected in export output."),
|
|
14
|
+
pagePath: z
|
|
15
|
+
.string()
|
|
16
|
+
.describe("Relative file path to the page source inside downloaded export root. Copy page code from this exact path."),
|
|
17
|
+
componentsPath: z
|
|
18
|
+
.string()
|
|
19
|
+
.describe("Relative directory path inside downloaded export root where page-level components live. Use as dependency copy start."),
|
|
20
|
+
}).describe("PrimeUI page descriptor used by project and export tools. Paths are always relative to export project root.");
|
|
21
|
+
const exportStatusSchema = z
|
|
22
|
+
.enum(["in_progress", "completed", "failed"])
|
|
23
|
+
.describe("Export lifecycle state. Use 'completed' before calling primeui_download_export.");
|
|
24
|
+
const exportItemSchema = z
|
|
25
|
+
.object({
|
|
26
|
+
id: z.string().describe("Export identifier. Pass this value to primeui_download_export input.id."),
|
|
27
|
+
status: exportStatusSchema,
|
|
28
|
+
createdAt: z.string().describe("Export creation timestamp in ISO-8601 UTC format."),
|
|
29
|
+
})
|
|
30
|
+
.describe("Single export record from PrimeUI export history.");
|
|
31
|
+
// ============================================================
|
|
32
|
+
// Shared constants
|
|
33
|
+
// ============================================================
|
|
34
|
+
const TRIGGER_PHRASES = [
|
|
35
|
+
"import page from PrimeUI",
|
|
36
|
+
"add page from PrimeUI",
|
|
37
|
+
"sync pages",
|
|
38
|
+
"pull page",
|
|
39
|
+
"transfer page",
|
|
40
|
+
"get page from PrimeUI",
|
|
41
|
+
"bring page from PrimeUI",
|
|
42
|
+
"export from PrimeUI",
|
|
43
|
+
].join(", ");
|
|
44
|
+
const WORKFLOW_SUMMARY = `
|
|
45
|
+
WORKFLOW ORDER (always follow this sequence):
|
|
46
|
+
1. primeui_get_project_info -> discover pages, confirm with user
|
|
47
|
+
2. primeui_create_export -> generate export snapshot
|
|
48
|
+
3. primeui_download_export -> download to temp directory
|
|
49
|
+
4. Manually move page code + dependencies into user's project (per page)
|
|
50
|
+
5. Repeat step 4 for each page user wants
|
|
51
|
+
6. primeui_clear_temp -> cleanup temp files
|
|
52
|
+
`.trim();
|
|
53
|
+
// ============================================================
|
|
54
|
+
// Server Instructions (initialInstructions)
|
|
55
|
+
// ============================================================
|
|
56
|
+
export const initialInstructions = `
|
|
57
|
+
PrimeUI MCP enables importing pages from PrimeUI Studio into your local project.
|
|
58
|
+
|
|
59
|
+
TRIGGER EXAMPLES (semantic intent, not exact phrase matching): ${TRIGGER_PHRASES}
|
|
60
|
+
|
|
61
|
+
${WORKFLOW_SUMMARY}
|
|
62
|
+
|
|
63
|
+
CRITICAL RULES FOR PAGE IMPORT:
|
|
64
|
+
- Import is PAGE-BY-PAGE only. Never import the entire project at once.
|
|
65
|
+
- The downloaded export in .primeui/temp/ contains a full standalone Next.js project.
|
|
66
|
+
Do NOT copy it wholesale.
|
|
67
|
+
- Copy ONLY the target page file and its direct component dependencies.
|
|
68
|
+
- Always use pagePath and componentsPath from tool responses as source of truth for file locations.
|
|
69
|
+
- Trace each page's imports to identify which component folders are needed.
|
|
70
|
+
- Check if components already exist in user's project - merge carefully, don't blindly overwrite.
|
|
71
|
+
- Adjust import paths to match user's project structure.
|
|
72
|
+
- Do NOT copy: package.json, next.config, tailwind.config, layout files, or any project-level config.
|
|
73
|
+
- If merge conflicts arise and cannot be resolved unambiguously, STOP and ask the user to decide.
|
|
74
|
+
`.trim();
|
|
75
|
+
// ============================================================
|
|
76
|
+
// Tool: primeui_get_project_info
|
|
77
|
+
// ============================================================
|
|
78
|
+
export const toolGetProjectInfo = {
|
|
79
|
+
title: "PrimeUI Project Info",
|
|
80
|
+
description: `ENTRY POINT for all PrimeUI import operations. Always start here. Returns project metadata and the full list of available pages.
|
|
81
|
+
|
|
82
|
+
WHEN TO USE: Call this FIRST when user wants to import, add, sync, pull, or transfer a page from PrimeUI. Intent examples (semantic intent, not exact phrase matching): ${TRIGGER_PHRASES}.
|
|
83
|
+
|
|
84
|
+
AFTER CALLING:
|
|
85
|
+
- If the user already specified which pages they need - verify those pages exist in the project and have isReadyToExport: true. If any requested page is not found or not ready, inform the user immediately.
|
|
86
|
+
- If the user did NOT specify pages - show the available pages list with titles and slugs, and ask which ones they want to import.
|
|
87
|
+
- Import works on a per-page basis, not the entire project at once. The user can request multiple pages, but each will be transferred individually.
|
|
88
|
+
- Only pages with isReadyToExport: true will be included in the export archive. If the user wants a page that is NOT ready, tell them to select an export-ready page variant in PrimeUI Studio first.
|
|
89
|
+
- Once target pages are confirmed, proceed to primeui_create_export.
|
|
90
|
+
|
|
91
|
+
${WORKFLOW_SUMMARY}`,
|
|
92
|
+
inputSchema: {},
|
|
93
|
+
outputSchema: {
|
|
94
|
+
projectId: z
|
|
95
|
+
.string()
|
|
96
|
+
.describe("PrimeUI project identifier associated with the API key and current import session context."),
|
|
97
|
+
projectName: z.string().describe("Human-readable PrimeUI project name for confirmations in chat."),
|
|
98
|
+
metadata: z
|
|
99
|
+
.record(z.unknown())
|
|
100
|
+
.describe("Additional project metadata from PrimeUI. May include project-description and other context fields."),
|
|
101
|
+
pages: z
|
|
102
|
+
.array(pageSchema)
|
|
103
|
+
.describe("All pages visible for this project context. Filter by user request and isReadyToExport before creating export."),
|
|
104
|
+
},
|
|
105
|
+
annotations: {
|
|
106
|
+
readOnlyHint: true,
|
|
107
|
+
destructiveHint: false,
|
|
108
|
+
idempotentHint: true,
|
|
109
|
+
openWorldHint: true,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
// ============================================================
|
|
113
|
+
// Tool: primeui_list_exports
|
|
114
|
+
// ============================================================
|
|
115
|
+
export const toolListExports = {
|
|
116
|
+
title: "PrimeUI Export List",
|
|
117
|
+
description: `Auxiliary tool to list previously created exports with their IDs, statuses, and creation dates. This is NOT the starting point for page import - start with primeui_get_project_info instead.
|
|
118
|
+
|
|
119
|
+
WHEN TO USE: This is an OPTIONAL helper tool, NOT part of the main import flow. Use it only when:
|
|
120
|
+
- Something went wrong with an export and you need to check its status.
|
|
121
|
+
- The user explicitly references a previous export by date or context.
|
|
122
|
+
- You need to verify whether an export initiated via PrimeUI Studio UI has completed.
|
|
123
|
+
|
|
124
|
+
Note: exports can be created both through primeui_create_export AND by the user directly in PrimeUI Studio UI. This tool shows all of them.
|
|
125
|
+
|
|
126
|
+
Do NOT use this tool as a substitute for primeui_create_export. Always create a fresh export unless the user explicitly asks to use a previous one.
|
|
127
|
+
|
|
128
|
+
${WORKFLOW_SUMMARY}`,
|
|
129
|
+
inputSchema: {},
|
|
130
|
+
outputSchema: {
|
|
131
|
+
exports: z
|
|
132
|
+
.array(exportItemSchema)
|
|
133
|
+
.describe("Available exports sorted by API policy. Use item.id to download a specific prior export if user asks."),
|
|
134
|
+
},
|
|
135
|
+
annotations: {
|
|
136
|
+
readOnlyHint: true,
|
|
137
|
+
destructiveHint: false,
|
|
138
|
+
idempotentHint: true,
|
|
139
|
+
openWorldHint: true,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
// ============================================================
|
|
143
|
+
// Tool: primeui_create_export
|
|
144
|
+
// ============================================================
|
|
145
|
+
export const toolCreateExport = {
|
|
146
|
+
title: "PrimeUI Create Export",
|
|
147
|
+
description: `Create a new export snapshot from the current PrimeUI project state and wait for completion. Returns export ID and the list of pages included in the export.
|
|
148
|
+
|
|
149
|
+
WHEN TO USE: Call this AFTER the user has confirmed which pages they want to import via primeui_get_project_info. This tool is REQUIRED before primeui_download_export, unless the user explicitly and directly asked to download a specific previous export.
|
|
150
|
+
|
|
151
|
+
AFTER CALLING:
|
|
152
|
+
- Verify that the pages the user wants are present in the export result AND have isReadyToExport: true. If a requested page is missing or not ready, inform the user before proceeding.
|
|
153
|
+
- Use the returned export ID to call primeui_download_export.
|
|
154
|
+
|
|
155
|
+
${WORKFLOW_SUMMARY}`,
|
|
156
|
+
inputSchema: {},
|
|
157
|
+
outputSchema: {
|
|
158
|
+
export: z
|
|
159
|
+
.object({
|
|
160
|
+
id: z.string().describe("Freshly created export identifier. Use this as primeui_download_export input.id."),
|
|
161
|
+
status: exportStatusSchema,
|
|
162
|
+
})
|
|
163
|
+
.describe("Created export summary."),
|
|
164
|
+
pages: z
|
|
165
|
+
.array(pageSchema)
|
|
166
|
+
.describe("Page snapshot associated with this export operation. Validate requested pages here before download/import."),
|
|
167
|
+
},
|
|
168
|
+
annotations: {
|
|
169
|
+
readOnlyHint: false,
|
|
170
|
+
destructiveHint: false,
|
|
171
|
+
idempotentHint: false,
|
|
172
|
+
openWorldHint: true,
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
// ============================================================
|
|
176
|
+
// Tool: primeui_download_export
|
|
177
|
+
// ============================================================
|
|
178
|
+
export const toolDownloadExport = {
|
|
179
|
+
title: "PrimeUI Download Export",
|
|
180
|
+
description: `Download a completed export into .primeui/temp/exports/[exportId]. Downloads and extracts the full export as a standalone Next.js project into the temp directory. This does NOT modify the user's project - files land only in .primeui/temp/.
|
|
181
|
+
|
|
182
|
+
Do NOT call this as the first step. Requires export ID from primeui_create_export. Start with primeui_get_project_info instead.
|
|
183
|
+
|
|
184
|
+
WHEN TO USE: Call this AFTER primeui_create_export has returned a completed export. Requires the export ID returned by primeui_create_export (or from primeui_list_exports if the user explicitly requested a previous export).
|
|
185
|
+
|
|
186
|
+
AFTER DOWNLOAD:
|
|
187
|
+
- The response includes a pages array. Verify the page the user wants is present and was exported successfully.
|
|
188
|
+
- Each page in the response has pagePath and componentsPath fields - use these as direct pointers to locate the page source code and its component dependencies in the downloaded export. No need to search manually.
|
|
189
|
+
|
|
190
|
+
MANUAL IMPORT STEPS per page (do not skip):
|
|
191
|
+
1. Read the page file at the pagePath from the response.
|
|
192
|
+
2. Read the component files at the componentsPath from the response. Trace the page's imports to identify which specific component folders are needed.
|
|
193
|
+
3. Copy ONLY the page file and its component dependencies into the user's project.
|
|
194
|
+
4. Adjust all import paths to match the user's project structure.
|
|
195
|
+
5. Check for existing components in user's project:
|
|
196
|
+
- If code overlaps or was modified on the user's side, carefully determine the nature of changes on both sides.
|
|
197
|
+
- If the merge conflict can be resolved unambiguously - resolve it.
|
|
198
|
+
- If NOT - STOP, explain the conflict to the user, and ask for their decision before continuing.
|
|
199
|
+
6. Do NOT copy project config files (package.json, next.config, tailwind.config, layout, etc.).
|
|
200
|
+
7. REPEAT steps 1-6 for each page the user wants to import.
|
|
201
|
+
8. Only after ALL pages are successfully imported, call primeui_clear_temp to clean up.
|
|
202
|
+
|
|
203
|
+
${WORKFLOW_SUMMARY}`,
|
|
204
|
+
inputSchema: {
|
|
205
|
+
id: z
|
|
206
|
+
.string()
|
|
207
|
+
.describe("Export identifier to download. Prefer export.id from primeui_create_export; use primeui_list_exports only on explicit user request."),
|
|
208
|
+
},
|
|
209
|
+
outputSchema: {
|
|
210
|
+
exportId: z
|
|
211
|
+
.string()
|
|
212
|
+
.describe("Downloaded export identifier. Should match the requested input.id for traceability."),
|
|
213
|
+
projectPath: z
|
|
214
|
+
.string()
|
|
215
|
+
.describe("Absolute local path to extracted export root in .primeui/temp/exports/[exportId]. Read files from here only."),
|
|
216
|
+
pages: z
|
|
217
|
+
.array(pageSchema)
|
|
218
|
+
.describe("Page descriptors for import decisions. Use pagePath/componentsPath from each item when copying code into user project."),
|
|
219
|
+
},
|
|
220
|
+
annotations: {
|
|
221
|
+
readOnlyHint: false,
|
|
222
|
+
destructiveHint: false,
|
|
223
|
+
idempotentHint: true,
|
|
224
|
+
openWorldHint: true,
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
// ============================================================
|
|
228
|
+
// Tool: primeui_clear_temp
|
|
229
|
+
// ============================================================
|
|
230
|
+
export const toolClearTemp = {
|
|
231
|
+
title: "PrimeUI Clear Temp",
|
|
232
|
+
description: `Delete all files in .primeui/temp/ and recreate empty temp structure.
|
|
233
|
+
|
|
234
|
+
Do NOT call this unless ALL requested pages have been successfully imported into the user's project.
|
|
235
|
+
|
|
236
|
+
WHEN TO USE: Call this as the FINAL step after ALL requested pages have been successfully imported into the user's project. Do not call this between page imports - wait until all pages are done.
|
|
237
|
+
|
|
238
|
+
Safe to call multiple times. Only affects .primeui/temp/ directory - never touches the user's project files.
|
|
239
|
+
|
|
240
|
+
${WORKFLOW_SUMMARY}`,
|
|
241
|
+
inputSchema: {},
|
|
242
|
+
outputSchema: {
|
|
243
|
+
success: z.boolean().describe("True when temp cleanup completed and baseline temp structure was recreated."),
|
|
244
|
+
},
|
|
245
|
+
annotations: {
|
|
246
|
+
readOnlyHint: false,
|
|
247
|
+
destructiveHint: false,
|
|
248
|
+
idempotentHint: true,
|
|
249
|
+
openWorldHint: false,
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
//# sourceMappingURL=instructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wFAAwF,CAAC;IACjH,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yFAAyF,CAAC;IACrH,IAAI,EAAE,CAAC;SACJ,MAAM,EAAE;SACR,QAAQ,CAAC,qGAAqG,CAAC;IAClH,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,QAAQ,CAAC,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E;IAClB,WAAW,EAAE,EAAE;IACf,YAAY,EAAE;QACZ,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,6EAA6E,CAAC;KAC7G;IACD,WAAW,EAAE;QACX,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACrB;CACF,CAAA"}
|
package/dist/lib/fs.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
1
|
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
3
2
|
import path from "node:path";
|
|
4
|
-
import
|
|
5
|
-
const execFileAsync = promisify(execFile);
|
|
3
|
+
import extractZipArchive from "extract-zip";
|
|
6
4
|
export async function ensureDir(dirPath) {
|
|
7
5
|
await mkdir(dirPath, { recursive: true });
|
|
8
6
|
}
|
|
@@ -17,11 +15,11 @@ export async function writeUtf8(filePath, content) {
|
|
|
17
15
|
export async function extractZip(zipPath, targetDir) {
|
|
18
16
|
await ensureDir(targetDir);
|
|
19
17
|
try {
|
|
20
|
-
await
|
|
18
|
+
await extractZipArchive(zipPath, { dir: targetDir });
|
|
21
19
|
}
|
|
22
20
|
catch (error) {
|
|
23
21
|
const details = error instanceof Error ? error.message : String(error);
|
|
24
|
-
throw new Error(`Failed to extract zip at "${zipPath}".
|
|
22
|
+
throw new Error(`Failed to extract zip at "${zipPath}". ${details}`);
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
//# sourceMappingURL=fs.js.map
|
package/dist/lib/fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/lib/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/lib/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,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
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import {
|
|
2
|
+
import { initialInstructions, toolClearTemp, toolCreateExport, toolDownloadExport, toolGetProjectInfo, toolListExports, } from "./instructions.js";
|
|
3
3
|
function okResult(title, data) {
|
|
4
4
|
return {
|
|
5
5
|
content: [{ type: "text", text: `${title} completed` }],
|
|
@@ -17,32 +17,10 @@ export function createPrimeUiMcpServer(source) {
|
|
|
17
17
|
const server = new McpServer({
|
|
18
18
|
name: "primeui-mcp-server",
|
|
19
19
|
version: "0.1.0",
|
|
20
|
+
}, {
|
|
21
|
+
instructions: initialInstructions,
|
|
20
22
|
});
|
|
21
|
-
server.registerTool("primeui_get_project_info", {
|
|
22
|
-
title: "PrimeUI Project Info",
|
|
23
|
-
description: "Get current project info for PrimeUI export context.",
|
|
24
|
-
inputSchema: {},
|
|
25
|
-
outputSchema: {
|
|
26
|
-
projectId: z.string(),
|
|
27
|
-
projectName: z.string(),
|
|
28
|
-
metadata: z.record(z.unknown()),
|
|
29
|
-
pages: z.array(z.object({
|
|
30
|
-
id: z.string(),
|
|
31
|
-
title: z.string(),
|
|
32
|
-
slug: z.string(),
|
|
33
|
-
pageType: z.string(),
|
|
34
|
-
isReadyToExport: z.boolean(),
|
|
35
|
-
pagePath: z.string(),
|
|
36
|
-
componentsPath: z.string(),
|
|
37
|
-
})),
|
|
38
|
-
},
|
|
39
|
-
annotations: {
|
|
40
|
-
readOnlyHint: true,
|
|
41
|
-
destructiveHint: false,
|
|
42
|
-
idempotentHint: true,
|
|
43
|
-
openWorldHint: false,
|
|
44
|
-
},
|
|
45
|
-
}, async () => {
|
|
23
|
+
server.registerTool("primeui_get_project_info", toolGetProjectInfo, async () => {
|
|
46
24
|
try {
|
|
47
25
|
const info = await source.getProjectInfo();
|
|
48
26
|
return okResult("primeui_get_project_info", info);
|
|
@@ -51,24 +29,7 @@ export function createPrimeUiMcpServer(source) {
|
|
|
51
29
|
return errorResult(error);
|
|
52
30
|
}
|
|
53
31
|
});
|
|
54
|
-
server.registerTool("primeui_list_exports", {
|
|
55
|
-
title: "PrimeUI Export List",
|
|
56
|
-
description: "List available PrimeUI exports.",
|
|
57
|
-
inputSchema: {},
|
|
58
|
-
outputSchema: {
|
|
59
|
-
exports: z.array(z.object({
|
|
60
|
-
id: z.string(),
|
|
61
|
-
status: z.enum(["in_progress", "completed", "failed"]),
|
|
62
|
-
createdAt: z.string(),
|
|
63
|
-
})),
|
|
64
|
-
},
|
|
65
|
-
annotations: {
|
|
66
|
-
readOnlyHint: true,
|
|
67
|
-
destructiveHint: false,
|
|
68
|
-
idempotentHint: true,
|
|
69
|
-
openWorldHint: false,
|
|
70
|
-
},
|
|
71
|
-
}, async () => {
|
|
32
|
+
server.registerTool("primeui_list_exports", toolListExports, async () => {
|
|
72
33
|
try {
|
|
73
34
|
const exportsList = await source.listExports();
|
|
74
35
|
return okResult("primeui_list_exports", { exports: exportsList });
|
|
@@ -77,32 +38,7 @@ export function createPrimeUiMcpServer(source) {
|
|
|
77
38
|
return errorResult(error);
|
|
78
39
|
}
|
|
79
40
|
});
|
|
80
|
-
server.registerTool("primeui_create_export", {
|
|
81
|
-
title: "PrimeUI Create Export",
|
|
82
|
-
description: "Create a new export from the current project state and wait for completion.",
|
|
83
|
-
inputSchema: {},
|
|
84
|
-
outputSchema: {
|
|
85
|
-
export: z.object({
|
|
86
|
-
id: z.string(),
|
|
87
|
-
status: z.enum(["in_progress", "completed", "failed"]),
|
|
88
|
-
}),
|
|
89
|
-
pages: z.array(z.object({
|
|
90
|
-
id: z.string(),
|
|
91
|
-
title: z.string(),
|
|
92
|
-
slug: z.string(),
|
|
93
|
-
pageType: z.string(),
|
|
94
|
-
isReadyToExport: z.boolean(),
|
|
95
|
-
pagePath: z.string(),
|
|
96
|
-
componentsPath: z.string(),
|
|
97
|
-
})),
|
|
98
|
-
},
|
|
99
|
-
annotations: {
|
|
100
|
-
readOnlyHint: false,
|
|
101
|
-
destructiveHint: false,
|
|
102
|
-
idempotentHint: false,
|
|
103
|
-
openWorldHint: false,
|
|
104
|
-
},
|
|
105
|
-
}, async () => {
|
|
41
|
+
server.registerTool("primeui_create_export", toolCreateExport, async () => {
|
|
106
42
|
try {
|
|
107
43
|
const result = await source.createExport();
|
|
108
44
|
return okResult("primeui_create_export", result);
|
|
@@ -111,23 +47,7 @@ export function createPrimeUiMcpServer(source) {
|
|
|
111
47
|
return errorResult(error);
|
|
112
48
|
}
|
|
113
49
|
});
|
|
114
|
-
server.registerTool("primeui_download_export", {
|
|
115
|
-
title: "PrimeUI Download Export",
|
|
116
|
-
description: "Download an export by id into .primeui/temp/exports/[exportId].",
|
|
117
|
-
inputSchema: {
|
|
118
|
-
id: z.string().describe("Export id from primeui_list_exports"),
|
|
119
|
-
},
|
|
120
|
-
outputSchema: {
|
|
121
|
-
exportId: z.string(),
|
|
122
|
-
projectPath: z.string(),
|
|
123
|
-
},
|
|
124
|
-
annotations: {
|
|
125
|
-
readOnlyHint: false,
|
|
126
|
-
destructiveHint: false,
|
|
127
|
-
idempotentHint: true,
|
|
128
|
-
openWorldHint: false,
|
|
129
|
-
},
|
|
130
|
-
}, async ({ id }) => {
|
|
50
|
+
server.registerTool("primeui_download_export", toolDownloadExport, async ({ id }) => {
|
|
131
51
|
try {
|
|
132
52
|
const result = await source.downloadExportById(id);
|
|
133
53
|
return okResult("primeui_download_export", result);
|
|
@@ -136,20 +56,7 @@ export function createPrimeUiMcpServer(source) {
|
|
|
136
56
|
return errorResult(error);
|
|
137
57
|
}
|
|
138
58
|
});
|
|
139
|
-
server.registerTool("primeui_clear_temp", {
|
|
140
|
-
title: "PrimeUI Clear Temp",
|
|
141
|
-
description: "Clear .primeui/temp and recreate baseline temp structure.",
|
|
142
|
-
inputSchema: {},
|
|
143
|
-
outputSchema: {
|
|
144
|
-
success: z.boolean(),
|
|
145
|
-
},
|
|
146
|
-
annotations: {
|
|
147
|
-
readOnlyHint: false,
|
|
148
|
-
destructiveHint: true,
|
|
149
|
-
idempotentHint: true,
|
|
150
|
-
openWorldHint: false,
|
|
151
|
-
},
|
|
152
|
-
}, async () => {
|
|
59
|
+
server.registerTool("primeui_clear_temp", toolClearTemp, async () => {
|
|
153
60
|
try {
|
|
154
61
|
await source.clearTemp();
|
|
155
62
|
return okResult("primeui_clear_temp", { success: true });
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAGnE,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,GAChB,MAAM,mBAAmB,CAAA;AAI1B,SAAS,QAAQ,CAAI,KAAa,EAAE,IAAO;IACzC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,YAAY,EAAE,CAAC;QACvD,iBAAiB,EAAE,IAA+B;KACnD,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACtE,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,OAAO,EAAE,EAAE,CAAC;KACnE,CAAA;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAyB;IAC9D,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,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AAC,kBAAkB,CAAC,EAAE,CAAC,CAAA;YACzE,OAAO,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAA;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,KAAK,CAAC,CAAA;QAC3B,CAAC;IACH,CAAC,CACF,CAAA;IAED,MAAM,CAAC,YAAY,CACjB,oBAAoB,EACpB,aAAa,EACb,KAAK,IAA6B,EAAE;QAClC,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,SAAS,EAAE,CAAA;YACxB,OAAO,QAAQ,CAAC,oBAAoB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;QAC1D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,KAAK,CAAC,CAAA;QAC3B,CAAC;IACH,CAAC,CACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -38,9 +38,11 @@ export class ProjectSyncService {
|
|
|
38
38
|
await this.provider.downloadExportArchive(id, targetZipPath);
|
|
39
39
|
await resetDir(targetProjectPath);
|
|
40
40
|
await extractZip(targetZipPath, targetProjectPath);
|
|
41
|
+
const { pages } = await this.provider.getProjectInfo();
|
|
41
42
|
return {
|
|
42
43
|
exportId: id,
|
|
43
44
|
projectPath: targetProjectPath,
|
|
45
|
+
pages,
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
async clearTemp() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-sync-service.js","sourceRoot":"","sources":["../../src/services/project-sync-service.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAUzE,MAAM,OAAO,kBAAkB;IACZ,QAAQ,CAAqB;IAC7B,WAAW,CAAQ;IACnB,WAAW,CAAQ;IACnB,QAAQ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C,CAAA;QAClD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAA;QAEtD,OAAO;YACL,QAAQ,EAAE,EAAE;YACZ,WAAW,EAAE,iBAAiB;YAC9B,KAAK;SACN,CAAA;IACH,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC7B,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAA;QACzD,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IACnC,CAAC;IAEO,KAAK,CAAC,gBAAgB;QAC5B,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACjC,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC9B,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACjC,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAA;IAC3D,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primeuicom/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/service.js",
|
|
6
6
|
"bin": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@modelcontextprotocol/sdk": "^1.25.3",
|
|
23
|
+
"extract-zip": "^2.0.1",
|
|
23
24
|
"zod": "^3.25.76"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|