impact-ui-mcp-server 1.0.2 → 1.0.4

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.
@@ -0,0 +1,279 @@
1
+ # TableChat Scaffold Plan – Impact UI MCP Server
2
+
3
+ This document is the implementation plan for adding a **TableChat scaffold** feature to the impact-ui MCP server. When a team runs a special prompt (e.g. “Add TableChat to my table”), the MCP server returns file contents and instructions so the AI (Cursor in Agent mode) can create or update the right files with minimal code for the consumer.
4
+
5
+ ---
6
+
7
+ ## 1. Goal
8
+
9
+ - **Consumer flow**: Team has a TableWrapper (or similar) that uses impact-ui `Table`. They want to enable TableChat.
10
+ - **One-time setup**: Scaffold creates `chat.service.js`, table-chat constants, axios/env setup, and `useTableChat.js` (plus optional TableWrapper example).
11
+ - **Per-table**: When adding chat to another table, only **objectType** and **uniqueRowId** (and optionally **channelName**) are needed; constants get a new table config block.
12
+ - **Parameters**:
13
+ - **First time**: `objectType` (required), `uniqueRowId` (required), `appCode` (optional, default e.g. `"promosmart"`), `channelName` (optional, default e.g. `"promo_name"`).
14
+ - **Add table**: `objectType` (required), `uniqueRowId` (required), `tableName` (for constant key, e.g. `"WORKBENCH_TABLE"`), optionally `channelName`.
15
+
16
+ ---
17
+
18
+ ## 2. Files to Scaffold (Copy-Paste with Parameterization)
19
+
20
+ ### 2.1 Core three files (user-provided content)
21
+
22
+ | File | Purpose | Parameterization |
23
+ |------|----------|-------------------|
24
+ | **chat.service.js** | All TableChat API calls using `TABLE_CHAT_API` | Only the **axios import path** may vary by project (e.g. `../axios` vs `@/utils/axios`). |
25
+ | **constants (table chat)** | Table-agnostic config + **per-table** `TABLE_CHAT_CONFIG_FOR_*` | **objectType**, **uniqueRowId**, **appCode**, **channelName**, **tableName** (for constant key). |
26
+ | **useTableChat.js** | Hook that wires chat config, WebSocket, URL filter, column modifier, chat props | **Import paths** (utils, constants, hooks, assets, helpers) – parameterized by a **base path** or path convention. |
27
+
28
+ ### 2.2 Constants file – what varies table-by-table
29
+
30
+ From your constants, the **table-specific** part is:
31
+
32
+ ```js
33
+ // Basic table chat configuration – one block per table
34
+ const TABLE_CHAT_CONFIG_FOR_<TABLE_NAME> = {
35
+ objectType: "<objectType>", // tableCode – required, varies per table
36
+ channelName: "<channelName>", // column field for chat icon – optional default
37
+ uniqueRowId: "<uniqueRowId>", // row ID field – required, varies per table
38
+ appCode: APP_CODE, // project-level – set once
39
+ maxReconnectAttempts: MAX_RECONNECT_ATTEMPTS,
40
+ };
41
+ ```
42
+
43
+ - **First time**: Create full constants file with one such block; user supplies **objectType**, **uniqueRowId**, and optionally **appCode**, **channelName**.
44
+ - **Add table**: Return only a **new** `TABLE_CHAT_CONFIG_FOR_<TABLE_NAME>` block + short instructions to merge into existing constants and re-export.
45
+
46
+ ### 2.3 Axios and env (not a separate “file” but part of scaffold response)
47
+
48
+ - **Env**: User must add to `.env` (or `.env.example`):
49
+ - `REACT_APP_TABLE_CHAT_BASE_URL='https://gap.devs.impactsmartsuite.com/pricesmart-shared/api/v3'`
50
+ - (URL will change per project.)
51
+ - **Axios instance**: In the project’s existing axios file (e.g. `utils/axios.js`), add:
52
+ - `TABLE_CHAT_API` created with `baseURL: process.env.REACT_APP_TABLE_CHAT_BASE_URL` (or `REACT_APP_TABLE_CHAT_API_BASE_URL` to match your naming).
53
+
54
+ Scaffold output should include an **env snippet** and an **axios snippet** so the AI can add them.
55
+
56
+ ---
57
+
58
+ ## 3. Dependency Graph (useTableChat.js)
59
+
60
+ `useTableChat.js` depends on:
61
+
62
+ - **Hooks**: `useChat`, `useUrlChatFilter`, `useTopicWebSocket`, `useTableVisibleRows`
63
+ - **Services**: `chat.service.js` (and axios with `TABLE_CHAT_API`)
64
+ - **Constants**: table-chat constants
65
+ - **Helpers**: `SpecialBadgeWrapperCellRenderer`, `ChatColumnCellRenderer` (e.g. from `tableCellRendererHelpers`)
66
+ - **UI**: `Tooltip` from `impact-ui`, chat icon asset (e.g. `chatMsgIcon.svg`)
67
+ - **Redux**: `useDispatch`, `toastError` (or equivalent)
68
+ - **Modal**: `ChatJourneyModal` (and its storage key from constants)
69
+
70
+ These are **not** in the impact-ui repo; they live in the consuming project (e.g. PromoSmart). So:
71
+
72
+ - **Option A (recommended for “copy-paste in any project”)**: You provide **templates** for `useChat`, `useUrlChatFilter`, `useTopicWebSocket`, `useTableVisibleRows`, and optionally the cell renderer helpers + `ChatJourneyModal`, and the MCP server bundles them so the scaffold is self-contained.
73
+ - **Option B**: Scaffold only the **three files** + env + axios + TableWrapper example; document the list above as **prerequisites** (team must add these hooks/helpers from a shared repo or implement them).
74
+
75
+ The plan below assumes **Option B** for the first version (scaffold the three files + env + axios + integration doc). If you later add the missing hooks/helpers as templates, the same MCP tool can append more entries to the `files` array.
76
+
77
+ ---
78
+
79
+ ## 4. MCP Tool Design
80
+
81
+ ### 4.1 Tool name
82
+
83
+ - `scaffold_table_chat` (or `get_table_chat_scaffold`).
84
+
85
+ ### 4.2 Input schema
86
+
87
+ ```ts
88
+ {
89
+ mode: "first_time" | "add_table";
90
+ objectType: string; // required – tableCode for this table
91
+ uniqueRowId: string; // required – row ID field (e.g. "promo_id")
92
+ tableName?: string; // for add_table – e.g. "WORKBENCH_TABLE" (used in TABLE_CHAT_CONFIG_FOR_<TABLE_NAME>)
93
+ appCode?: string; // optional – default "promosmart" (first_time)
94
+ channelName?: string; // optional – default "promo_name" (column to show chat icon)
95
+ paths?: {
96
+ services?: string; // e.g. "src/utils/services"
97
+ constants?: string; // e.g. "src/constants"
98
+ hooks?: string; // e.g. "src/customHooks"
99
+ axios?: string; // e.g. "src/utils/axios"
100
+ };
101
+ }
102
+ ```
103
+
104
+ - **first_time**: Create `chat.service.js`, constants file (with one table config), env snippet, axios snippet, `useTableChat.js`, and optionally a TableWrapper example. Require **objectType** and **uniqueRowId**; **appCode** and **channelName** are optional with defaults.
105
+ - **add_table**: Return only the new `TABLE_CHAT_CONFIG_FOR_<tableName>` block + instructions to merge into existing constants + how to use `chatConfig` in the table usage.
106
+
107
+ ### 4.3 Output shape (so the AI can create/update files)
108
+
109
+ ```ts
110
+ {
111
+ instructions: string; // Markdown: what to do (add env, add axios, create files, wire TableWrapper)
112
+ envSnippet?: string; // Line(s) for .env
113
+ axiosSnippet?: string; // Code to add to axios file (TABLE_CHAT_API)
114
+ files: Array<{
115
+ path: string; // e.g. "src/utils/services/chat.service.js"
116
+ content: string; // Full file content (with placeholders replaced)
117
+ action: "create" | "merge"; // merge = add to existing file (e.g. constants)
118
+ }>;
119
+ integrationSnippet?: string; // Minimal TableWrapper + actual table usage (as in your example)
120
+ }
121
+ ```
122
+
123
+ - For **first_time**, `files` includes at least:
124
+ - `chat.service.js`
125
+ - table-chat constants file (one table config)
126
+ - `useTableChat.js`
127
+ - For **add_table**, `files` can be a single item with `action: "merge"` and content = only the new `TABLE_CHAT_CONFIG_FOR_*` block + export line, plus `instructions` explaining where to paste it.
128
+
129
+ ---
130
+
131
+ ## 5. First-Time Setup Flow (Step-by-Step)
132
+
133
+ 1. **User prompt** (e.g. in Cursor):
134
+ “Add TableChat feature from impact-ui for my table. objectType: `landing_workbench_table`, uniqueRowId: `promo_id`.”
135
+ Optionally: “appCode: promosmart, channelName: promo_name.”
136
+
137
+ 2. **AI** calls MCP tool:
138
+ `scaffold_table_chat({ mode: "first_time", objectType: "landing_workbench_table", uniqueRowId: "promo_id", appCode: "promosmart", channelName: "promo_name" })`.
139
+
140
+ 3. **MCP server** returns:
141
+ - **instructions**: Add `REACT_APP_TABLE_CHAT_BASE_URL` to `.env`, add `TABLE_CHAT_API` to axios file, create the following files, then wire TableWrapper as in the snippet.
142
+ - **envSnippet**: `REACT_APP_TABLE_CHAT_BASE_URL='https://...'`
143
+ - **axiosSnippet**: `const TABLE_CHAT_API = axios.create({ baseURL: process.env.REACT_APP_TABLE_CHAT_BASE_URL, ... });` and export.
144
+ - **files**:
145
+ - `src/utils/services/chat.service.js` (content from your chat.service.js; import from `../axios` or from `paths.axios`).
146
+ - `src/constants/tableChatConstants.js` (or similar): full constants file with `TABLE_CHAT_CONFIG_FOR_WORKBENCH_TABLE` (or a generic name) using the given objectType, uniqueRowId, appCode, channelName.
147
+ - `src/customHooks/useTableChat.js`: content with import paths resolved (e.g. from `paths` or a convention like `@/utils/services/chat.service`, `@/constants/tableChatConstants`).
148
+ - **integrationSnippet**: Your TableWrapper example + actual table usage with `chatConfig={{ selectedRows, uniqueRowId, objectType }}`.
149
+
150
+ 4. **AI** (Agent mode) creates/edits files in the user’s project and adds the env line and axios snippet.
151
+
152
+ 5. **User** ensures dependencies of `useTableChat` exist (useChat, useUrlChatFilter, useTopicWebSocket, useTableVisibleRows, tableCellRendererHelpers, ChatJourneyModal, etc.) – either from a shared repo or by adding them in a later scaffold phase.
153
+
154
+ ---
155
+
156
+ ## 6. Add-Table Flow
157
+
158
+ 1. **User prompt**:
159
+ “Add TableChat for another table: objectType: `landing_marketing_calendar_promos_table`, uniqueRowId: `promo_id`, tableName: MARKETING_CALENDAR_PROMOS_TABLE.”
160
+
161
+ 2. **AI** calls:
162
+ `scaffold_table_chat({ mode: "add_table", objectType: "landing_marketing_calendar_promos_table", uniqueRowId: "promo_id", tableName: "MARKETING_CALENDAR_PROMOS_TABLE", channelName: "promo_name" })`.
163
+
164
+ 3. **MCP server** returns:
165
+ - **instructions**: Merge the following block into your existing table-chat constants file and add the new config to the export. Then use `chatConfig={{ ... TABLE_CHAT_CONFIG_FOR_MARKETING_CALENDAR_PROMOS_TABLE }}` (or pass objectType/uniqueRowId) in your TableWrapper for that table.
166
+ - **files**: One item with `action: "merge"`, path = existing constants file, content = the new `TABLE_CHAT_CONFIG_FOR_MARKETING_CALENDAR_PROMOS_TABLE` block + export update.
167
+ - **integrationSnippet**: Example usage for the new table (same pattern as workbench).
168
+
169
+ 4. **AI** merges the block into the constants file and optionally updates the table usage.
170
+
171
+ ---
172
+
173
+ ## 7. Path Conventions and Placeholders
174
+
175
+ - **Templates** should use placeholders so the MCP server (or the AI) can replace them:
176
+ - `{{OBJECT_TYPE}}`, `{{UNIQUE_ROW_ID}}`, `{{APP_CODE}}`, `{{CHANNEL_NAME}}`, `{{TABLE_NAME}}`
177
+ - `{{IMPORT_AXIOS}}` (e.g. `from "../axios"` or `from "@/utils/axios"`)
178
+ - `{{IMPORT_CONSTANTS}}`, `{{IMPORT_CHAT_SERVICE}}`, `{{IMPORT_USE_CHAT}}`, etc., or a single **base path** (e.g. `@/`) so all imports are consistent.
179
+ - **Default paths** (if `paths` is omitted):
180
+ - services: `src/utils/services`
181
+ - constants: `src/constants`
182
+ - hooks: `src/customHooks`
183
+ - axios: `src/utils/axios`
184
+
185
+ ---
186
+
187
+ ## 8. TableWrapper and Actual Table Usage (Reference)
188
+
189
+ - **TableWrapper** (your example): Uses `useTableChat({ chatConfig, tableRef, rowData, showChatIconOnColumn, visibleRowsIds, isEnabled })`, then `getChatProps()`, `getChatColumnModifier(columnDefs)`, and spreads `...chatProps` and applies `getChatColumnModifier(defaultColumnDefs)` to column defs. Chat journey modal uses `chatConfig.journeyModalStorageKey` and `chatConfig.journeyModalConfig`.
190
+ - **Actual table** (your example):
191
+ `<TableWrapper ... chatConfig={{ selectedRows: workbenchSelectedOffers, uniqueRowId: "promo_id", objectType: TABLE_VIEW_TABLE_NAME.LANDING_WORKBENCH_TABLE }} ... />`
192
+ So after scaffold, the consumer only needs to pass **objectType** (e.g. from a table name constant) and **uniqueRowId** (and optionally **channelName**); the rest comes from the scaffolded constants and hook.
193
+
194
+ The **integrationSnippet** in the scaffold response should mirror this so the AI can paste or adapt it into the project.
195
+
196
+ ---
197
+
198
+ ## 9. Recommended User Prompts (for documentation)
199
+
200
+ Document these so teams know what to ask:
201
+
202
+ - **First-time setup**:
203
+ “Add TableChat feature from impact-ui. objectType: \<tableCode\>, uniqueRowId: \<rowIdField\>. [Optional: appCode: promosmart, channelName: promo_name]”
204
+ - **Add another table**:
205
+ “Add TableChat for another table: objectType: \<tableCode\>, uniqueRowId: \<rowIdField\>, tableName: \<CONSTANT_NAME\>.”
206
+
207
+ The AI should then call `scaffold_table_chat` with the appropriate `mode` and parameters.
208
+
209
+ ### Example prompts (copy-paste for teams)
210
+
211
+ **First time (e.g. Workbench table):**
212
+ ```
213
+ Add TableChat feature from impact-ui for my table.
214
+ objectType: landing_workbench_table
215
+ uniqueRowId: promo_id
216
+ [Optional: appCode: promosmart, channelName: promo_name]
217
+ ```
218
+
219
+ **Add another table (e.g. Marketing Calendar Promos):**
220
+ ```
221
+ Add TableChat for another table from impact-ui.
222
+ objectType: landing_marketing_calendar_promos_table
223
+ uniqueRowId: promo_id
224
+ tableName: MARKETING_CALENDAR_PROMOS_TABLE
225
+ channelName: promo_name
226
+ ```
227
+
228
+ ---
229
+
230
+ ## 10. Implementation Checklist (MCP Server)
231
+
232
+ - [ ] Add **templates** directory under `mcp-server/` (e.g. `templates/table-chat/`) with:
233
+ - `chat.service.js.template`
234
+ - `tableChatConstants.js.template`
235
+ - `useTableChat.js.template`
236
+ - (Optional) `axios-snippet.txt`, `env-snippet.txt`
237
+ - [ ] Implement **scaffold_table_chat** tool in `src/index.js`:
238
+ - Read templates (from package path via `import.meta.url` / `__dirname`).
239
+ - Replace placeholders with tool args (objectType, uniqueRowId, appCode, channelName, tableName, paths).
240
+ - Return `{ instructions, envSnippet, axiosSnippet, files, integrationSnippet }`.
241
+ - [ ] For **add_table**, either:
242
+ - Return only the new constant block + instructions to merge, or
243
+ - Accept `constantsFilePath` and return a full “merged” constants file (more complex; optional).
244
+ - [ ] Document **prerequisites** (useChat, useUrlChatFilter, useTopicWebSocket, useTableVisibleRows, tableCellRendererHelpers, ChatJourneyModal) in MCP server docs or in the `instructions` text so teams know what they must add if not scaffolded.
245
+ - [ ] Add **TABLE_CHAT_API** and **REACT_APP_TABLE_CHAT_BASE_URL** to any existing ENV doc (e.g. `ENV_VARIABLES.md`).
246
+ - [ ] Add `templates` and `TABLECHAT_SCAFFOLD_PLAN.md` to the `files` array in `package.json` so they are published with the npm package.
247
+
248
+ ---
249
+
250
+ ## 11. Summary
251
+
252
+ | Item | Detail |
253
+ |------|--------|
254
+ | **Core files** | chat.service.js, table-chat constants, useTableChat.js |
255
+ | **Constants vary by table** | objectType, uniqueRowId (required); appCode, channelName (optional with defaults) |
256
+ | **First time** | Require objectType + uniqueRowId; optional appCode, channelName; create services, constants, hook, env, axios snippet, TableWrapper snippet |
257
+ | **Add table** | Require objectType + uniqueRowId (+ tableName for constant key); return new TABLE_CHAT_CONFIG block + merge instructions |
258
+ | **Env** | REACT_APP_TABLE_CHAT_BASE_URL (or REACT_APP_TABLE_CHAT_API_BASE_URL) |
259
+ | **Dependencies of useTableChat** | useChat, useUrlChatFilter, useTopicWebSocket, useTableVisibleRows, tableCellRendererHelpers, ChatJourneyModal, Redux toast, asset – document or bundle as templates later |
260
+
261
+ This plan allows any project with a TableWrapper-style setup to implement TableChat with a single prompt and minimal manual code (objectType, uniqueRowId, and optionally appCode/channelName/tableName), while keeping the “three files” (service, constants, useTableChat) as the main scaffold payload and constants as the only table-varying part.
262
+
263
+ ---
264
+
265
+ ## 12. Next steps for implementation
266
+
267
+ 1. **Add template files** in `mcp-server/templates/table-chat/`:
268
+ - Paste your `chat.service.js` → save as `chat.service.js.template`, replace axios import with `{{IMPORT_AXIOS}}`.
269
+ - Paste your table-chat constants → save as `tableChatConstants.js.template`, replace first table config with `{{OBJECT_TYPE}}`, `{{UNIQUE_ROW_ID}}`, `{{APP_CODE}}`, `{{CHANNEL_NAME}}`, `{{TABLE_NAME}}`.
270
+ - Paste your `useTableChat.js` → save as `useTableChat.js.template`, replace all import paths with the placeholders listed in `templates/table-chat/README.md`.
271
+ - Add `axios-snippet.txt` and `env-snippet.txt` (and optionally `integration-snippet.jsx.template`).
272
+
273
+ 2. **Implement the tool** in `mcp-server/src/`:
274
+ - Create `tools/tableChatScaffold.js` (or similar): read templates from `templates/table-chat/`, replace placeholders with tool args, build `files` array and return payload.
275
+ - In `index.js`: register `scaffold_table_chat` in `ListToolsRequestSchema` and handle `CallToolRequestSchema` for it.
276
+
277
+ 3. **Resolve template path**: Use `import.meta.url` / `path.dirname(fileURLToPath(import.meta.url))` in the tool to resolve the path to `templates/table-chat/` relative to the MCP server package so it works when installed from npm.
278
+
279
+ 4. **Document** in MCP server README or USAGE: how to run the special prompt and that useChat, useUrlChatFilter, useTopicWebSocket, useTableVisibleRows, and table helpers are required (or add those templates in a later phase).
@@ -102,21 +102,51 @@ if (useNpm) {
102
102
  console.log(" Make sure to install: npm install impact-ui-mcp-server\n");
103
103
  }
