@pandacss/mcp 1.11.2 → 1.11.3
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/dist/index.js +37 -0
- package/dist/index.mjs +37 -0
- package/package.json +8 -5
package/dist/index.js
CHANGED
|
@@ -182,6 +182,9 @@ async function startMcpServer(options = {}) {
|
|
|
182
182
|
const server = createMcpServer({ ctx });
|
|
183
183
|
const serverTransport = transport ?? new import_stdio.StdioServerTransport();
|
|
184
184
|
await server.connect(serverTransport);
|
|
185
|
+
if (!transport) {
|
|
186
|
+
watchProcessLifecycle(server);
|
|
187
|
+
}
|
|
185
188
|
console.error("Panda CSS MCP server started");
|
|
186
189
|
console.error(`Working directory: ${resolvedCwd}`);
|
|
187
190
|
if (resolvedConfigPath) {
|
|
@@ -189,6 +192,40 @@ async function startMcpServer(options = {}) {
|
|
|
189
192
|
}
|
|
190
193
|
return server;
|
|
191
194
|
}
|
|
195
|
+
function watchProcessLifecycle(server, options = {}) {
|
|
196
|
+
const proc = options.process ?? process;
|
|
197
|
+
const exit = options.exit ?? ((code) => process.exit(code));
|
|
198
|
+
let exiting = false;
|
|
199
|
+
const shutdown = (code) => {
|
|
200
|
+
if (exiting) return;
|
|
201
|
+
exiting = true;
|
|
202
|
+
void Promise.resolve(server.close()).catch(() => void 0);
|
|
203
|
+
exit(code);
|
|
204
|
+
};
|
|
205
|
+
proc.stdin.on("end", () => shutdown(0));
|
|
206
|
+
proc.stdin.on("close", () => shutdown(0));
|
|
207
|
+
proc.on("SIGINT", () => shutdown(0));
|
|
208
|
+
proc.on("SIGTERM", () => shutdown(0));
|
|
209
|
+
for (const stream of [proc.stdout, proc.stderr]) {
|
|
210
|
+
stream.on("error", (err) => {
|
|
211
|
+
if (err?.code === "EPIPE") shutdown(0);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
const onFatal = (label) => (err) => {
|
|
215
|
+
try {
|
|
216
|
+
proc.stderr.write(`[panda mcp] ${label}, exiting: ${formatError(err)}
|
|
217
|
+
`);
|
|
218
|
+
} catch {
|
|
219
|
+
}
|
|
220
|
+
shutdown(1);
|
|
221
|
+
};
|
|
222
|
+
proc.on("uncaughtException", onFatal("uncaught exception"));
|
|
223
|
+
proc.on("unhandledRejection", onFatal("unhandled rejection"));
|
|
224
|
+
return shutdown;
|
|
225
|
+
}
|
|
226
|
+
function formatError(err) {
|
|
227
|
+
return err instanceof Error ? err.stack ?? err.message : String(err);
|
|
228
|
+
}
|
|
192
229
|
|
|
193
230
|
// src/init.ts
|
|
194
231
|
var p = __toESM(require("@clack/prompts"));
|
package/dist/index.mjs
CHANGED
|
@@ -143,6 +143,9 @@ async function startMcpServer(options = {}) {
|
|
|
143
143
|
const server = createMcpServer({ ctx });
|
|
144
144
|
const serverTransport = transport ?? new StdioServerTransport();
|
|
145
145
|
await server.connect(serverTransport);
|
|
146
|
+
if (!transport) {
|
|
147
|
+
watchProcessLifecycle(server);
|
|
148
|
+
}
|
|
146
149
|
console.error("Panda CSS MCP server started");
|
|
147
150
|
console.error(`Working directory: ${resolvedCwd}`);
|
|
148
151
|
if (resolvedConfigPath) {
|
|
@@ -150,6 +153,40 @@ async function startMcpServer(options = {}) {
|
|
|
150
153
|
}
|
|
151
154
|
return server;
|
|
152
155
|
}
|
|
156
|
+
function watchProcessLifecycle(server, options = {}) {
|
|
157
|
+
const proc = options.process ?? process;
|
|
158
|
+
const exit = options.exit ?? ((code) => process.exit(code));
|
|
159
|
+
let exiting = false;
|
|
160
|
+
const shutdown = (code) => {
|
|
161
|
+
if (exiting) return;
|
|
162
|
+
exiting = true;
|
|
163
|
+
void Promise.resolve(server.close()).catch(() => void 0);
|
|
164
|
+
exit(code);
|
|
165
|
+
};
|
|
166
|
+
proc.stdin.on("end", () => shutdown(0));
|
|
167
|
+
proc.stdin.on("close", () => shutdown(0));
|
|
168
|
+
proc.on("SIGINT", () => shutdown(0));
|
|
169
|
+
proc.on("SIGTERM", () => shutdown(0));
|
|
170
|
+
for (const stream of [proc.stdout, proc.stderr]) {
|
|
171
|
+
stream.on("error", (err) => {
|
|
172
|
+
if (err?.code === "EPIPE") shutdown(0);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
const onFatal = (label) => (err) => {
|
|
176
|
+
try {
|
|
177
|
+
proc.stderr.write(`[panda mcp] ${label}, exiting: ${formatError(err)}
|
|
178
|
+
`);
|
|
179
|
+
} catch {
|
|
180
|
+
}
|
|
181
|
+
shutdown(1);
|
|
182
|
+
};
|
|
183
|
+
proc.on("uncaughtException", onFatal("uncaught exception"));
|
|
184
|
+
proc.on("unhandledRejection", onFatal("unhandled rejection"));
|
|
185
|
+
return shutdown;
|
|
186
|
+
}
|
|
187
|
+
function formatError(err) {
|
|
188
|
+
return err instanceof Error ? err.stack ?? err.message : String(err);
|
|
189
|
+
}
|
|
153
190
|
|
|
154
191
|
// src/init.ts
|
|
155
192
|
import * as p from "@clack/prompts";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/mcp",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.3",
|
|
4
4
|
"description": "MCP server for Panda CSS AI assistants",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -36,10 +36,13 @@
|
|
|
36
36
|
"@clack/prompts": "0.11.0",
|
|
37
37
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
38
38
|
"zod": "^4.0.0",
|
|
39
|
-
"@pandacss/logger": "1.11.
|
|
40
|
-
"@pandacss/node": "1.11.
|
|
41
|
-
"@pandacss/token-dictionary": "1.11.
|
|
42
|
-
"@pandacss/types": "1.11.
|
|
39
|
+
"@pandacss/logger": "1.11.3",
|
|
40
|
+
"@pandacss/node": "1.11.3",
|
|
41
|
+
"@pandacss/token-dictionary": "1.11.3",
|
|
42
|
+
"@pandacss/types": "1.11.3"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=20"
|
|
43
46
|
},
|
|
44
47
|
"scripts": {
|
|
45
48
|
"build": "tsup src/index.ts --format=esm,cjs",
|