@agimon-ai/style-system 0.1.8 → 0.1.9

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/cli.cjs CHANGED
@@ -1,13 +1,17 @@
1
1
  #!/usr/bin/env node
2
- const require_stdio = require("./stdio-EAP8fZ2p.cjs");
2
+ const require_stdio = require("./stdio-C2gi8JVm.cjs");
3
3
  let node_fs = require("node:fs");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_stdio.__toESM(node_path, 1);
6
+ let zod = require("zod");
6
7
  let _agimon_ai_foundation_exec = require("@agimon-ai/foundation-exec");
8
+ let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
7
9
  require("reflect-metadata");
8
10
  let commander = require("commander");
9
11
  let chalk = require("chalk");
10
12
  chalk = require_stdio.__toESM(chalk, 1);
13
+ let node_http = require("node:http");
14
+ let _modelcontextprotocol_node = require("@modelcontextprotocol/node");
11
15
  //#region src/utils/print.ts
12
16
  function resolveChalk(value, depth = 0) {
13
17
  if (value && (typeof value === "object" || typeof value === "function") && "red" in value && typeof value.red === "function") return value;
@@ -243,13 +247,80 @@ const listSharedComponentsCommand = new commander.Command("list-shared-component
243
247
  }
244
248
  });
245
249
  //#endregion
250
+ //#region src/transports/http.ts
251
+ /** Request-scoped modern Streamable HTTP. No legacy HTTP/SSE endpoint is registered. */
252
+ var HttpTransportHandler = class {
253
+ serverFactory;
254
+ host;
255
+ port;
256
+ server = null;
257
+ handler = null;
258
+ constructor(serverFactory, port, host = "localhost") {
259
+ this.serverFactory = serverFactory;
260
+ if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Error("Invalid HTTP port");
261
+ this.port = port;
262
+ this.host = host;
263
+ }
264
+ async start() {
265
+ if (this.server) throw new Error("MCP HTTP transport already running");
266
+ const handler = (0, _modelcontextprotocol_server.createMcpHandler)(this.serverFactory, { legacy: "reject" });
267
+ const serve = (0, _modelcontextprotocol_node.toNodeHandler)(handler);
268
+ const validateHost = (0, _modelcontextprotocol_node.localhostHostValidation)();
269
+ const validateOrigin = (0, _modelcontextprotocol_node.localhostOriginValidation)();
270
+ const loopback = [
271
+ "localhost",
272
+ "127.0.0.1",
273
+ "::1",
274
+ "[::1]"
275
+ ].includes(this.host);
276
+ const server = (0, node_http.createServer)((req, res) => {
277
+ if (req.url?.split("?")[0] !== "/mcp" || ![
278
+ "POST",
279
+ "GET",
280
+ "DELETE"
281
+ ].includes(req.method ?? "")) {
282
+ res.writeHead(404).end();
283
+ return;
284
+ }
285
+ if (loopback && (!validateHost(req, res) || !validateOrigin(req, res))) return;
286
+ serve(req, res).catch((error) => {
287
+ process.stderr.write(`MCP HTTP request failed: ${error instanceof Error ? error.message : String(error)}\n`);
288
+ if (!res.headersSent) res.writeHead(500).end();
289
+ });
290
+ });
291
+ try {
292
+ await new Promise((resolve, reject) => {
293
+ server.once("error", reject);
294
+ server.listen(this.port, this.host, () => resolve());
295
+ });
296
+ this.server = server;
297
+ this.handler = handler;
298
+ } catch (error) {
299
+ await handler.close();
300
+ throw error;
301
+ }
302
+ }
303
+ async stop() {
304
+ const server = this.server;
305
+ this.server = null;
306
+ const handler = this.handler;
307
+ this.handler = null;
308
+ await handler?.close();
309
+ if (server) await new Promise((resolve, reject) => server.close((error) => error ? reject(error) : resolve()));
310
+ }
311
+ getPort() {
312
+ const address = this.server?.address();
313
+ return address && typeof address !== "string" ? address.port : this.port;
314
+ }
315
+ };
316
+ //#endregion
246
317
  //#region src/commands/mcp-serve.ts
247
318
  /**
248
319
  * MCP Serve Command
249
320
  *
250
321
  * DESIGN PATTERNS:
251
322
  * - Command pattern with Commander for CLI argument parsing
252
- * - Transport abstraction pattern for flexible deployment (stdio, HTTP, SSE)
323
+ * - Transport abstraction pattern for modern stdio and HTTP
253
324
  * - Factory pattern for creating transport handlers
254
325
  * - Graceful shutdown pattern with signal handling
255
326
  *
@@ -283,7 +354,9 @@ async function startServer(handler, bundlerService, devServerPort) {
283
354
  releasePortOnRelease: false,
284
355
  metadata: devServerPort ? { devServerPort } : {}
285
356
  });
286
- } catch {}
357
+ } catch (error) {
358
+ console.error("Process registry unavailable:", error);
359
+ }
287
360
  const shutdown = async (signal) => {
288
361
  console.error(`\nReceived ${signal}, shutting down gracefully...`);
289
362
  try {
@@ -308,27 +381,37 @@ async function startServer(handler, bundlerService, devServerPort) {
308
381
  * Note: Design system configuration is now app-specific and read from each app's project.json.
309
382
  * No global theme configuration is needed at the server level.
310
383
  */