104
104
  } else {
105
- // Local development configuration
106
- const mcpServerPath = resolve(__dirname);
107
- const indexPath = resolve(__dirname, "src/index.js");
105
+ // For npm packages (when run from a project), use ${workspaceFolder} variables
106
+ // Try to detect if we're in a project with node_modules
107
+ const cwd = process.cwd();
108
+ let mcpServerPath = "${workspaceFolder}/frontend/node_modules/impact-ui-mcp-server/src/index.js";
109
+ let impactUiPath = "${workspaceFolder}/frontend/node_modules/impact-ui";
110
+
111
+ // Check actual structure to determine which path to use
112
+ const frontendMcpPath = resolve(cwd, "frontend", "node_modules", "impact-ui-mcp-server", "src", "index.js");
113
+ const rootMcpPath = resolve(cwd, "node_modules", "impact-ui-mcp-server", "src", "index.js");
114
+
115
+ if (existsSync(frontendMcpPath)) {
116
+ // Packages are in frontend/node_modules
117
+ mcpServerPath = "${workspaceFolder}/frontend/node_modules/impact-ui-mcp-server/src/index.js";
118
+ impactUiPath = "${workspaceFolder}/frontend/node_modules/impact-ui";
119
+ } else if (existsSync(rootMcpPath)) {
120
+ // Packages are in root node_modules
121
+ mcpServerPath = "${workspaceFolder}/node_modules/impact-ui-mcp-server/src/index.js";
122
+ impactUiPath = "${workspaceFolder}/node_modules/impact-ui";
123
+ }
124
+
125
+ // Check for scoped package name
126
+ const frontendScopedMcpPath = resolve(cwd, "frontend", "node_modules", "@impact-analytics", "impact-ui-mcp-server", "src", "index.js");
127
+ const rootScopedMcpPath = resolve(cwd, "node_modules", "@impact-analytics", "impact-ui-mcp-server", "src", "index.js");
128
+
129
+ if (existsSync(frontendScopedMcpPath)) {
130
+ mcpServerPath = "${workspaceFolder}/frontend/node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js";
131
+ } else if (existsSync(rootScopedMcpPath)) {
132
+ mcpServerPath = "${workspaceFolder}/node_modules/@impact-analytics/impact-ui-mcp-server/src/index.js";
133
+ }
108
134
 
109
135
  config = {
110
136
  "mcp.servers": {
111
137
  "impact-ui": {
112
138
  "command": "node",
113
- "args": [indexPath],
114
- "cwd": mcpServerPath
139
+ "args": [mcpServerPath],
140
+ "cwd": "${workspaceFolder}",
141
+ "env": {
142
+ "IMPACT_UI_NODE_MODULES": impactUiPath
143
+ }
115
144
  }
116
145
  }
117
146
  };
118
147
 
119
- console.log("\n🏠 Local Development Configuration\n");
148
+ console.log("\n📦 NPM Package Configuration (with ${workspaceFolder} variables)\n");
149
+ console.log("💡 Detected package structure and using ${workspaceFolder} variables for Cursor.\n");
120
150
  }
