wavemaker-dev-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WaveMaker Dev MCP contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # wavemaker-dev-mcp
2
+
3
+ An MCP (Model Context Protocol) server that exposes **read-only** tools to search and read:
4
+
5
+ - **`@wavemaker/react-runtime`** — component sources, `props.js` / `props.ts`, and references to widget names
6
+ - **`@wavemaker/foundation-css`** or **`@wavemaker-ai/foundation-css`** — tokens, LESS, and CSS
7
+
8
+ There are **no embeddings** and **no vector DB**. Search uses [ripgrep](https://github.com/BurntSushi/ripgrep) when available, with a Node.js fallback.
9
+
10
+ ## Requirements
11
+
12
+ - Node.js 18+
13
+ - A project that installs `@wavemaker/react-runtime` and (optionally) `@wavemaker/foundation-css` under `node_modules`
14
+ - Optional: `rg` on `PATH` for faster search
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ git clone <your-repo-url> wavemaker-dev-mcp
20
+ cd wavemaker-dev-mcp
21
+ npm install
22
+ npm run build
23
+ ```
24
+
25
+ The published npm package includes `dist/`; a git clone must run `npm run build` before using `dist/index.js` in MCP config.
26
+
27
+ ## Local testing (MCP Inspector)
28
+
29
+ Use [@modelcontextprotocol/inspector](https://www.npmjs.com/package/@modelcontextprotocol/inspector) to exercise the server in a browser. The inspector expects **Node.js ≥ 22.7.5**.
30
+
31
+ From this repository root (after `npm run build` so `dist/index.js` exists):
32
+
33
+ ```bash
34
+ npx @modelcontextprotocol/inspector --config mcp.json --server wavemaker-dev
35
+ ```
36
+
37
+ If `mcp.json` defines only this server, `--server wavemaker-dev` may be omitted. Open the UI URL printed in the terminal (default **http://localhost:6274**). When prompted, use the session token from the console to authenticate to the proxy.
38
+
39
+ Point the server at your WaveMaker app or source clones by adding an `env` block to the `wavemaker-dev` entry in `mcp.json` (see **Environment variables** below), or set variables in your shell before the `npx` command.
40
+
41
+ ## Environment variables
42
+
43
+ | Variable | Purpose |
44
+ |----------|---------|
45
+ | `WM_PROJECT_ROOT` | App root (directory containing `node_modules`). Used when the MCP process `cwd` is not your app. Overridden by the `workingDirectory` tool argument when set. |
46
+ | `WM_REACT_RUNTIME_ROOT` | Absolute path to `@wavemaker/react-runtime` (skips `node_modules` lookup). |
47
+ | `WM_FOUNDATION_CSS_ROOT` | Absolute path to the foundation-css package root. |
48
+
49
+ ## Tools
50
+
51
+ | Tool | Description |
52
+ |------|-------------|
53
+ | `get_wavemaker_roots` | Show resolved paths for react-runtime and foundation-css. |
54
+ | `search_wavemaker_runtime` | Search inside the react-runtime package (`pattern`, optional `fileGlob`, `maxResults`). |
55
+ | `read_wavemaker_runtime_file` | Read a file relative to that package (e.g. `components/input/select/props.js`). |
56
+ | `search_foundation_css` | Search inside foundation-css. |
57
+ | `read_foundation_css_file` | Read a file relative to foundation-css. |
58
+ | `find_wavemaker_component` | Given a name like `WmSelect` or `select`, list matching `props` paths and sample references under `components/`. |
59
+
60
+ ## Cursor
61
+
62
+ Add a **global** or **project** MCP config so the server runs with **`cwd` set to your WaveMaker app** (the folder that contains `node_modules`).
63
+
64
+ Example (adjust absolute paths):
65
+
66
+ ```json
67
+ {
68
+ "mcpServers": {
69
+ "wavemaker-dev": {
70
+ "command": "node",
71
+ "args": ["/path/to/wavemaker-dev-mcp/dist/index.js"],
72
+ "cwd": "/path/to/your-wm-react-app"
73
+ }
74
+ }
75
+ }
76
+ ```
77
+
78
+ If you cannot set `cwd`, set `WM_PROJECT_ROOT` to your app root (e.g. `env` in the MCP server entry, if your client supports it).
79
+
80
+ After publishing to npm, you can use:
81
+
82
+ ```json
83
+ {
84
+ "mcpServers": {
85
+ "wavemaker-dev": {
86
+ "command": "npx",
87
+ "args": ["-y", "wavemaker-dev-mcp"],
88
+ "cwd": "/path/to/your-wm-react-app"
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ ## Tests (Playwright)
95
+
96
+ Integration tests spawn the server over stdio with the official MCP client and call tools. They expect a WaveMaker app at `../wm-react-base-app` (sibling directory) or set **`WM_TEST_APP_ROOT`** to an app root that contains `node_modules/@wavemaker/react-runtime`.
97
+
98
+ ```bash
99
+ npm run build
100
+ npm test
101
+ ```
102
+
103
+ ## License
104
+
105
+ MIT
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Strip leading `Wm` and lowercase (e.g. WmSelect -> select).
3
+ */
4
+ export declare function normalizeComponentQuery(name: string): string;
5
+ /**
6
+ * Build a likely `Wm*` name from user input (`select` -> `WmSelect`, `WmButton` -> `WmButton`).
7
+ */
8
+ export declare function toWmComponentName(input: string): string;
9
+ /**
10
+ * Find props files under `.../components` whose path likely matches the widget (e.g. `.../select/props.js`).
11
+ */
12
+ export declare function findPropsPathsByHint(runtimeRoot: string, hint: string): Promise<string[]>;
13
+ /**
14
+ * Find references to a component name in source (fallback when path hint fails).
15
+ */
16
+ export declare function findComponentRefs(runtimeRoot: string, componentName: string, maxResults: number): Promise<import("./search.js").ContentMatch[]>;
17
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAgB/F;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iDAOrG"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.normalizeComponentQuery = normalizeComponentQuery;
7
+ exports.toWmComponentName = toWmComponentName;
8
+ exports.findPropsPathsByHint = findPropsPathsByHint;
9
+ exports.findComponentRefs = findComponentRefs;
10
+ const node_path_1 = __importDefault(require("node:path"));
11
+ const fast_glob_1 = __importDefault(require("fast-glob"));
12
+ const paths_js_1 = require("./paths.js");
13
+ const search_js_1 = require("./search.js");
14
+ /**
15
+ * Strip leading `Wm` and lowercase (e.g. WmSelect -> select).
16
+ */
17
+ function normalizeComponentQuery(name) {
18
+ let s = name.trim();
19
+ if (s.startsWith("Wm"))
20
+ s = s.slice(2);
21
+ return s.toLowerCase();
22
+ }
23
+ /**
24
+ * Build a likely `Wm*` name from user input (`select` -> `WmSelect`, `WmButton` -> `WmButton`).
25
+ */
26
+ function toWmComponentName(input) {
27
+ const s = input.trim().replace(/^Wm/i, "");
28
+ if (!s)
29
+ return input.trim();
30
+ const pascal = s.charAt(0).toUpperCase() + s.slice(1);
31
+ return `Wm${pascal}`;
32
+ }
33
+ /**
34
+ * Find props files under `.../components` whose path likely matches the widget (e.g. `.../select/props.js`).
35
+ */
36
+ async function findPropsPathsByHint(runtimeRoot, hint) {
37
+ const key = normalizeComponentQuery(hint);
38
+ if (!key)
39
+ return [];
40
+ const componentsRoot = (0, paths_js_1.resolveRuntimeComponentsRoot)(runtimeRoot);
41
+ const files = await (0, fast_glob_1.default)("**/props.{js,ts}", {
42
+ cwd: componentsRoot,
43
+ onlyFiles: true,
44
+ dot: false,
45
+ });
46
+ const matches = files.filter((f) => {
47
+ const lower = f.toLowerCase();
48
+ return lower.includes(`/${key}/`) || lower.includes(`/${key}.`) || lower.startsWith(`${key}/`);
49
+ });
50
+ return matches
51
+ .map((f) => node_path_1.default.relative(runtimeRoot, node_path_1.default.join(componentsRoot, f)).replace(/\\/g, "/"))
52
+ .sort();
53
+ }
54
+ /**
55
+ * Find references to a component name in source (fallback when path hint fails).
56
+ */
57
+ async function findComponentRefs(runtimeRoot, componentName, maxResults) {
58
+ const pattern = componentName.trim();
59
+ if (!pattern)
60
+ return [];
61
+ const componentsRoot = (0, paths_js_1.resolveRuntimeComponentsRoot)(runtimeRoot);
62
+ const rg = (0, search_js_1.searchWithRipgrep)(componentsRoot, pattern, maxResults);
63
+ if (rg !== null)
64
+ return rg;
65
+ return (0, search_js_1.searchWithNode)(componentsRoot, pattern, maxResults, "**/*.{js,ts,tsx,jsx}");
66
+ }
67
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":";;;;;AAQA,0DAIC;AAKD,8CAKC;AAKD,oDAgBC;AAKD,8CAOC;AAvDD,0DAA6B;AAC7B,0DAA2B;AAC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AG,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IACjG,CAAC,CAAC,CAAC;IACH,OAAO,OAAO;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,mBAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SACxF,IAAI,EAAE,CAAC;AACZ,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,iBAAiB,CAAC,WAAmB,EAAE,aAAqB,EAAE,UAAkB;IACpG,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;IACrC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,MAAM,cAAc,GAAG,IAAA,uCAA4B,EAAC,WAAW,CAAC,CAAC;IACjE,MAAM,EAAE,GAAG,IAAA,6BAAiB,EAAC,cAAc,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAClE,IAAI,EAAE,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAC3B,OAAO,IAAA,0BAAc,EAAC,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC;AACrF,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,217 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
9
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
10
+ const zod_1 = require("zod");
11
+ const components_js_1 = require("./components.js");
12
+ const paths_js_1 = require("./paths.js");
13
+ const search_js_1 = require("./search.js");
14
+ function resolveProjectRoot(workingDirectory) {
15
+ return workingDirectory ?? process.env.WM_PROJECT_ROOT?.trim() ?? process.cwd();
16
+ }
17
+ const MAX_READ_BYTES = 512 * 1024;
18
+ const MAX_LINES_PREVIEW = 400;
19
+ function readFileSlice(absolute, startLine, endLine) {
20
+ const buf = node_fs_1.default.readFileSync(absolute);
21
+ let text = buf.length > MAX_READ_BYTES ? buf.subarray(0, MAX_READ_BYTES).toString("utf8") : buf.toString("utf8");
22
+ let truncated = buf.length > MAX_READ_BYTES;
23
+ const lines = text.split(/\r?\n/);
24
+ if (startLine !== undefined || endLine !== undefined) {
25
+ const start = Math.max(1, startLine ?? 1) - 1;
26
+ const end = endLine === undefined ? lines.length : Math.min(lines.length, endLine);
27
+ const slice = lines.slice(start, end);
28
+ if (slice.length > MAX_LINES_PREVIEW) {
29
+ truncated = true;
30
+ return { text: slice.slice(0, MAX_LINES_PREVIEW).join("\n"), truncated };
31
+ }
32
+ return { text: slice.join("\n"), truncated };
33
+ }
34
+ if (lines.length > MAX_LINES_PREVIEW) {
35
+ return { text: lines.slice(0, MAX_LINES_PREVIEW).join("\n"), truncated: true };
36
+ }
37
+ return { text, truncated };
38
+ }
39
+ const workingDirSchema = zod_1.z
40
+ .string()
41
+ .optional()
42
+ .describe("Project root (directory containing node_modules). Defaults to process.cwd(). Set when the MCP process cwd is not your app root.");
43
+ async function main() {
44
+ const mcp = new mcp_js_1.McpServer({
45
+ name: "wavemaker-dev-mcp",
46
+ version: "0.1.0",
47
+ title: "WaveMaker React & Foundation CSS",
48
+ });
49
+ mcp.registerTool("get_wavemaker_roots", {
50
+ title: "Resolve WaveMaker package paths",
51
+ description: "Returns resolved paths for react-runtime and foundation-css. Resolution order: WM_*_SOURCE (local clone) → WM_*_ROOT → node_modules. Call this first if searches fail.",
52
+ inputSchema: { workingDirectory: workingDirSchema },
53
+ }, async ({ workingDirectory }) => {
54
+ const roots = (0, paths_js_1.resolveRoots)(resolveProjectRoot(workingDirectory));
55
+ const lines = [
56
+ `projectRoot: ${roots.projectRoot}`,
57
+ roots.reactRuntime
58
+ ? `reactRuntime: ${roots.reactRuntime.path} [${roots.reactRuntime.resolution}]`
59
+ : "reactRuntime: NOT FOUND (set WM_REACT_RUNTIME_SOURCE or WM_REACT_RUNTIME_ROOT, or install @wavemaker/react-runtime under node_modules)",
60
+ roots.foundationCss
61
+ ? `foundationCss: ${roots.foundationCss.path} [${roots.foundationCss.resolution}, ${roots.foundationCss.packageName}]`
62
+ : "foundationCss: NOT FOUND (set WM_FOUNDATION_CSS_SOURCE or WM_FOUNDATION_CSS_ROOT, or install @wavemaker/foundation-css under node_modules)",
63
+ ];
64
+ return { content: [{ type: "text", text: lines.join("\n") }] };
65
+ });
66
+ mcp.registerTool("search_wavemaker_runtime", {
67
+ title: "Search @wavemaker/react-runtime sources",
68
+ description: "Ripgrep (or Node fallback) over the installed react-runtime package for symbols, props, or text. Use fileGlob like **/*.js or **/props.js to narrow scope.",
69
+ inputSchema: {
70
+ pattern: zod_1.z.string().describe("Regular expression or literal (Node fallback escapes if invalid regex)."),
71
+ maxResults: zod_1.z.number().optional().describe("Max matches (default 40)."),
72
+ fileGlob: zod_1.z.string().optional().describe("Optional glob relative to package root, e.g. **/props.js"),
73
+ workingDirectory: workingDirSchema,
74
+ },
75
+ }, async ({ pattern, maxResults, fileGlob, workingDirectory }) => {
76
+ const roots = (0, paths_js_1.resolveRoots)(resolveProjectRoot(workingDirectory));
77
+ if (!roots.reactRuntime) {
78
+ return {
79
+ isError: true,
80
+ content: [{ type: "text", text: "react-runtime not found. Run get_wavemaker_roots or install @wavemaker/react-runtime." }],
81
+ };
82
+ }
83
+ const max = Math.min(200, Math.max(1, maxResults ?? 40));
84
+ const root = roots.reactRuntime.path;
85
+ let matches = (0, search_js_1.searchWithRipgrep)(root, pattern, max, fileGlob);
86
+ if (matches === null) {
87
+ matches = await (0, search_js_1.searchWithNode)(root, pattern, max, fileGlob);
88
+ }
89
+ return { content: [{ type: "text", text: (0, search_js_1.formatMatches)("react-runtime", root, matches) }] };
90
+ });
91
+ mcp.registerTool("read_wavemaker_runtime_file", {
92
+ title: "Read a file under @wavemaker/react-runtime",
93
+ description: "Read a file from the resolved react-runtime root (published package or local clone). Use components/... for npm installs or src/components/... when using WM_REACT_RUNTIME_SOURCE.",
94
+ inputSchema: {
95
+ relativePath: zod_1.z
96
+ .string()
97
+ .describe("Path under react-runtime root, e.g. components/input/select/props.js or src/components/input/select/props.ts"),
98
+ startLine: zod_1.z.number().optional().describe("1-based start line (optional)."),
99
+ endLine: zod_1.z.number().optional().describe("1-based end line inclusive (optional)."),
100
+ workingDirectory: workingDirSchema,
101
+ },
102
+ }, async ({ relativePath, startLine, endLine, workingDirectory }) => {
103
+ const roots = (0, paths_js_1.resolveRoots)(resolveProjectRoot(workingDirectory));
104
+ if (!roots.reactRuntime) {
105
+ return {
106
+ isError: true,
107
+ content: [{ type: "text", text: "react-runtime not found." }],
108
+ };
109
+ }
110
+ const check = (0, paths_js_1.safeReadUnderRoot)(roots.reactRuntime.path, relativePath);
111
+ if (!check.ok) {
112
+ return { isError: true, content: [{ type: "text", text: check.error }] };
113
+ }
114
+ if (!node_fs_1.default.existsSync(check.absolute) || !node_fs_1.default.statSync(check.absolute).isFile()) {
115
+ return { isError: true, content: [{ type: "text", text: `Not a file: ${relativePath}` }] };
116
+ }
117
+ const { text, truncated } = readFileSlice(check.absolute, startLine, endLine);
118
+ const header = `${check.absolute}${truncated ? "\n[truncated]" : ""}\n\n`;
119
+ return { content: [{ type: "text", text: header + text }] };
120
+ });
121
+ mcp.registerTool("search_foundation_css", {
122
+ title: "Search @wavemaker/foundation-css (or @wavemaker-ai/foundation-css)",
123
+ description: "Search tokens, LESS, and CSS under the foundation-css package for variables, classes, or snippets.",
124
+ inputSchema: {
125
+ pattern: zod_1.z.string(),
126
+ maxResults: zod_1.z.number().optional(),
127
+ fileGlob: zod_1.z.string().optional(),
128
+ workingDirectory: workingDirSchema,
129
+ },
130
+ }, async ({ pattern, maxResults, fileGlob, workingDirectory }) => {
131
+ const roots = (0, paths_js_1.resolveRoots)(resolveProjectRoot(workingDirectory));
132
+ if (!roots.foundationCss) {
133
+ return {
134
+ isError: true,
135
+ content: [
136
+ {
137
+ type: "text",
138
+ text: "foundation-css not found. Install @wavemaker/foundation-css or set WM_FOUNDATION_CSS_ROOT.",
139
+ },
140
+ ],
141
+ };
142
+ }
143
+ const max = Math.min(200, Math.max(1, maxResults ?? 40));
144
+ const root = roots.foundationCss.path;
145
+ let matches = (0, search_js_1.searchWithRipgrep)(root, pattern, max, fileGlob);
146
+ if (matches === null) {
147
+ matches = await (0, search_js_1.searchWithNode)(root, pattern, max, fileGlob);
148
+ }
149
+ return { content: [{ type: "text", text: (0, search_js_1.formatMatches)("foundation-css", root, matches) }] };
150
+ });
151
+ mcp.registerTool("read_foundation_css_file", {
152
+ title: "Read a file under foundation-css",
153
+ description: "Read a file from the foundation-css package (tokens, LESS, CSS). Path is relative to package root.",
154
+ inputSchema: {
155
+ relativePath: zod_1.z.string(),
156
+ startLine: zod_1.z.number().optional(),
157
+ endLine: zod_1.z.number().optional(),
158
+ workingDirectory: workingDirSchema,
159
+ },
160
+ }, async ({ relativePath, startLine, endLine, workingDirectory }) => {
161
+ const roots = (0, paths_js_1.resolveRoots)(resolveProjectRoot(workingDirectory));
162
+ if (!roots.foundationCss) {
163
+ return {
164
+ isError: true,
165
+ content: [{ type: "text", text: "foundation-css not found." }],
166
+ };
167
+ }
168
+ const check = (0, paths_js_1.safeReadUnderRoot)(roots.foundationCss.path, relativePath);
169
+ if (!check.ok) {
170
+ return { isError: true, content: [{ type: "text", text: check.error }] };
171
+ }
172
+ if (!node_fs_1.default.existsSync(check.absolute) || !node_fs_1.default.statSync(check.absolute).isFile()) {
173
+ return { isError: true, content: [{ type: "text", text: `Not a file: ${relativePath}` }] };
174
+ }
175
+ const { text, truncated } = readFileSlice(check.absolute, startLine, endLine);
176
+ const header = `${check.absolute}${truncated ? "\n[truncated]" : ""}\n\n`;
177
+ return { content: [{ type: "text", text: header + text }] };
178
+ });
179
+ mcp.registerTool("find_wavemaker_component", {
180
+ title: "Find props / paths for a WaveMaker widget",
181
+ description: "Given a widget name like WmSelect or WmButton, list matching props.js/ts paths under components/, and optionally search for the name in source when path matching is ambiguous (e.g. charts).",
182
+ inputSchema: {
183
+ componentName: zod_1.z.string().describe('e.g. "WmSelect", "WmBarChart", or "select"'),
184
+ workingDirectory: workingDirSchema,
185
+ },
186
+ }, async ({ componentName, workingDirectory }) => {
187
+ const roots = (0, paths_js_1.resolveRoots)(resolveProjectRoot(workingDirectory));
188
+ if (!roots.reactRuntime) {
189
+ return {
190
+ isError: true,
191
+ content: [{ type: "text", text: "react-runtime not found." }],
192
+ };
193
+ }
194
+ const root = roots.reactRuntime.path;
195
+ const hints = await (0, components_js_1.findPropsPathsByHint)(root, componentName);
196
+ const wmName = (0, components_js_1.toWmComponentName)(componentName);
197
+ const refs = await (0, components_js_1.findComponentRefs)(root, wmName, 20);
198
+ const lines = [
199
+ `react-runtime: ${root}`,
200
+ `normalized name for source search: ${wmName}`,
201
+ "",
202
+ "Props files matching path hint (components/**/props.*):",
203
+ hints.length ? hints.map((p) => ` ${p}`).join("\n") : " (none — charts and some widgets use non-obvious folder names; use refs below or search_wavemaker_runtime)",
204
+ "",
205
+ `References to "${wmName}" under components/ (sample):`,
206
+ refs.length ? (0, search_js_1.formatMatches)("refs", (0, paths_js_1.resolveRuntimeComponentsRoot)(root), refs) : " (none)",
207
+ ];
208
+ return { content: [{ type: "text", text: lines.join("\n") }] };
209
+ });
210
+ const transport = new stdio_js_1.StdioServerTransport();
211
+ await mcp.connect(transport);
212
+ }
213
+ main().catch((err) => {
214
+ console.error(err);
215
+ process.exit(1);
216
+ });
217
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,sDAAyB;AACzB,oEAAoE;AACpE,wEAAiF;AACjF,6BAAwB;AACxB,mDAA6F;AAC7F,yCAA2F;AAC3F,2CAA+E;AAE/E,SAAS,kBAAkB,CAAC,gBAAyB;IACnD,OAAO,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;AAClF,CAAC;AAED,MAAM,cAAc,GAAG,GAAG,GAAG,IAAI,CAAC;AAClC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,SAAS,aAAa,CAAC,QAAgB,EAAE,SAAkB,EAAE,OAAgB;IAC3E,MAAM,GAAG,GAAG,iBAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,IAAI,GAAG,GAAG,CAAC,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjH,IAAI,SAAS,GAAG,GAAG,CAAC,MAAM,GAAG,cAAc,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,SAAS,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACrD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,GAAG,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC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AC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,43 @@
1
+ export declare function existsDir(p: string): boolean;
2
+ /**
3
+ * How the react-runtime root was chosen (first match wins).
4
+ */
5
+ export type ReactRuntimeResolution = "WM_REACT_RUNTIME_SOURCE" | "WM_REACT_RUNTIME_ROOT" | `node_modules:${string}`;
6
+ /**
7
+ * How the foundation-css root was chosen (first match wins).
8
+ */
9
+ export type FoundationResolution = "WM_FOUNDATION_CSS_SOURCE" | "WM_FOUNDATION_CSS_ROOT" | `node_modules:${string}`;
10
+ export type ResolvedRoots = {
11
+ projectRoot: string;
12
+ reactRuntime: {
13
+ path: string;
14
+ resolution: ReactRuntimeResolution;
15
+ } | null;
16
+ foundationCss: {
17
+ path: string;
18
+ resolution: FoundationResolution;
19
+ packageName: string;
20
+ } | null;
21
+ };
22
+ /**
23
+ * Prefer local source clones, then explicit package roots, then node_modules.
24
+ *
25
+ * React runtime: `WM_REACT_RUNTIME_SOURCE` → `WM_REACT_RUNTIME_ROOT` → `node_modules/@wavemaker/react-runtime`
26
+ * Foundation: `WM_FOUNDATION_CSS_SOURCE` → `WM_FOUNDATION_CSS_ROOT` → `node_modules` packages
27
+ */
28
+ export declare function resolveRoots(cwd?: string): ResolvedRoots;
29
+ /**
30
+ * Local react-runtime repos often use `src/components`; published packages use `components`.
31
+ */
32
+ export declare function resolveRuntimeComponentsRoot(runtimeRoot: string): string;
33
+ /**
34
+ * Ensure `relativePath` resolves under `root` (no traversal).
35
+ */
36
+ export declare function safeReadUnderRoot(root: string, relativePath: string): {
37
+ ok: true;
38
+ absolute: string;
39
+ } | {
40
+ ok: false;
41
+ error: string;
42
+ };
43
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAMA,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAM5C;AAQD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAC9B,yBAAyB,GACzB,uBAAuB,GACvB,gBAAgB,MAAM,EAAE,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,GAAG,wBAAwB,GAAG,gBAAgB,MAAM,EAAE,CAAC;AAEpH,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,sBAAsB,CAAA;KAAE,GAAG,IAAI,CAAC;IAC1E,aAAa,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,oBAAoB,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAC/F,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,SAAgB,GAAG,aAAa,CA6C/D;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAIxE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAQnI"}
package/dist/paths.js ADDED
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.existsDir = existsDir;
7
+ exports.resolveRoots = resolveRoots;
8
+ exports.resolveRuntimeComponentsRoot = resolveRuntimeComponentsRoot;
9
+ exports.safeReadUnderRoot = safeReadUnderRoot;
10
+ const node_fs_1 = __importDefault(require("node:fs"));
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const RUNTIME_PKG = "@wavemaker/react-runtime";
13
+ const FOUNDATION_CANDIDATES = ["@wavemaker/foundation-css", "@wavemaker-ai/foundation-css"];
14
+ function existsDir(p) {
15
+ try {
16
+ return node_fs_1.default.statSync(p).isDirectory();
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ }
22
+ function resolvePackageDir(projectRoot, packageName) {
23
+ const nested = node_path_1.default.join(projectRoot, "node_modules", packageName);
24
+ if (existsDir(nested))
25
+ return nested;
26
+ return null;
27
+ }
28
+ /**
29
+ * Prefer local source clones, then explicit package roots, then node_modules.
30
+ *
31
+ * React runtime: `WM_REACT_RUNTIME_SOURCE` → `WM_REACT_RUNTIME_ROOT` → `node_modules/@wavemaker/react-runtime`
32
+ * Foundation: `WM_FOUNDATION_CSS_SOURCE` → `WM_FOUNDATION_CSS_ROOT` → `node_modules` packages
33
+ */
34
+ function resolveRoots(cwd = process.cwd()) {
35
+ const projectRoot = cwd;
36
+ let reactRuntime = null;
37
+ const srcRt = process.env.WM_REACT_RUNTIME_SOURCE?.trim();
38
+ if (srcRt && existsDir(srcRt)) {
39
+ reactRuntime = { path: node_path_1.default.resolve(srcRt), resolution: "WM_REACT_RUNTIME_SOURCE" };
40
+ }
41
+ else {
42
+ const envRt = process.env.WM_REACT_RUNTIME_ROOT?.trim();
43
+ if (envRt && existsDir(envRt)) {
44
+ reactRuntime = { path: node_path_1.default.resolve(envRt), resolution: "WM_REACT_RUNTIME_ROOT" };
45
+ }
46
+ else {
47
+ const d = resolvePackageDir(projectRoot, RUNTIME_PKG);
48
+ if (d)
49
+ reactRuntime = { path: d, resolution: `node_modules:${RUNTIME_PKG}` };
50
+ }
51
+ }
52
+ let foundationCss = null;
53
+ const srcFd = process.env.WM_FOUNDATION_CSS_SOURCE?.trim();
54
+ if (srcFd && existsDir(srcFd)) {
55
+ foundationCss = {
56
+ path: node_path_1.default.resolve(srcFd),
57
+ resolution: "WM_FOUNDATION_CSS_SOURCE",
58
+ packageName: "(WM_FOUNDATION_CSS_SOURCE)",
59
+ };
60
+ }
61
+ else {
62
+ const envFd = process.env.WM_FOUNDATION_CSS_ROOT?.trim();
63
+ if (envFd && existsDir(envFd)) {
64
+ foundationCss = {
65
+ path: node_path_1.default.resolve(envFd),
66
+ resolution: "WM_FOUNDATION_CSS_ROOT",
67
+ packageName: "(WM_FOUNDATION_CSS_ROOT)",
68
+ };
69
+ }
70
+ else {
71
+ for (const name of FOUNDATION_CANDIDATES) {
72
+ const d = resolvePackageDir(projectRoot, name);
73
+ if (d) {
74
+ foundationCss = { path: d, resolution: `node_modules:${name}`, packageName: name };
75
+ break;
76
+ }
77
+ }
78
+ }
79
+ }
80
+ return { projectRoot, reactRuntime, foundationCss };
81
+ }
82
+ /**
83
+ * Local react-runtime repos often use `src/components`; published packages use `components`.
84
+ */
85
+ function resolveRuntimeComponentsRoot(runtimeRoot) {
86
+ const srcComponents = node_path_1.default.join(runtimeRoot, "src", "components");
87
+ if (existsDir(srcComponents))
88
+ return srcComponents;
89
+ return node_path_1.default.join(runtimeRoot, "components");
90
+ }
91
+ /**
92
+ * Ensure `relativePath` resolves under `root` (no traversal).
93
+ */
94
+ function safeReadUnderRoot(root, relativePath) {
95
+ const absRoot = node_path_1.default.resolve(root);
96
+ const joined = node_path_1.default.resolve(absRoot, relativePath);
97
+ const rel = node_path_1.default.relative(absRoot, joined);
98
+ if (rel.startsWith("..") || node_path_1.default.isAbsolute(rel)) {
99
+ return { ok: false, error: "Path escapes root directory" };
100
+ }
101
+ return { ok: true, absolute: joined };
102
+ }
103
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":";;;;;AAMA,8BAMC;AAiCD,oCA6CC;AAKD,oEAIC;AAKD,8CAQC;AAhHD,sDAAyB;AACzB,0DAA6B;AAE7B,MAAM,WA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AC;AACtD,CAAC;AAED;;GAEG;AACH,SAAgB,4BAA4B,CAAC,WAAmB;IAC9D,MAAM,aAAa,GAAG,mBAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IAClE,IAAI,SAAS,CAAC,aAAa,CAAC;QAAE,OAAO,aAAa,CAAC;IACnD,OAAO,mBAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,IAAY,EAAE,YAAoB;IAClE,MAAM,OAAO,GAAG,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,mBAAI,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnD,MAAM,GAAG,GAAG,mBAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3C,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,mBAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACjD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,6BAA6B,EAAE,CAAC;IAC7D,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1,15 @@
1
+ export type ContentMatch = {
2
+ file: string;
3
+ line: number;
4
+ text: string;
5
+ };
6
+ /**
7
+ * Try ripgrep for fast search; returns null if rg is missing or errors.
8
+ */
9
+ export declare function searchWithRipgrep(root: string, pattern: string, maxResults: number, pathGlob?: string): ContentMatch[] | null;
10
+ /**
11
+ * Slow path: walk files under root and scan line-by-line.
12
+ */
13
+ export declare function searchWithNode(root: string, pattern: string, maxResults: number, pathGlob?: string): Promise<ContentMatch[]>;
14
+ export declare function formatMatches(rootLabel: string, rootPath: string, matches: ContentMatch[]): string;
15
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAuBF;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,GAChB,YAAY,EAAE,GAAG,IAAI,CAmBvB;AAuBD;;GAEG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,EAAE,CAAC,CAsCzB;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,CAMlG"}
package/dist/search.js ADDED
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.searchWithRipgrep = searchWithRipgrep;
7
+ exports.searchWithNode = searchWithNode;
8
+ exports.formatMatches = formatMatches;
9
+ const node_child_process_1 = require("node:child_process");
10
+ const node_fs_1 = __importDefault(require("node:fs"));
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const fast_glob_1 = __importDefault(require("fast-glob"));
13
+ const TEXT_EXTENSIONS = new Set([
14
+ ".ts",
15
+ ".tsx",
16
+ ".js",
17
+ ".jsx",
18
+ ".mjs",
19
+ ".cjs",
20
+ ".json",
21
+ ".md",
22
+ ".less",
23
+ ".css",
24
+ ".scss",
25
+ ".svg",
26
+ ".html",
27
+ ]);
28
+ function isTextish(file) {
29
+ const ext = file.slice(file.lastIndexOf("."));
30
+ return TEXT_EXTENSIONS.has(ext.toLowerCase()) || !ext.includes(".");
31
+ }
32
+ /**
33
+ * Try ripgrep for fast search; returns null if rg is missing or errors.
34
+ */
35
+ function searchWithRipgrep(root, pattern, maxResults, pathGlob) {
36
+ const args = ["--line-number", "--no-heading", "--smart-case"];
37
+ if (pathGlob && pathGlob.length > 0) {
38
+ args.push("--glob", pathGlob);
39
+ }
40
+ args.push(pattern, root);
41
+ try {
42
+ const out = (0, node_child_process_1.execFileSync)("rg", args, {
43
+ encoding: "utf8",
44
+ maxBuffer: 32 * 1024 * 1024,
45
+ });
46
+ return parseRgOutput(out, root, maxResults);
47
+ }
48
+ catch (e) {
49
+ const err = e;
50
+ if (err.status === 1 && typeof err.stdout === "string") {
51
+ return parseRgOutput(err.stdout, root, maxResults);
52
+ }
53
+ return null;
54
+ }
55
+ }
56
+ function parseRgOutput(out, root, maxResults) {
57
+ const lines = out.split(/\r?\n/).filter(Boolean);
58
+ const matches = [];
59
+ const absRoot = node_path_1.default.resolve(root);
60
+ for (const line of lines) {
61
+ const m = /^(.+?):(\d+):(.*)$/.exec(line);
62
+ if (!m)
63
+ continue;
64
+ let filePath = m[1];
65
+ const absFile = node_path_1.default.resolve(filePath);
66
+ filePath = node_path_1.default.relative(absRoot, absFile).replace(/\\/g, "/");
67
+ if (filePath.startsWith(".."))
68
+ continue;
69
+ matches.push({
70
+ file: filePath,
71
+ line: Number(m[2]),
72
+ text: m[3],
73
+ });
74
+ if (matches.length >= maxResults)
75
+ break;
76
+ }
77
+ return matches;
78
+ }
79
+ /**
80
+ * Slow path: walk files under root and scan line-by-line.
81
+ */
82
+ async function searchWithNode(root, pattern, maxResults, pathGlob) {
83
+ const globPat = pathGlob && pathGlob.length > 0 ? pathGlob : "**/*";
84
+ const files = await (0, fast_glob_1.default)(globPat, {
85
+ cwd: root,
86
+ onlyFiles: true,
87
+ dot: false,
88
+ ignore: ["**/node_modules/**"],
89
+ followSymbolicLinks: false,
90
+ });
91
+ let regex;
92
+ try {
93
+ regex = new RegExp(pattern, "i");
94
+ }
95
+ catch {
96
+ regex = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "i");
97
+ }
98
+ const matches = [];
99
+ const maxFiles = 4000;
100
+ for (let i = 0; i < files.length && i < maxFiles; i++) {
101
+ const rel = files[i];
102
+ if (!isTextish(rel))
103
+ continue;
104
+ const full = `${root}/${rel}`.replace(/\\/g, "/");
105
+ let content;
106
+ try {
107
+ content = node_fs_1.default.readFileSync(full, "utf8");
108
+ }
109
+ catch {
110
+ continue;
111
+ }
112
+ const lines = content.split(/\r?\n/);
113
+ for (let li = 0; li < lines.length; li++) {
114
+ if (regex.test(lines[li])) {
115
+ matches.push({ file: rel.replace(/\\/g, "/"), line: li + 1, text: lines[li] });
116
+ if (matches.length >= maxResults)
117
+ return matches;
118
+ }
119
+ }
120
+ }
121
+ return matches;
122
+ }
123
+ function formatMatches(rootLabel, rootPath, matches) {
124
+ if (matches.length === 0) {
125
+ return `No matches in ${rootLabel} (${rootPath}).`;
126
+ }
127
+ const lines = matches.map((m) => `${m.file}:${m.line}: ${m.text}`);
128
+ return [`${rootLabel} (${rootPath})`, "", ...lines].join("\n");
129
+ }
130
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.js","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":";;;;;AAmCA,8CAwBC;AA0BD,wCA2CC;AAED,sCAMC;AAxID,2DAAkD;AAClD,sDAAyB;AACzB,0DAA6B;AAC7B,0DAA2B;AAQ3B,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,KAAK;IACL,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,O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gBAC1B,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC/E,IAAI,OAAO,CAAC,MAAM,IAAI,UAAU;oBAAE,OAAO,OAAO,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAgB,aAAa,CAAC,SAAiB,EAAE,QAAgB,EAAE,OAAuB;IACxF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,iBAAiB,SAAS,KAAK,QAAQ,IAAI,CAAC;IACrD,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACnE,OAAO,CAAC,GAAG,SAAS,KAAK,QAAQ,GAAG,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "wavemaker-dev-mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for WaveMaker React runtime and foundation-css: search, read props, and tokens from node_modules",
5
+ "keywords": [
6
+ "mcp",
7
+ "wavemaker",
8
+ "react-runtime",
9
+ "foundation-css",
10
+ "modelcontextprotocol"
11
+ ],
12
+ "license": "MIT",
13
+ "author": "Naresh Ravulapalli",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/nareshr500/wavemaker-dev-mcp.git"
17
+ },
18
+ "type": "commonjs",
19
+ "main": "dist/index.js",
20
+ "bin": {
21
+ "wavemaker-dev-mcp": "./dist/index.js"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc",
33
+ "postbuild": "chmod +x dist/index.js",
34
+ "start": "node dist/index.js",
35
+ "test": "playwright test",
36
+ "prepublishOnly": "npm run build"
37
+ },
38
+ "dependencies": {
39
+ "@modelcontextprotocol/sdk": "^1.29.0",
40
+ "fast-glob": "^3.3.3",
41
+ "zod": "^4.3.6"
42
+ },
43
+ "devDependencies": {
44
+ "@playwright/test": "^1.59.0",
45
+ "@types/node": "^25.5.0",
46
+ "typescript": "^6.0.2"
47
+ }
48
+ }