@bamboocss/mcp 1.56.7 → 1.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,9 +25,13 @@ let _modelcontextprotocol_sdk_server_stdio_js = require("@modelcontextprotocol/s
25
25
  let _bamboocss_logger = require("@bamboocss/logger");
26
26
  let _bamboocss_node = require("@bamboocss/node");
27
27
  let _bamboocss_token_dictionary = require("@bamboocss/token-dictionary");
28
- let path = require("path");
28
+ let node_console = require("node:console");
29
+ let node_path = require("node:path");
29
30
  let zod_v4 = require("zod/v4");
30
31
  zod_v4 = __toESM(zod_v4);
32
+ //#region package.json
33
+ var version = "1.57.0";
34
+ //#endregion
31
35
  //#region src/server.ts
32
36
  const tokenCategorySchema = zod_v4.enum(_bamboocss_token_dictionary.TOKEN_CATEGORIES).optional().describe("Filter by token category");
33
37
  const json = (data) => ({ content: [{
@@ -42,7 +46,7 @@ function createMcpServer(options) {
42
46
  const { ctx } = options;
43
47
  const server = new _modelcontextprotocol_sdk_server_mcp_js.McpServer({
44
48
  name: "@bamboocss/mcp",
45
- version: "1.0.0"
49
+ version
46
50
  });
47
51
  const recipeNames = ctx.recipes.keys;
48
52
  const patternNames = ctx.patterns.keys;
@@ -98,32 +102,78 @@ function createMcpServer(options) {
98
102
  server.registerTool("get_color_palette", { description: "Get the color palette with all color values" }, async () => json(ctx.getSpecOfType("color-palette")));
99
103
  server.registerTool("get_config", { description: "Get the resolved Bamboo CSS configuration including paths, JSX settings, and output options" }, async () => json(ctx.config));
100
104
  server.registerTool("get_usage_report", {
101
- description: "Get a usage report of design tokens and recipes across the codebase. Shows which tokens/recipes are used, unused, or missing. Useful for auditing, cleanup, and identifying dead code.",
105
+ description: "Get a usage report of the design system across the codebase: design tokens, recipes, patterns, utilities and keyframes. Shows which are used and how often, and which are defined but unused. Useful for auditing, cleanup, and identifying dead code.",
102
106
  inputSchema: { scope: zod_v4.enum([
103
107
  "all",
104
108
  "token",
105
- "recipe"
106
- ]).optional().describe("Analysis scope: token, recipe, or all (default)") }
109
+ "recipe",
110
+ "pattern",
111
+ "utility",
112
+ "keyframe"
113
+ ]).optional().describe("Analysis scope: token, recipe, pattern, utility, keyframe, or all (default)") }
107
114
  }, async ({ scope }) => {
108
115
  const result = await (0, _bamboocss_node.analyze)(ctx);
109
- const includeTokens = !scope || scope === "all" || scope === "token";
110
- const includeRecipes = !scope || scope === "all" || scope === "recipe";
116
+ const includes = (part) => !scope || scope === "all" || scope === part;
111
117
  const report = {};
112
- if (includeTokens && !ctx.tokens.isEmpty) report.tokens = result.getTokenReport().report.getSummary();
113
- if (includeRecipes && !ctx.recipes.isEmpty()) report.recipes = result.getRecipeReport().report;
118
+ if (includes("token") && !ctx.tokens.isEmpty) report.tokens = result.getTokenReport().report.getSummary();
119
+ if (includes("recipe") && !ctx.recipes.isEmpty()) report.recipes = result.getRecipeReport().report;
120
+ if (includes("pattern") && !ctx.patterns.isEmpty()) report.patterns = result.getPatternReport();
121
+ if (includes("utility")) report.utilities = result.getUtilityReport();
122
+ if (includes("keyframe")) {
123
+ const keyframes = result.getKeyframeReport();
124
+ if (keyframes.length) report.keyframes = keyframes;
125
+ }
114
126
  return json(report);
115
127
  });
116
128
  return server;
117
129
  }
118
130
  /**
131
+ * Keep stdout to the protocol, and leave when the client has gone.
132
+ *
133
+ * Over stdio, stdout carries JSON-RPC and nothing else: a line printed there that is not a
134
+ * message corrupts the stream. `silent` quieted the logger, but loading the config sets its level
135
+ * from `logLevel` again, and `get_usage_report` then printed `Analyzing N file(s)` into it. The
136
+ * `console` methods that write to stdout now write to stderr, which a client shows as the server's
137
+ * log; the rest — `table`, `group`, `count` — print through `log`.
138
+ *
139
+ * A client that has gone leaves stdout without a reader, and a write to it fails with `EPIPE`.
140
+ * Unheard, that reached the handler `@bamboocss/node` installs for uncaught errors, which logged
141
+ * it — into a pipe without a reader, failing again — and kept the process alive doing so. Losing
142
+ * stderr alone is a client that stopped reading the log, which costs only the log.
143
+ */
144
+ let guarded = false;
145
+ function guardStdio() {
146
+ if (guarded) return;
147
+ guarded = true;
148
+ const toStderr = new node_console.Console({
149
+ stdout: process.stderr,
150
+ stderr: process.stderr
151
+ });
152
+ for (const method of [
153
+ "log",
154
+ "info",
155
+ "debug",
156
+ "dir"
157
+ ]) console[method] = toStderr[method].bind(toStderr);
158
+ const withoutReader = (error) => error.code === "EPIPE" || error.code === "ERR_STREAM_DESTROYED";
159
+ process.stdout.on("error", (error) => {
160
+ if (withoutReader(error)) process.exit(0);
161
+ throw error;
162
+ });
163
+ process.stderr.on("error", (error) => {
164
+ if (!withoutReader(error)) throw error;
165
+ });
166
+ }
167
+ /**
119
168
  * Start the MCP server with the given options.
120
169
  * By default, uses StdioServerTransport for CLI usage.
121
170
  */
122
171
  async function startMcpServer(options = {}) {
123
172
  const { cwd = process.cwd(), config: configPath, silent = false, transport } = options;
173
+ if (!transport) guardStdio();
124
174
  if (silent) _bamboocss_logger.logger.level = "silent";
125
- const resolvedCwd = (0, path.resolve)(cwd);
126
- const resolvedConfigPath = configPath ? (0, path.resolve)(configPath) : void 0;
175
+ const resolvedCwd = (0, node_path.resolve)(cwd);
176
+ const resolvedConfigPath = configPath ? (0, node_path.resolve)(configPath) : void 0;
127
177
  const server = createMcpServer({ ctx: await (0, _bamboocss_node.loadConfigAndCreateContext)({
128
178
  cwd: resolvedCwd,
129
179
  configPath: resolvedConfigPath
@@ -3,8 +3,12 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
3
3
  import { logger } from "@bamboocss/logger";
4
4
  import { analyze, loadConfigAndCreateContext } from "@bamboocss/node";
5
5
  import { TOKEN_CATEGORIES } from "@bamboocss/token-dictionary";
6
- import { resolve } from "path";
6
+ import { Console } from "node:console";
7
+ import { resolve } from "node:path";
7
8
  import * as z from "zod/v4";
9
+ //#region package.json
10
+ var version = "1.57.0";
11
+ //#endregion
8
12
  //#region src/server.ts
9
13
  const tokenCategorySchema = z.enum(TOKEN_CATEGORIES).optional().describe("Filter by token category");
10
14
  const json = (data) => ({ content: [{
@@ -19,7 +23,7 @@ function createMcpServer(options) {
19
23
  const { ctx } = options;
20
24
  const server = new McpServer({
21
25
  name: "@bamboocss/mcp",
22
- version: "1.0.0"
26
+ version
23
27
  });
24
28
  const recipeNames = ctx.recipes.keys;
25
29
  const patternNames = ctx.patterns.keys;
@@ -75,29 +79,75 @@ function createMcpServer(options) {
75
79
  server.registerTool("get_color_palette", { description: "Get the color palette with all color values" }, async () => json(ctx.getSpecOfType("color-palette")));
76
80
  server.registerTool("get_config", { description: "Get the resolved Bamboo CSS configuration including paths, JSX settings, and output options" }, async () => json(ctx.config));
77
81
  server.registerTool("get_usage_report", {
78
- description: "Get a usage report of design tokens and recipes across the codebase. Shows which tokens/recipes are used, unused, or missing. Useful for auditing, cleanup, and identifying dead code.",
82
+ description: "Get a usage report of the design system across the codebase: design tokens, recipes, patterns, utilities and keyframes. Shows which are used and how often, and which are defined but unused. Useful for auditing, cleanup, and identifying dead code.",
79
83
  inputSchema: { scope: z.enum([
80
84
  "all",
81
85
  "token",
82
- "recipe"
83
- ]).optional().describe("Analysis scope: token, recipe, or all (default)") }
86
+ "recipe",
87
+ "pattern",
88
+ "utility",
89
+ "keyframe"
90
+ ]).optional().describe("Analysis scope: token, recipe, pattern, utility, keyframe, or all (default)") }
84
91
  }, async ({ scope }) => {
85
92
  const result = await analyze(ctx);
86
- const includeTokens = !scope || scope === "all" || scope === "token";
87
- const includeRecipes = !scope || scope === "all" || scope === "recipe";
93
+ const includes = (part) => !scope || scope === "all" || scope === part;
88
94
  const report = {};
89
- if (includeTokens && !ctx.tokens.isEmpty) report.tokens = result.getTokenReport().report.getSummary();
90
- if (includeRecipes && !ctx.recipes.isEmpty()) report.recipes = result.getRecipeReport().report;
95
+ if (includes("token") && !ctx.tokens.isEmpty) report.tokens = result.getTokenReport().report.getSummary();
96
+ if (includes("recipe") && !ctx.recipes.isEmpty()) report.recipes = result.getRecipeReport().report;
97
+ if (includes("pattern") && !ctx.patterns.isEmpty()) report.patterns = result.getPatternReport();
98
+ if (includes("utility")) report.utilities = result.getUtilityReport();
99
+ if (includes("keyframe")) {
100
+ const keyframes = result.getKeyframeReport();
101
+ if (keyframes.length) report.keyframes = keyframes;
102
+ }
91
103
  return json(report);
92
104
  });
93
105
  return server;
94
106
  }
95
107
  /**
108
+ * Keep stdout to the protocol, and leave when the client has gone.
109
+ *
110
+ * Over stdio, stdout carries JSON-RPC and nothing else: a line printed there that is not a
111
+ * message corrupts the stream. `silent` quieted the logger, but loading the config sets its level
112
+ * from `logLevel` again, and `get_usage_report` then printed `Analyzing N file(s)` into it. The
113
+ * `console` methods that write to stdout now write to stderr, which a client shows as the server's
114
+ * log; the rest — `table`, `group`, `count` — print through `log`.
115
+ *
116
+ * A client that has gone leaves stdout without a reader, and a write to it fails with `EPIPE`.
117
+ * Unheard, that reached the handler `@bamboocss/node` installs for uncaught errors, which logged
118
+ * it — into a pipe without a reader, failing again — and kept the process alive doing so. Losing
119
+ * stderr alone is a client that stopped reading the log, which costs only the log.
120
+ */
121
+ let guarded = false;
122
+ function guardStdio() {
123
+ if (guarded) return;
124
+ guarded = true;
125
+ const toStderr = new Console({
126
+ stdout: process.stderr,
127
+ stderr: process.stderr
128
+ });
129
+ for (const method of [
130
+ "log",
131
+ "info",
132
+ "debug",
133
+ "dir"
134
+ ]) console[method] = toStderr[method].bind(toStderr);
135
+ const withoutReader = (error) => error.code === "EPIPE" || error.code === "ERR_STREAM_DESTROYED";
136
+ process.stdout.on("error", (error) => {
137
+ if (withoutReader(error)) process.exit(0);
138
+ throw error;
139
+ });
140
+ process.stderr.on("error", (error) => {
141
+ if (!withoutReader(error)) throw error;
142
+ });
143
+ }
144
+ /**
96
145
  * Start the MCP server with the given options.
97
146
  * By default, uses StdioServerTransport for CLI usage.
98
147
  */
99
148
  async function startMcpServer(options = {}) {
100
149
  const { cwd = process.cwd(), config: configPath, silent = false, transport } = options;
150
+ if (!transport) guardStdio();
101
151
  if (silent) logger.level = "silent";
102
152
  const resolvedCwd = resolve(cwd);
103
153
  const resolvedConfigPath = configPath ? resolve(configPath) : void 0;
package/dist/cli.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_cli = require("./cli-Dfrpr-kE.cjs");
2
+ const require_cli = require("./cli-DEyO83rZ.cjs");
3
3
  exports.parseArgs = require_cli.parseArgs;
4
4
  exports.runMcpCli = require_cli.runMcpCli;
package/dist/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as runMcpCli, t as parseArgs } from "./cli-a029tZ9j.mjs";
1
+ import { n as runMcpCli, t as parseArgs } from "./cli-DOyr6bHv.mjs";
2
2
  export { parseArgs, runMcpCli };
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_cli = require("./cli-Dfrpr-kE.cjs");
2
+ const require_cli = require("./cli-DEyO83rZ.cjs");
3
3
  exports.createMcpServer = require_cli.createMcpServer;
4
4
  exports.runMcpCli = require_cli.runMcpCli;
5
5
  exports.startMcpServer = require_cli.startMcpServer;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { i as startMcpServer, n as runMcpCli, r as createMcpServer } from "./cli-a029tZ9j.mjs";
1
+ import { i as startMcpServer, n as runMcpCli, r as createMcpServer } from "./cli-DOyr6bHv.mjs";
2
2
  export { createMcpServer, runMcpCli, startMcpServer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/mcp",
3
- "version": "1.56.7",
3
+ "version": "1.57.0",
4
4
  "description": "MCP server for Bamboo CSS AI assistants",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -40,10 +40,13 @@
40
40
  "dependencies": {
41
41
  "@modelcontextprotocol/sdk": "^1.29.0",
42
42
  "zod": "^4.0.0",
43
- "@bamboocss/logger": "1.56.7",
44
- "@bamboocss/node": "1.56.7",
45
- "@bamboocss/token-dictionary": "1.56.7",
46
- "@bamboocss/types": "1.56.7"
43
+ "@bamboocss/logger": "1.57.0",
44
+ "@bamboocss/node": "1.57.0",
45
+ "@bamboocss/token-dictionary": "1.57.0",
46
+ "@bamboocss/types": "1.57.0"
47
+ },
48
+ "engines": {
49
+ "node": ">=22.12.0"
47
50
  },
48
51
  "scripts": {
49
52
  "build": "tsdown src/index.ts src/cli.ts --format=esm,cjs",