121
151
 
122
152
  console.log("Add this to your Cursor settings.json:\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impact-ui-mcp-server",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "MCP Server for Impact UI Library - Provides AI access to component documentation and code examples",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -11,6 +11,8 @@
11
11
  "impact-ui-generate-windsurf-config-absolute": "./generate-windsurf-config-absolute.js"
12
12
  },
13
13
  "files": [
14
+ "TABLECHAT_SCAFFOLD_PLAN.md",
15
+ "templates",
14
16
  "src",
15
17
  "generate-cursor-config.js",
16
18
  "generate-windsurf-config.js",
@@ -56,4 +58,4 @@
56
58
  "glob": "^10.3.10",
57
59
  "fs-extra": "^11.1.1"
58
60
  }
59
- }
61
+ }
package/src/index.js CHANGED
@@ -15,6 +15,7 @@ import { parseComponentFile } from "./parsers/componentParser.js";
15
15
  import { getProjectRoot } from "./utils/fileReader.js";
16
16
  import { getComponentInfo } from "./tools/componentInfo.js";
17
17
  import { generateCodeExample } from "./tools/codeExample.js";
18
+ import { getTableChatScaffold } from "./tools/tableChatScaffold.js";
18
19
 
19
20
  // Component registry - populated on startup
20
21
  let componentRegistry = {};