311
- const mcpServeCommand = new commander.Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio", "stdio").option("--theme-path <path>", "Theme CSS file path relative to workspace root for get-css-classes when app config does not define style-system.themePath").option("--dev", "Start Vite dev server for component hot reload and caching").option("--app-path <path>", "App path for dev server (e.g., apps/agiflow-app)").action(async (options) => {
384
+ const mcpServeCommand = new commander.Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio or http", "stdio").option("-p, --port <port>", "HTTP port (required for HTTP)").option("--host <host>", "HTTP bind host", "localhost").option("--theme-path <path>", "Theme CSS file path relative to workspace root for get-css-classes when app config does not define style-system.themePath").option("--dev", "Start Vite dev server for component hot reload and caching").option("--app-path <path>", "App path for dev server (e.g., apps/agiflow-app)").action(async (options) => {
312
385
  try {
313
- const transportType = options.type.toLowerCase();
386
+ const parsed = zod.z.object({
387
+ type: zod.z.enum(["stdio", "http"]),
388
+ port: zod.z.coerce.number().int().min(0).max(65535).optional(),
389
+ host: zod.z.string().min(1),
390
+ themePath: zod.z.string().optional(),
391
+ dev: zod.z.boolean().optional(),
392
+ appPath: zod.z.string().optional()
393
+ }).parse(options);
394
+ const transportType = parsed.type;
314
395
  let devServerPort;
315
396
  const bundlerService = await require_stdio.getBundlerServiceFromConfig();
316
- if (options.dev) {
317
- if (!options.appPath) {
397
+ if (parsed.dev) {
398
+ if (!parsed.appPath) {
318
399
  console.error("Error: --app-path is required when using --dev flag");
319
400
  console.error(`Example: ${require_stdio.STYLE_SYSTEM_CLI_NAME} mcp-serve --dev --app-path apps/agiflow-app`);
320
401
  process.exit(1);
321
402
  }
322
- const { url, port } = await bundlerService.startDevServer(options.appPath);
403
+ const { url, port } = await bundlerService.startDevServer(parsed.appPath);
323
404
  devServerPort = port;
324
405
  console.error(`Dev server started at ${url} (port: ${port})`);
325
406
  }
326
407
  if (transportType === "stdio") {
327
- const container = require_stdio.createContainer({ defaultThemePath: options.themePath });
328
- const server = require_stdio.createServer(container);
329
- await startServer(new require_stdio.StdioTransportHandler(server), bundlerService, devServerPort);
408
+ const container = require_stdio.createContainer({ defaultThemePath: parsed.themePath });
409
+ await startServer(new require_stdio.StdioTransportHandler(() => require_stdio.createServer(container)), bundlerService, devServerPort);
410
+ } else if (transportType === "http" && parsed.port !== void 0) {
411
+ const container = require_stdio.createContainer({ defaultThemePath: parsed.themePath });
412
+ await startServer(new HttpTransportHandler(() => require_stdio.createServer(container), parsed.port, parsed.host), bundlerService, devServerPort);
330
413
  } else {
331
- console.error(`Unknown transport type: ${transportType}. Use: stdio`);
414
+ console.error("HTTP requires --port");
332
415
  process.exit(1);
333
416
  }
334
417
  } catch (error) {
package/dist/cli.mjs CHANGED
@@ -1,11 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, L as log, N as DEFAULT_STYLE_SYSTEM_CONFIG, P as TailwindCSSClassesService, a as STYLE_SYSTEM_CLI_NAME, b as getBundlerServiceFromConfig, i as createServer, k as resolveStyleSystemThemePath, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler } from "./stdio-kBUcm1mr.mjs";
2
+ import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, L as log, N as DEFAULT_STYLE_SYSTEM_CONFIG, P as TailwindCSSClassesService, a as STYLE_SYSTEM_CLI_NAME, b as getBundlerServiceFromConfig, i as createServer$1, k as resolveStyleSystemThemePath, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler } from "./stdio-n-SouxK6.mjs";
3
3
  import { promises } from "node:fs";
4
4
  import path from "node:path";
5
+ import { z } from "zod";
5
6
  import { registerManagedProcess } from "@agimon-ai/foundation-exec";
7
+ import { createMcpHandler } from "@modelcontextprotocol/server";
6
8
  import "reflect-metadata";
7
9
  import { Command } from "commander";
8
10
  import * as chalkImport from "chalk";
11
+ import { createServer } from "node:http";
12
+ import { localhostHostValidation, localhostOriginValidation, toNodeHandler } from "@modelcontextprotocol/node";
9
13
  //#region src/utils/print.ts
10
14
  function resolveChalk(value, depth = 0) {
11
15
  if (value && (typeof value === "object" || typeof value === "function") && "red" in value && typeof value.red === "function") return value;
@@ -241,13 +245,80 @@ const listSharedComponentsCommand = new Command("list-shared-components").descri
241
245
  }
242
246
  });
243
247
  //#endregion
248
+ //#region src/transports/http.ts
249
+ /** Request-scoped modern Streamable HTTP. No legacy HTTP/SSE endpoint is registered. */
250
+ var HttpTransportHandler = class {
251
+ serverFactory;
252
+ host;
253
+ port;
254
+ server = null;
255
+ handler = null;
256
+ constructor(serverFactory, port, host = "localhost") {
257
+ this.serverFactory = serverFactory;
258
+ if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Error("Invalid HTTP port");
259
+ this.port = port;
260
+ this.host = host;
261
+ }
262
+ async start() {
263
+ if (this.server) throw new Error("MCP HTTP transport already running");
264
+ const handler = createMcpHandler(this.serverFactory, { legacy: "reject" });
265
+ const serve = toNodeHandler(handler);
266
+ const validateHost = localhostHostValidation();
267
+ const validateOrigin = localhostOriginValidation();
268
+ const loopback = [
269
+ "localhost",
270
+ "127.0.0.1",
271
+ "::1",
272
+ "[::1]"
273
+ ].includes(this.host);
274
+ const server = createServer((req, res) => {
275
+ if (req.url?.split("?")[0] !== "/mcp" || ![
276
+ "POST",
277
+ "GET",
278
+ "DELETE"
279
+ ].includes(req.method ?? "")) {
280
+ res.writeHead(404).end();
281
+ return;
282
+ }
283
+ if (loopback && (!validateHost(req, res) || !validateOrigin(req, res))) return;
284
+ serve(req, res).catch((error) => {
285
+ process.stderr.write(`MCP HTTP request failed: ${error instanceof Error ? error.message : String(error)}\n`);
286
+ if (!res.headersSent) res.writeHead(500).end();
287
+ });
288
+ });
289
+ try {
290
+ await new Promise((resolve, reject) => {
291
+ server.once("error", reject);
292
+ server.listen(this.port, this.host, () => resolve());
293
+ });
294
+ this.server = server;
295
+ this.handler = handler;
296
+ } catch (error) {
297
+ await handler.close();
298
+ throw error;
299
+ }
300
+ }
301
+ async stop() {
302
+ const server = this.server;
303
+ this.server = null;
304
+ const handler = this.handler;
305
+ this.handler = null;
306
+ await handler?.close();
307
+ if (server) await new Promise((resolve, reject) => server.close((error) => error ? reject(error) : resolve()));
308
+ }
309
+ getPort() {
310
+ const address = this.server?.address();
311
+ return address && typeof address !== "string" ? address.port : this.port;
312
+ }
313
+ };
314
+ //#endregion
244
315
  //#region src/commands/mcp-serve.ts