@@ -194,6 +195,60 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
194
195
  required: ["componentName"],
195
196
  },
196
197
  },
198
+ {
199
+ name: "scaffold_table_chat",
200
+ description: "Get scaffold (file contents and instructions) to add TableChat feature to a project using impact-ui Table. Returns useTopicWebSocket hook, chatCellRenderers, env/axios snippets, and integration steps. Use when the user asks to add TableChat or implement table chat.",
201
+ inputSchema: {
202
+ type: "object",
203
+ properties: {
204
+ mode: {
205
+ type: "string",
206
+ description: "first_time (default) or add_table",
207
+ enum: ["first_time", "add_table"],
208
+ },
209
+ objectType: {
210
+ type: "string",
211
+ description: "Table code / object type (e.g. promo, landing_workbench_table). Required.",
212
+ },
213
+ uniqueRowId: {
214
+ type: "string",
215
+ description: "Row ID field name (e.g. promo_id). Required.",
216
+ },
217
+ tableName: {
218
+ type: "string",
219
+ description: "Constant key suffix for add_table (e.g. WORKBENCH_TABLE).",
220
+ },
221
+ appCode: {
222
+ type: "string",
223
+ description: "Project app code (default: promosmart).",
224
+ },
225
+ channelName: {
226
+ type: "string",
227
+ description: "Column field to show chat icon on (default: promo_name).",
228
+ },
229
+ paths: {
230
+ type: "object",
231
+ description: "Optional paths: hooks, services, helpers, axios, constants.",
232
+ properties: {
233
+ hooks: { type: "string" },
234
+ services: { type: "string" },
235
+ helpers: { type: "string" },
236
+ axios: { type: "string" },
237
+ constants: { type: "string" },
238
+ },
239
+ },
240
+ reactRouterPackage: {
241
+ type: "string",
242
+ description: "Package for useSearchParams in useUrlChatFilter (default: react-router-dom-v5-compat). Use react-router-dom for v6.",
243
+ },
244
+ lodashPackage: {
245
+ type: "string",
246
+ description: "Package for debounce in useTableVisibleRows (default: lodash). Use lodash-es if needed.",
247
+ },
248
+ },
249
+ required: ["objectType", "uniqueRowId"],
250
+ },
251
+ },
197
252
  ],
198
253
  };
199
254
  });
@@ -528,6 +583,28 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
528
583
  };
529
584
  }
530
585
 
586
+ case "scaffold_table_chat": {
587
+ const scaffoldMarkdown = getTableChatScaffold({
588
+ mode: args.mode || "first_time",
589
+ objectType: args.objectType,
590
+ uniqueRowId: args.uniqueRowId,
591
+ tableName: args.tableName,
592
+ appCode: args.appCode,
593
+ channelName: args.channelName,
594
+ paths: args.paths,
595
+ reactRouterPackage: args.reactRouterPackage,
596
+ lodashPackage: args.lodashPackage,
597
+ });
598
+ return {
599
+ content: [
600
+ {
601
+ type: "text",
602
+ text: scaffoldMarkdown,
603
+ },
604
+ ],
605
+ };
606
+ }
607
+
531
608
  default:
532
609
  throw new Error(`Unknown tool: ${name}`);
533
610
  }