245
316
  /**
246
317
  * MCP Serve Command
247
318
  *
248
319
  * DESIGN PATTERNS:
249
320
  * - Command pattern with Commander for CLI argument parsing
250
- * - Transport abstraction pattern for flexible deployment (stdio, HTTP, SSE)
321
+ * - Transport abstraction pattern for modern stdio and HTTP
251
322
  * - Factory pattern for creating transport handlers
252
323
  * - Graceful shutdown pattern with signal handling
253
324
  *
@@ -281,7 +352,9 @@ async function startServer(handler, bundlerService, devServerPort) {
281
352
  releasePortOnRelease: false,
282
353
  metadata: devServerPort ? { devServerPort } : {}
283
354
  });
284
- } catch {}
355
+ } catch (error) {
356
+ console.error("Process registry unavailable:", error);
357
+ }
285
358
  const shutdown = async (signal) => {
286
359
  console.error(`\nReceived ${signal}, shutting down gracefully...`);
287
360
  try {
@@ -306,27 +379,37 @@ async function startServer(handler, bundlerService, devServerPort) {
306
379
  * Note: Design system configuration is now app-specific and read from each app's project.json.
307
380
  * No global theme configuration is needed at the server level.
308
381
  */
309
- const mcpServeCommand = new Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio", "stdio").option("--theme-path <path>", "Theme CSS file path relative to workspace root for get-css-classes when app config does not define style-system.themePath").option("--dev", "Start Vite dev server for component hot reload and caching").option("--app-path <path>", "App path for dev server (e.g., apps/agiflow-app)").action(async (options) => {
382
+ const mcpServeCommand = new Command("mcp-serve").description("Start MCP server with specified transport").option("-t, --type <type>", "Transport type: stdio or http", "stdio").option("-p, --port <port>", "HTTP port (required for HTTP)").option("--host <host>", "HTTP bind host", "localhost").option("--theme-path <path>", "Theme CSS file path relative to workspace root for get-css-classes when app config does not define style-system.themePath").option("--dev", "Start Vite dev server for component hot reload and caching").option("--app-path <path>", "App path for dev server (e.g., apps/agiflow-app)").action(async (options) => {
310
383
  try {
311
- const transportType = options.type.toLowerCase();
384
+ const parsed = z.object({
385
+ type: z.enum(["stdio", "http"]),
386
+ port: z.coerce.number().int().min(0).max(65535).optional(),
387
+ host: z.string().min(1),
388
+ themePath: z.string().optional(),
389
+ dev: z.boolean().optional(),
390
+ appPath: z.string().optional()
391
+ }).parse(options);
392
+ const transportType = parsed.type;
312
393
  let devServerPort;
313
394
  const bundlerService = await getBundlerServiceFromConfig();
314
- if (options.dev) {
315
- if (!options.appPath) {
395
+ if (parsed.dev) {
396
+ if (!parsed.appPath) {
316
397
  console.error("Error: --app-path is required when using --dev flag");
317
398
  console.error(`Example: ${STYLE_SYSTEM_CLI_NAME} mcp-serve --dev --app-path apps/agiflow-app`);
318
399
  process.exit(1);
319
400
  }
320
- const { url, port } = await bundlerService.startDevServer(options.appPath);
401
+ const { url, port } = await bundlerService.startDevServer(parsed.appPath);
321
402
  devServerPort = port;
322
403
  console.error(`Dev server started at ${url} (port: ${port})`);
323
404
  }
324
405
  if (transportType === "stdio") {
325
- const container = createContainer({ defaultThemePath: options.themePath });
326
- const server = createServer(container);
327
- await startServer(new StdioTransportHandler(server), bundlerService, devServerPort);
406
+ const container = createContainer({ defaultThemePath: parsed.themePath });
407
+ await startServer(new StdioTransportHandler(() => createServer$1(container)), bundlerService, devServerPort);
408
+ } else if (transportType === "http" && parsed.port !== void 0) {
409
+ const container = createContainer({ defaultThemePath: parsed.themePath });
410
+ await startServer(new HttpTransportHandler(() => createServer$1(container), parsed.port, parsed.host), bundlerService, devServerPort);
328
411
  } else {
329
- console.error(`Unknown transport type: ${transportType}. Use: stdio`);
412
+ console.error("HTTP requires --port");
330
413
  process.exit(1);
331
414
  }
332
415
  } catch (error) {
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_stdio = require("./stdio-EAP8fZ2p.cjs");
2
+ const require_stdio = require("./stdio-C2gi8JVm.cjs");
3
3
  let node_fs = require("node:fs");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_stdio.__toESM(node_path, 1);
package/dist/index.d.cts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Container, ContainerModule } from "inversify";
2
2
  import "zod";
3
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { CallToolResult, Server } from "@modelcontextprotocol/server";
4
4
  import { AliasOptions, Plugin, UserConfig } from "vite";
5
- import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
6
5
  //#region src/container/module.d.ts
7
6
  interface StyleSystemModuleOptions {
8
7
  defaultThemePath?: string;
@@ -1620,8 +1619,8 @@ interface ToolDefinition {
1620
1619
  name: string;
1621
1620
  description: string;
1622
1621
  inputSchema: {
1623
- type: string;
1624
- properties: Record<string, any>;
1622
+ type: 'object';
1623
+ properties: Record<string, Record<string, unknown>>;
1625
1624
  required?: string[];
1626
1625
  additionalProperties?: boolean;
1627
1626
  };
@@ -1630,7 +1629,7 @@ interface ToolDefinition {
1630
1629
  /**
1631
1630
  * Base tool interface following MCP SDK patterns
1632
1631
  */
1633
- interface Tool<TInput = any> {
1632
+ interface Tool<TInput = unknown> {
1634
1633
  getDefinition(): ToolDefinition;
1635
1634
  execute(input: TInput): Promise<CallToolResult>;
1636
1635
  }
@@ -1998,14 +1997,12 @@ declare class PolishComponentTool implements Tool<PolishComponentInput> {
1998
1997
  }
1999
1998
  //#endregion
2000
1999
  //#region src/transports/stdio.d.ts
2001
- /**
2002
- * Stdio transport handler for MCP server
2003
- * Used for command-line and direct integrations
2004
- */
2000
+ /** Modern MCP stdio only: reject legacy initialization explicitly. */
2005
2001
  declare class StdioTransportHandler {
2006
- private server;
2007
- private transport;
2008
- constructor(server: Server);
2002
+ private readonly factory;
2003
+ private handle;
2004
+ private started;
2005
+ constructor(server: Server | (() => Server));
2009
2006
  start(): Promise<void>;
2010
2007
  stop(): Promise<void>;
2011
2008
  }
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Container, ContainerModule } from "inversify";
2
2
  import { z } from "zod";
3
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
4
- import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ import { CallToolResult, Server } from "@modelcontextprotocol/server";
5
4
  import { AliasOptions, Plugin, UserConfig } from "vite";
6
5
  //#region src/container/module.d.ts
7
6
  interface StyleSystemModuleOptions {
@@ -1620,8 +1619,8 @@ interface ToolDefinition {
1620
1619
  name: string;
1621
1620
  description: string;
1622
1621
  inputSchema: {
1623
- type: string;
1624
- properties: Record<string, any>;
1622
+ type: 'object';
1623
+ properties: Record<string, Record<string, unknown>>;
1625
1624
  required?: string[];
1626
1625
  additionalProperties?: boolean;
1627
1626
  };
@@ -1630,7 +1629,7 @@ interface ToolDefinition {
1630
1629
  /**
1631
1630
  * Base tool interface following MCP SDK patterns
1632
1631
  */
1633
- interface Tool<TInput = any> {
1632
+ interface Tool<TInput = unknown> {
1634
1633
  getDefinition(): ToolDefinition;
1635
1634
  execute(input: TInput): Promise<CallToolResult>;
1636
1635
  }
@@ -1998,14 +1997,12 @@ declare class PolishComponentTool implements Tool<PolishComponentInput> {
1998
1997
  }
1999
1998
  //#endregion
2000
1999
  //#region src/transports/stdio.d.ts
2001
- /**
2002
- * Stdio transport handler for MCP server
2003
- * Used for command-line and direct integrations
2004
- */
2000
+ /** Modern MCP stdio only: reject legacy initialization explicitly. */
2005
2001
  declare class StdioTransportHandler {
2006
- private server;
2007
- private transport;
2008
- constructor(server: Server);
2002
+ private readonly factory;
2003
+ private handle;
2004
+ private started;
2005
+ constructor(server: Server | (() => Server));
2009
2006
  start(): Promise<void>;
2010
2007
  stop(): Promise<void>;
2011
2008
  }
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, D as resolveAppDesignSystemConfig, E as resetStyleSystemConfigCache, F as BaseCSSClassesService, I as TemplatesManagerService, M as CSSClassesServiceFactory, N as DEFAULT_STYLE_SYSTEM_CONFIG, O as StyleSystemConfigLoader, P as TailwindCSSClassesService, S as BaseBundlerService, T as hasStyleSystemProjectConfig, _ as ThemeService, b as getBundlerServiceFromConfig, c as createStyleSystemModule, d as ListSharedComponentsTool, f as GetComponentVisualTool, g as ComponentRendererService, h as GetUiComponentService, i as createServer, j as StoriesIndexService, k as resolveStyleSystemThemePath, l as PolishComponentTool, m as ListThemesTool, n as extractCustomTokenNames, p as GetCSSClassesTool, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, u as ListAppComponentsTool, v as createDefaultBundlerService, w as getSharedComponentTags, x as ViteReactBundlerService, y as getBundlerService } from "./stdio-kBUcm1mr.mjs";
1
+ import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, D as resolveAppDesignSystemConfig, E as resetStyleSystemConfigCache, F as BaseCSSClassesService, I as TemplatesManagerService, M as CSSClassesServiceFactory, N as DEFAULT_STYLE_SYSTEM_CONFIG, O as StyleSystemConfigLoader, P as TailwindCSSClassesService, S as BaseBundlerService, T as hasStyleSystemProjectConfig, _ as ThemeService, b as getBundlerServiceFromConfig, c as createStyleSystemModule, d as ListSharedComponentsTool, f as GetComponentVisualTool, g as ComponentRendererService, h as GetUiComponentService, i as createServer, j as StoriesIndexService, k as resolveStyleSystemThemePath, l as PolishComponentTool, m as ListThemesTool, n as extractCustomTokenNames, p as GetCSSClassesTool, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, u as ListAppComponentsTool, v as createDefaultBundlerService, w as getSharedComponentTags, x as ViteReactBundlerService, y as getBundlerService } from "./stdio-n-SouxK6.mjs";
2
2
  import { promises } from "node:fs";
3
3
  import path from "node:path";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -50,9 +50,8 @@ let _vitejs_plugin_react = require("@vitejs/plugin-react");
50
50
  _vitejs_plugin_react = __toESM(_vitejs_plugin_react, 1);
51
51
  let node_child_process = require("node:child_process");
52
52
  let _agimon_ai_foundation_exec = require("@agimon-ai/foundation-exec");
53
- let _modelcontextprotocol_sdk_server_index_js = require("@modelcontextprotocol/sdk/server/index.js");
54
- let _modelcontextprotocol_sdk_types_js = require("@modelcontextprotocol/sdk/types.js");
55
- let _modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
53
+ let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
54
+ let _modelcontextprotocol_server_stdio = require("@modelcontextprotocol/server/stdio");
56
55
  //#region src/services/ThemeService/BaseThemeService.ts
57
56
  /**
58
57
  * BaseThemeService
@@ -4015,26 +4014,6 @@ AppComponentsService = __decorate([
4015
4014
  ], AppComponentsService);
4016
4015
  //#endregion
4017
4016
  //#region src/tools/ListThemesTool.ts
4018
- /**
4019
- * ListThemesTool
4020
- *
4021
- * DESIGN PATTERNS:
4022
- * - Tool pattern with getDefinition() and execute() methods
4023
- * - Factory pattern for service creation
4024
- * - JSON Schema validation for inputs
4025
- *
4026
- * CODING STANDARDS:
4027
- * - Implement Tool interface from ../types
4028
- * - Use TOOL_NAME constant with snake_case (e.g., 'list_themes')
4029
- * - Return CallToolResult with content array
4030
- * - Handle errors with isError flag
4031
- * - Delegate complex logic to services
4032
- *
4033
- * AVOID:
4034
- * - Complex business logic in execute method
4035
- * - Unhandled promise rejections
4036
- * - Missing input validation
4037
- */
4038
4017
  var _ListThemesTool;
4039
4018
  let ListThemesTool = class ListThemesTool {
4040
4019
  static {
@@ -4097,26 +4076,6 @@ ListThemesTool = _ListThemesTool = __decorate([
4097
4076
  ], ListThemesTool);
4098
4077
  //#endregion
4099
4078
  //#region src/tools/GetCSSClassesTool.ts
4100
- /**
4101
- * GetCSSClassesTool
4102
- *
4103
- * DESIGN PATTERNS:
4104
- * - Tool pattern with getDefinition() and execute() methods
4105
- * - Service delegation for business logic via factory pattern
4106
- * - JSON Schema validation for inputs
4107
- *
4108
- * CODING STANDARDS:
4109
- * - Implement Tool interface from ../types
4110
- * - Use TOOL_NAME constant with snake_case (e.g., 'get_css_classes')
4111
- * - Return CallToolResult with content array
4112
- * - Handle errors with isError flag
4113
- * - Delegate complex logic to services
4114
- *
4115
- * AVOID:
4116
- * - Complex business logic in execute method
4117
- * - Unhandled promise rejections
4118
- * - Missing input validation
4119
- */
4120
4079
  var _GetCSSClassesTool;
4121
4080
  /**
4122
4081
  * Valid CSS class category values
@@ -4389,26 +4348,6 @@ var AntigravityCliService = class {
4389
4348
  };
4390
4349
  //#endregion
4391
4350
  //#region src/tools/GetComponentVisualTool.ts
4392
- /**
4393
- * GetComponentVisualTool
4394
- *
4395
- * DESIGN PATTERNS:
4396
- * - Tool pattern with getDefinition() and execute() methods
4397
- * - Service delegation for business logic
4398
- * - JSON Schema validation for inputs
4399
- *
4400
- * CODING STANDARDS:
4401
- * - Implement Tool interface from ../types
4402
- * - Use TOOL_NAME constant with snake_case (e.g., 'get_component_visual')
4403
- * - Return CallToolResult with content array
4404
- * - Handle errors with isError flag
4405
- * - Delegate complex logic to services
4406
- *
4407
- * AVOID:
4408
- * - Complex business logic in execute method
4409
- * - Unhandled promise rejections
4410
- * - Missing input validation
4411
- */
4412
4351
  var _GetComponentVisualTool;
4413
4352
  /**
4414
4353
  * Template for visual review instructions returned with component screenshots.
@@ -4531,26 +4470,6 @@ GetComponentVisualTool = _GetComponentVisualTool = __decorate([
4531
4470
  ], GetComponentVisualTool);
4532
4471
  //#endregion
4533
4472
  //#region src/tools/ListSharedComponentsTool.ts
4534
- /**
4535
- * ListSharedComponentsTool
4536
- *
4537
- * DESIGN PATTERNS:
4538
- * - Tool pattern with getDefinition() and execute() methods
4539
- * - Service delegation for business logic
4540
- * - JSON Schema validation for inputs
4541
- *
4542
- * CODING STANDARDS:
4543
- * - Implement Tool interface from ../types
4544
- * - Use TOOL_NAME constant with snake_case (e.g., 'list_shared_components')
4545
- * - Return CallToolResult with content array
4546
- * - Handle errors with isError flag
4547
- * - Delegate complex logic to services
4548
- *
4549
- * AVOID:
4550
- * - Complex business logic in execute method
4551
- * - Unhandled promise rejections
4552
- * - Missing input validation
4553
- */
4554
4473
  var _ListSharedComponentsTool;
4555
4474
  let ListSharedComponentsTool = class ListSharedComponentsTool {
4556
4475
  static {
@@ -4661,26 +4580,6 @@ ListSharedComponentsTool = _ListSharedComponentsTool = __decorate([
4661
4580
  ], ListSharedComponentsTool);
4662
4581
  //#endregion
4663
4582
  //#region src/tools/ListAppComponentsTool.ts
4664
- /**
4665
- * ListAppComponentsTool
4666
- *
4667
- * DESIGN PATTERNS:
4668
- * - Tool pattern with getDefinition() and execute() methods
4669
- * - Service delegation for business logic
4670
- * - JSON Schema validation for inputs
4671
- *
4672
- * CODING STANDARDS:
4673
- * - Implement Tool interface from ../types
4674
- * - Use TOOL_NAME constant with snake_case (e.g., 'list_app_components')
4675
- * - Return CallToolResult with content array
4676
- * - Handle errors with isError flag
4677
- * - Delegate complex logic to services
4678
- *
4679
- * AVOID:
4680
- * - Complex business logic in execute method
4681
- * - Unhandled promise rejections
4682
- * - Missing input validation
4683
- */
4684
4583
  var _ListAppComponentsTool;
4685
4584
  let ListAppComponentsTool = class ListAppComponentsTool {
4686
4585
  static {
@@ -5064,7 +4963,7 @@ function createContainer(options) {
5064
4963
  }
5065
4964
  //#endregion
5066
4965
  //#region package.json
5067
- var version = "0.1.7";
4966
+ var version = "0.1.8";
5068
4967
  //#endregion
5069
4968
  //#region src/metadata.ts
5070
4969
  const STYLE_SYSTEM_CLI_NAME = "style-system";
@@ -5086,7 +4985,7 @@ function createServer(containerOrThemePath) {
5086
4985
  let container;
5087
4986
  if (!containerOrThemePath || typeof containerOrThemePath === "string") container = createContainer({ defaultThemePath: containerOrThemePath });
5088
4987
  else container = containerOrThemePath;
5089
- const server = new _modelcontextprotocol_sdk_server_index_js.Server({
4988
+ const server = new _modelcontextprotocol_server.Server({
5090
4989
  name: STYLE_SYSTEM_SERVER_NAME,
5091
4990
  version: STYLE_SYSTEM_VERSION
5092
4991
  }, {
@@ -5099,7 +4998,7 @@ function createServer(containerOrThemePath) {
5099
4998
  const listSharedComponentsTool = container.get(STYLE_SYSTEM_TYPES.ListSharedComponentsTool);
5100
4999
  const listAppComponentsTool = container.get(STYLE_SYSTEM_TYPES.ListAppComponentsTool);
5101
5000
  const polishComponentTool = container.get(STYLE_SYSTEM_TYPES.PolishComponentTool);
5102
- server.setRequestHandler(_modelcontextprotocol_sdk_types_js.ListToolsRequestSchema, async () => {
5001
+ server.setRequestHandler("tools/list", async () => {
5103
5002
  return { tools: [
5104
5003
  withCapabilities(listThemesTool.getDefinition(), [
5105
5004
  "themes",
@@ -5133,23 +5032,45 @@ function createServer(containerOrThemePath) {
5133
5032
  "polish",
5134
5033
  "antigravity"
5135
5034
  ])
5136
- ] };
5035
+ ].map((tool) => {
5036
+ if (tool.inputSchema.type !== "object") throw new Error(`Invalid schema for ${tool.name}`);
5037
+ return {
5038
+ ...tool,
5039
+ inputSchema: tool.inputSchema
5040
+ };
5041
+ }) };
5137
5042
  });
5138
- server.setRequestHandler(_modelcontextprotocol_sdk_types_js.CallToolRequestSchema, async (request) => {
5043
+ server.setRequestHandler("tools/call", async (request) => {
5139
5044
  const { name, arguments: args } = request.params;
5140
- if (name === ListThemesTool.TOOL_NAME) return await listThemesTool.execute({});
5141
- if (name === GetCSSClassesTool.TOOL_NAME) return await getCSSClassesTool.execute(args);
5142
- if (name === GetComponentVisualTool.TOOL_NAME) return await getComponentVisualTool.execute(args);
5143
- if (name === ListSharedComponentsTool.TOOL_NAME) return await listSharedComponentsTool.execute({});
5144
- if (name === ListAppComponentsTool.TOOL_NAME) return await listAppComponentsTool.execute(args);
5145
- if (name === PolishComponentTool.TOOL_NAME) return await polishComponentTool.execute(args);
5146
- return {
5045
+ const tool = [
5046
+ listThemesTool,
5047
+ getCSSClassesTool,
5048
+ getComponentVisualTool,
5049
+ listSharedComponentsTool,
5050
+ listAppComponentsTool,
5051
+ polishComponentTool
5052
+ ].find((candidate) => candidate.getDefinition().name === name);
5053
+ if (!tool) return {
5147
5054
  content: [{
5148
5055
  type: "text",
5149
- text: `Error: Unknown tool: ${name}`
5056
+ text: `Unknown tool: ${name}`
5150
5057
  }],
5151
5058
  isError: true
5152
5059
  };
5060
+ try {
5061
+ const definition = tool.getDefinition();
5062
+ if (definition.inputSchema.type !== "object") throw new Error(`Invalid schema for ${name}`);
5063
+ const input = zod.z.fromJSONSchema(definition.inputSchema).parse(args ?? {});
5064
+ return await tool.execute(input);
5065
+ } catch (error) {
5066
+ return {
5067
+ content: [{
5068
+ type: "text",
5069
+ text: error instanceof Error ? error.message : String(error)
5070
+ }],
5071
+ isError: true
5072
+ };
5073
+ }
5153
5074
  });
5154
5075
  return server;
5155
5076
  }
@@ -5293,42 +5214,24 @@ function generateRestrictedClassesConfig(cssResult) {
5293
5214
  }
5294
5215
  //#endregion
5295
5216
  //#region src/transports/stdio.ts
5296
- /**
5297
- * STDIO Transport
5298
- *
5299
- * DESIGN PATTERNS:
5300
- * - Transport handler pattern implementing TransportHandler interface
5301
- * - Standard I/O based communication for CLI usage
5302
- *
5303
- * CODING STANDARDS:
5304
- * - Initialize server and transport properly
5305
- * - Handle cleanup on shutdown with stop() method
5306
- * - Use async/await for all operations
5307
- *
5308
- * AVOID:
5309
- * - Forgetting to close transport on shutdown
5310
- * - Missing error handling for connection failures
5311
- */
5312
- /**
5313
- * Stdio transport handler for MCP server
5314
- * Used for command-line and direct integrations
5315
- */
5217
+ /** Modern MCP stdio only: reject legacy initialization explicitly. */
5316
5218
  var StdioTransportHandler = class {
5317
- server;
5318
- transport = null;
5219
+ factory;
5220
+ handle = null;
5221
+ started = false;
5319
5222
  constructor(server) {
5320
- this.server = server;
5223
+ this.factory = typeof server === "function" ? server : () => server;
5321
5224
  }
5322
5225
  async start() {
5323
- this.transport = new _modelcontextprotocol_sdk_server_stdio_js.StdioServerTransport();
5324
- await this.server.connect(this.transport);
5226
+ if (this.handle || this.started) throw new Error("style-system stdio server already started");
5227
+ this.handle = (0, _modelcontextprotocol_server_stdio.serveStdio)(this.factory, { legacy: "reject" });
5228
+ this.started = true;
5325
5229
  log.info(`${STYLE_SYSTEM_SERVER_NAME} MCP server started on stdio`);
5326
5230
  }
5327
5231
  async stop() {
5328
- if (this.transport) {
5329
- await this.transport.close();
5330
- this.transport = null;
5331
- }
5232
+ if (!this.handle) return;
5233
+ await this.handle.close();
5234
+ this.handle = null;
5332
5235
  }
5333
5236
  };
5334
5237
  //#endregion
@@ -21,9 +21,8 @@ import { fileURLToPath } from "node:url";
21
21
  import react from "@vitejs/plugin-react";
22
22
  import { execSync, spawn } from "node:child_process";
23
23
  import { registerManagedProcess } from "@agimon-ai/foundation-exec";
24
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
25
- import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
26
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
24
+ import { Server } from "@modelcontextprotocol/server";
25
+ import { serveStdio } from "@modelcontextprotocol/server/stdio";
27
26
  //#region \0rolldown/runtime.js
28
27
  var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
29
28
  //#endregion
@@ -3989,26 +3988,6 @@ AppComponentsService = __decorate([
3989
3988
  ], AppComponentsService);
3990
3989
  //#endregion
3991
3990
  //#region src/tools/ListThemesTool.ts
3992
- /**
3993
- * ListThemesTool
3994
- *
3995
- * DESIGN PATTERNS:
3996
- * - Tool pattern with getDefinition() and execute() methods
3997
- * - Factory pattern for service creation
3998
- * - JSON Schema validation for inputs
3999
- *
4000
- * CODING STANDARDS:
4001
- * - Implement Tool interface from ../types
4002
- * - Use TOOL_NAME constant with snake_case (e.g., 'list_themes')
4003
- * - Return CallToolResult with content array
4004
- * - Handle errors with isError flag
4005
- * - Delegate complex logic to services
4006
- *
4007
- * AVOID:
4008
- * - Complex business logic in execute method
4009
- * - Unhandled promise rejections
4010
- * - Missing input validation
4011
- */
4012
3991
  var _ListThemesTool;
4013
3992
  let ListThemesTool = class ListThemesTool {
4014
3993
  static {
@@ -4071,26 +4050,6 @@ ListThemesTool = _ListThemesTool = __decorate([
4071
4050
  ], ListThemesTool);
4072
4051
  //#endregion
4073
4052
  //#region src/tools/GetCSSClassesTool.ts
4074
- /**
4075
- * GetCSSClassesTool
4076
- *
4077
- * DESIGN PATTERNS:
4078
- * - Tool pattern with getDefinition() and execute() methods
4079
- * - Service delegation for business logic via factory pattern
4080
- * - JSON Schema validation for inputs
4081
- *
4082
- * CODING STANDARDS:
4083
- * - Implement Tool interface from ../types
4084
- * - Use TOOL_NAME constant with snake_case (e.g., 'get_css_classes')
4085
- * - Return CallToolResult with content array
4086
- * - Handle errors with isError flag
4087
- * - Delegate complex logic to services
4088
- *
4089
- * AVOID:
4090
- * - Complex business logic in execute method
4091
- * - Unhandled promise rejections
4092
- * - Missing input validation
4093
- */
4094
4053
  var _GetCSSClassesTool;
4095
4054
  /**
4096
4055
  * Valid CSS class category values
@@ -4363,26 +4322,6 @@ var AntigravityCliService = class {
4363
4322
  };
4364
4323
  //#endregion
4365
4324
  //#region src/tools/GetComponentVisualTool.ts
4366
- /**
4367
- * GetComponentVisualTool
4368
- *
4369
- * DESIGN PATTERNS:
4370
- * - Tool pattern with getDefinition() and execute() methods
4371
- * - Service delegation for business logic
4372
- * - JSON Schema validation for inputs
4373
- *
4374
- * CODING STANDARDS:
4375
- * - Implement Tool interface from ../types
4376
- * - Use TOOL_NAME constant with snake_case (e.g., 'get_component_visual')
4377
- * - Return CallToolResult with content array
4378
- * - Handle errors with isError flag
4379
- * - Delegate complex logic to services
4380
- *
4381
- * AVOID:
4382
- * - Complex business logic in execute method
4383
- * - Unhandled promise rejections
4384
- * - Missing input validation
4385
- */
4386
4325
  var _GetComponentVisualTool;
4387
4326
  /**
4388
4327
  * Template for visual review instructions returned with component screenshots.
@@ -4505,26 +4444,6 @@ GetComponentVisualTool = _GetComponentVisualTool = __decorate([
4505
4444
  ], GetComponentVisualTool);
4506
4445
  //#endregion
4507
4446
  //#region src/tools/ListSharedComponentsTool.ts
4508
- /**
4509
- * ListSharedComponentsTool
4510
- *
4511
- * DESIGN PATTERNS:
4512
- * - Tool pattern with getDefinition() and execute() methods
4513
- * - Service delegation for business logic
4514
- * - JSON Schema validation for inputs
4515
- *
4516
- * CODING STANDARDS:
4517
- * - Implement Tool interface from ../types
4518
- * - Use TOOL_NAME constant with snake_case (e.g., 'list_shared_components')
4519
- * - Return CallToolResult with content array
4520
- * - Handle errors with isError flag
4521
- * - Delegate complex logic to services
4522
- *
4523
- * AVOID:
4524
- * - Complex business logic in execute method
4525
- * - Unhandled promise rejections
4526
- * - Missing input validation
4527
- */
4528
4447
  var _ListSharedComponentsTool;
4529
4448
  let ListSharedComponentsTool = class ListSharedComponentsTool {
4530
4449
  static {
@@ -4635,26 +4554,6 @@ ListSharedComponentsTool = _ListSharedComponentsTool = __decorate([
4635
4554
  ], ListSharedComponentsTool);
4636
4555
  //#endregion
4637
4556
  //#region src/tools/ListAppComponentsTool.ts
4638
- /**
4639
- * ListAppComponentsTool
4640
- *
4641
- * DESIGN PATTERNS:
4642
- * - Tool pattern with getDefinition() and execute() methods
4643
- * - Service delegation for business logic
4644
- * - JSON Schema validation for inputs
4645
- *
4646
- * CODING STANDARDS:
4647
- * - Implement Tool interface from ../types
4648
- * - Use TOOL_NAME constant with snake_case (e.g., 'list_app_components')
4649
- * - Return CallToolResult with content array
4650
- * - Handle errors with isError flag
4651
- * - Delegate complex logic to services
4652
- *
4653
- * AVOID:
4654
- * - Complex business logic in execute method
4655
- * - Unhandled promise rejections
4656
- * - Missing input validation
4657
- */
4658
4557
  var _ListAppComponentsTool;
4659
4558
  let ListAppComponentsTool = class ListAppComponentsTool {
4660
4559
  static {
@@ -5038,7 +4937,7 @@ function createContainer(options) {
5038
4937
  }
5039
4938
  //#endregion
5040
4939
  //#region package.json
5041
- var version = "0.1.7";
4940
+ var version = "0.1.8";
5042
4941
  //#endregion
5043
4942
  //#region src/metadata.ts
5044
4943
  const STYLE_SYSTEM_CLI_NAME = "style-system";
@@ -5073,7 +4972,7 @@ function createServer(containerOrThemePath) {
5073
4972
  const listSharedComponentsTool = container.get(STYLE_SYSTEM_TYPES.ListSharedComponentsTool);
5074
4973
  const listAppComponentsTool = container.get(STYLE_SYSTEM_TYPES.ListAppComponentsTool);
5075
4974
  const polishComponentTool = container.get(STYLE_SYSTEM_TYPES.PolishComponentTool);
5076
- server.setRequestHandler(ListToolsRequestSchema, async () => {
4975
+ server.setRequestHandler("tools/list", async () => {
5077
4976
  return { tools: [
5078
4977
  withCapabilities(listThemesTool.getDefinition(), [
5079
4978
  "themes",
@@ -5107,23 +5006,45 @@ function createServer(containerOrThemePath) {
5107
5006
  "polish",
5108
5007
  "antigravity"
5109
5008
  ])
5110
- ] };
5009
+ ].map((tool) => {
5010
+ if (tool.inputSchema.type !== "object") throw new Error(`Invalid schema for ${tool.name}`);
5011
+ return {
5012
+ ...tool,
5013
+ inputSchema: tool.inputSchema
5014
+ };
5015
+ }) };
5111
5016
  });
5112
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
5017
+ server.setRequestHandler("tools/call", async (request) => {
5113
5018
  const { name, arguments: args } = request.params;
5114
- if (name === ListThemesTool.TOOL_NAME) return await listThemesTool.execute({});
5115
- if (name === GetCSSClassesTool.TOOL_NAME) return await getCSSClassesTool.execute(args);
5116
- if (name === GetComponentVisualTool.TOOL_NAME) return await getComponentVisualTool.execute(args);
5117
- if (name === ListSharedComponentsTool.TOOL_NAME) return await listSharedComponentsTool.execute({});
5118
- if (name === ListAppComponentsTool.TOOL_NAME) return await listAppComponentsTool.execute(args);
5119
- if (name === PolishComponentTool.TOOL_NAME) return await polishComponentTool.execute(args);
5120
- return {
5019
+ const tool = [
5020
+ listThemesTool,
5021
+ getCSSClassesTool,
5022
+ getComponentVisualTool,
5023
+ listSharedComponentsTool,
5024
+ listAppComponentsTool,
5025
+ polishComponentTool
5026
+ ].find((candidate) => candidate.getDefinition().name === name);
5027
+ if (!tool) return {
5121
5028
  content: [{
5122
5029
  type: "text",
5123
- text: `Error: Unknown tool: ${name}`
5030
+ text: `Unknown tool: ${name}`
5124
5031
  }],
5125
5032
  isError: true
5126
5033
  };
5034
+ try {
5035
+ const definition = tool.getDefinition();
5036
+ if (definition.inputSchema.type !== "object") throw new Error(`Invalid schema for ${name}`);
5037
+ const input = z.fromJSONSchema(definition.inputSchema).parse(args ?? {});
5038
+ return await tool.execute(input);
5039
+ } catch (error) {
5040
+ return {
5041
+ content: [{
5042
+ type: "text",
5043
+ text: error instanceof Error ? error.message : String(error)
5044
+ }],
5045
+ isError: true
5046
+ };
5047
+ }
5127
5048
  });
5128
5049
  return server;
5129
5050
  }
@@ -5267,42 +5188,24 @@ function generateRestrictedClassesConfig(cssResult) {
5267
5188
  }
5268
5189
  //#endregion
5269
5190
  //#region src/transports/stdio.ts
5270
- /**
5271
- * STDIO Transport
5272
- *
5273
- * DESIGN PATTERNS:
5274
- * - Transport handler pattern implementing TransportHandler interface
5275
- * - Standard I/O based communication for CLI usage
5276
- *
5277
- * CODING STANDARDS:
5278
- * - Initialize server and transport properly
5279
- * - Handle cleanup on shutdown with stop() method
5280
- * - Use async/await for all operations
5281
- *
5282
- * AVOID:
5283
- * - Forgetting to close transport on shutdown
5284
- * - Missing error handling for connection failures
5285
- */
5286
- /**
5287
- * Stdio transport handler for MCP server
5288
- * Used for command-line and direct integrations
5289
- */
5191
+ /** Modern MCP stdio only: reject legacy initialization explicitly. */
5290
5192
  var StdioTransportHandler = class {
5291
- server;
5292
- transport = null;
5193
+ factory;
5194
+ handle = null;
5195
+ started = false;
5293
5196
  constructor(server) {
5294
- this.server = server;
5197
+ this.factory = typeof server === "function" ? server : () => server;
5295
5198
  }
5296
5199
  async start() {
5297
- this.transport = new StdioServerTransport();
5298
- await this.server.connect(this.transport);
5200
+ if (this.handle || this.started) throw new Error("style-system stdio server already started");
5201
+ this.handle = serveStdio(this.factory, { legacy: "reject" });
5202
+ this.started = true;
5299
5203
  log.info(`${STYLE_SYSTEM_SERVER_NAME} MCP server started on stdio`);
5300
5204
  }
5301
5205
  async stop() {
5302
- if (this.transport) {
5303
- await this.transport.close();
5304
- this.transport = null;
5305
- }
5206
+ if (!this.handle) return;
5207
+ await this.handle.close();
5208
+ this.handle = null;
5306
5209
  }
5307
5210
  };
5308
5211
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/style-system",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "MCP server for exploring themes, Tailwind CSS classes, and UI components from Storybook with standalone component rendering capabilities",
5
5
  "keywords": [
6
6
  "design-system",
@@ -40,7 +40,8 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@modelcontextprotocol/sdk": "1.29.0",
43
+ "@modelcontextprotocol/node": "2.1.0",
44
+ "@modelcontextprotocol/server": "2.1.0",
44
45
  "@tailwindcss/vite": "4.3.3",
45
46
  "@vitejs/plugin-react": "6.0.3",
46
47
  "chalk": "5.6.2",
@@ -60,12 +61,14 @@
60
61
  "tailwindcss": "4.3.3",
61
62
  "vite": "8.1.5",
62
63
  "vite-plugin-singlefile": "^2.3.3",
63
- "@agimon-ai/foundation-exec": "0.26.30"
64
+ "@agimon-ai/foundation-exec": "0.26.31",
65
+ "@agimon-ai/foundation-validator": "0.26.31"
64
66
  },
65
67
  "devDependencies": {
66
68
  "@babel/parser": "8.0.0",
67
69
  "@babel/traverse": "8.0.0",
68
70
  "@babel/types": "8.0.0",
71
+ "@modelcontextprotocol/client": "2.1.0",
69
72
  "@types/babel__traverse": "7.28.0",
70
73
  "@types/node": "26.1.1",
71
74
  "@types/react": "19.2.17",