@nqminds/mcp-client 1.0.31 → 1.0.33

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.
@@ -1 +1 @@
1
- {"version":3,"file":"MCPChat.d.ts","sourceRoot":"","sources":["../src/MCPChat.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,KAAK,EAAyB,YAAY,EAAe,MAAM,SAAS,CAAC;AAgchF,wBAAgB,OAAO,CAAC,EACtB,aAAa,EACb,WAA6B,EAC7B,YAAiB,EACjB,SAAc,GACf,EAAE,YAAY,qBA6hBd"}
1
+ {"version":3,"file":"MCPChat.d.ts","sourceRoot":"","sources":["../src/MCPChat.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,KAAK,EAAyB,YAAY,EAAe,MAAM,SAAS,CAAC;AA0ahF,wBAAgB,OAAO,CAAC,EACtB,aAAa,EACb,WAA6B,EAC7B,YAAiB,EACjB,SAAc,GACf,EAAE,YAAY,qBAyhBd"}
package/dist/MCPChat.js CHANGED
@@ -12,99 +12,61 @@ function stripUtmSource(url) {
12
12
  .replace(/\?$/, "");
13
13
  }
14
14
  /**
15
- * Fixes broken markdown tables produced by streaming LLM output.
15
+ * Renders a structured json-table block as an HTML table.
16
16
  *
17
- * The LLM often emits an entire table (title + header + separator + data rows)
18
- * as a single line, e.g.:
19
- * "My title | Col A | Col B | |---|---| | val1 | val2 | | val3 | val4 |"
20
- *
21
- * Strategy:
22
- * 1. Split content into lines.
23
- * 2. For each line, detect whether a markdown separator pattern
24
- * (|---|---| etc.) appears *somewhere* but the line is NOT already a
25
- * standalone separator or a normal single table row.
26
- * 3. If so, extract any leading title text, then split the remainder into
27
- * individual pipe-delimited rows by counting pipes.
28
- * 4. Emit blank + title (if any) + one row per line + blank.
17
+ * Expected JSON shape:
18
+ * { "columns": ["Col A", "Col B"], "rows": [["val1", "val2"], ...] }
19
+ */
20
+ function JsonDataTable({ columns, rows }) {
21
+ return (React.createElement("div", { className: "mcp-data-table-wrapper" },
22
+ React.createElement("table", { className: "mcp-data-table" },
23
+ React.createElement("thead", null,
24
+ React.createElement("tr", null, columns.map((col, i) => React.createElement("th", { key: i }, col)))),
25
+ React.createElement("tbody", null, rows.map((row, ri) => (React.createElement("tr", { key: ri }, row.map((cell, ci) => React.createElement("td", { key: ci }, String(cell ?? ""))))))))));
26
+ }
27
+ /**
28
+ * Returns the ReactMarkdown `components` map.
29
29
  *
30
- * Deliberately avoids touching `preprocessLinks` output (markdown links
31
- * have the form `[text](url)` which contains no `|`, so they are safe).
30
+ * When `isStreaming` is true, json-table code blocks are left as raw code
31
+ * (the JSON may be incomplete mid-stream). Once streaming finishes they are
32
+ * parsed and replaced with a proper <JsonDataTable />.
32
33
  */
33
- function fixBrokenTables(content) {
34
- const SEP_CELL = /^[ \t]*:?-{2,}:?[ \t]*$/;
35
- // Matches a run of pipe-delimited separator cells: |---|---:|:---|
36
- const SEP_RE = /\|[ \t]*:?-{2,}:?[ \t]*(?:\|[ \t]*:?-{2,}:?[ \t]*)+\|/;
37
- const lines = content.split("\n");
38
- const out = [];
39
- for (let i = 0; i < lines.length; i++) {
40
- const line = lines[i];
41
- // Find a separator sub-string in this line
42
- const sepMatch = SEP_RE.exec(line);
43
- if (!sepMatch) {
44
- out.push(line);
45
- continue;
46
- }
47
- const sepStr = sepMatch[0];
48
- // Count columns from the separator
49
- const cols = sepStr.split("|").filter((s) => SEP_CELL.test(s)).length;
50
- if (cols < 1) {
51
- out.push(line);
52
- continue;
53
- }
54
- // If the line is ONLY the separator (possibly with surrounding whitespace)
55
- // it's already correct — leave it alone.
56
- if (line.trim() === sepStr.trim()) {
57
- out.push(line);
58
- continue;
59
- }
60
- // There may be a title/description before the first pipe.
61
- // Everything before the very first "|" in the line is the title.
62
- const firstPipeIdx = line.indexOf("|");
63
- const title = firstPipeIdx > 0 ? line.substring(0, firstPipeIdx).trim() : "";
64
- // Table content is everything from the first "|" onwards.
65
- const tableText = firstPipeIdx >= 0 ? line.substring(firstPipeIdx) : line;
66
- // Split into individual cells by pipe, preserving the "|" delimiters.
67
- // We walk character-by-character and emit a new row every time we have
68
- // accumulated exactly (cols + 1) pipe characters.
69
- const rows = [];
70
- let currentRow = "";
71
- let pipeCount = 0;
72
- const perRow = cols + 1; // a N-column row has N+1 pipes
73
- for (let k = 0; k < tableText.length; k++) {
74
- const ch = tableText[k];
75
- currentRow += ch;
76
- if (ch === "|") {
77
- pipeCount++;
78
- if (pipeCount === perRow) {
79
- rows.push(currentRow.trim());
80
- currentRow = "";
81
- pipeCount = 0;
82
- // Skip any whitespace between rows
83
- while (k + 1 < tableText.length && tableText[k + 1] === " ")
84
- k++;
34
+ function makeMarkdownComponents(isStreaming) {
35
+ return {
36
+ a({ href, children }) {
37
+ return React.createElement("a", { href: href, target: "_blank", rel: "noopener noreferrer" }, children);
38
+ },
39
+ code({ className, children }) {
40
+ const lang = /language-([\w-]+)/.exec(className ?? "")?.[1];
41
+ if (lang === "json-table" && !isStreaming) {
42
+ const raw = String(children ?? "").replace(/\n$/, "");
43
+ try {
44
+ const parsed = JSON.parse(raw);
45
+ if (Array.isArray(parsed.columns) &&
46
+ Array.isArray(parsed.rows) &&
47
+ parsed.rows.every(Array.isArray)) {
48
+ return React.createElement(JsonDataTable, { columns: parsed.columns, rows: parsed.rows });
49
+ }
85
50
  }
51
+ catch { /* fall through to normal code block */ }
86
52
  }
87
- }
88
- // Any leftover (incomplete row — happens during streaming)
89
- if (currentRow.trim())
90
- rows.push(currentRow.trim());
91
- // Need at least header + separator to bother reconstructing
92
- if (rows.length < 2) {
93
- out.push(line);
94
- continue;
95
- }
96
- // Emit: blank line, optional title, then each row on its own line, blank line
97
- if (out.length > 0 && out[out.length - 1] !== "")
98
- out.push("");
99
- if (title) {
100
- out.push(title);
101
- out.push("");
102
- }
103
- for (const row of rows)
104
- out.push(row);
105
- out.push("");
106
- }
107
- return out.join("\n");
53
+ return React.createElement("code", { className: className }, children);
54
+ },
55
+ pre({ children }) {
56
+ // When the sole child is a json-table code element that our `code`
57
+ // override has already replaced with <JsonDataTable />, skip the
58
+ // <pre> wrapper so the table is not styled as a code block.
59
+ const childArr = React.Children.toArray(children);
60
+ if (!isStreaming &&
61
+ childArr.length === 1 &&
62
+ React.isValidElement(childArr[0]) &&
63
+ typeof childArr[0].props.className === "string" &&
64
+ childArr[0].props.className.includes("language-json-table")) {
65
+ return React.createElement(React.Fragment, null, children);
66
+ }
67
+ return React.createElement("pre", null, children);
68
+ },
69
+ };
108
70
  }
109
71
  /**
110
72
  * Post-processes AI response content to ensure all links open in a new tab
@@ -128,7 +90,7 @@ function preprocessLinks(content) {
128
90
  * the browser's print dialog (which offers "Save as PDF").
129
91
  */
130
92
  function downloadMessageAsPdf(markdownContent, companyNumber) {
131
- const html = renderToStaticMarkup(React.createElement(ReactMarkdown, { remarkPlugins: [remarkGfm] }, preprocessLinks(fixBrokenTables(markdownContent))));
93
+ const html = renderToStaticMarkup(React.createElement(ReactMarkdown, { remarkPlugins: [remarkGfm], components: makeMarkdownComponents(false) }, preprocessLinks(markdownContent)));
132
94
  const title = companyNumber
133
95
  ? `FLAIR Report — ${companyNumber}`
134
96
  : "FLAIR Report";
@@ -278,7 +240,7 @@ This information should include:
278
240
  - ESG or public impact: sustainability, ethics, and social responsibility
279
241
  - Recent developments: major news, acquisitions, product releases, or leadership changes
280
242
 
281
- Use formal and impersonal language and avoid referring to these instructions. Format your output using markdown.`,
243
+ Use formal and impersonal language and avoid referring to these instructions. `,
282
244
  },
283
245
  {
284
246
  label: "Competitor analysis",
@@ -295,7 +257,7 @@ Use formal and impersonal language and avoid referring to these instructions. Fo
295
257
  3.2.2. Create a brief description of their business
296
258
  3.2.3. Say why you consider them to be a competitor
297
259
 
298
- Use formal and impersonal language and avoid referring to these instructions. Format your output using markdown.`,
260
+ Use formal and impersonal language and avoid referring to these instructions. `,
299
261
  },
300
262
  {
301
263
  label: "Risk analysis",
@@ -340,7 +302,7 @@ Note that your database does not list dissolved companies so you will need to se
340
302
  You MUST check the reason for a dissolution if you discover a relevant dissolved company.
341
303
 
342
304
  Use formal and impersonal language and avoid referring to these instructions.
343
- Format your output using markdown.`,
305
+ `,
344
306
  },
345
307
  {
346
308
  label: "Online sentiment",
@@ -372,7 +334,7 @@ Format your output using markdown.`,
372
334
  3.3.3. Highlight key events that evidence sentiment and the identified changes
373
335
 
374
336
  Use formal and impersonal language and avoid referring to these instructions.
375
- Format your output using markdown.`,
337
+ `,
376
338
  },
377
339
  {
378
340
  label: "SWOT analysis",
@@ -391,7 +353,7 @@ Format your output using markdown.`,
391
353
  3. Using the information gathered, perform a detailed SWOT analysis
392
354
 
393
355
  Use formal and impersonal language and avoid referring to these instructions.
394
- Format your output using markdown.`,
356
+ `,
395
357
  },
396
358
  {
397
359
  label: "Research key people",
@@ -420,7 +382,7 @@ Format your output using markdown.`,
420
382
  2.1.4. Are people likely to be linked by family relationships?
421
383
 
422
384
  Use formal and impersonal language and avoid referring to these instructions.
423
- Format your output using markdown.
385
+
424
386
  `,
425
387
  },
426
388
  ];
@@ -726,9 +688,7 @@ export function MCPChat({ companyNumber, apiEndpoint = "/api/mcp/chat", customSt
726
688
  .map((msg, idx) => (React.createElement("div", { key: idx, className: `mcp-chat-message ${msg.role === "user" ? "mcp-chat-message-user" : "mcp-chat-message-assistant"}` },
727
689
  React.createElement("div", { className: "mcp-chat-message-bubble" },
728
690
  msg.role === "assistant" ? (React.createElement("div", { className: "mcp-chat-message-content markdown-content" },
729
- React.createElement(ReactMarkdown, { remarkPlugins: [remarkGfm], components: {
730
- a: ({ href, children }) => (React.createElement("a", { href: href, target: "_blank", rel: "noopener noreferrer" }, children)),
731
- } }, preprocessLinks(fixBrokenTables(msg.content))))) : (React.createElement("div", { className: "mcp-chat-message-content" }, msg.content)),
691
+ React.createElement(ReactMarkdown, { remarkPlugins: [remarkGfm], components: makeMarkdownComponents(msg.isStreaming ?? false) }, preprocessLinks(msg.content)))) : (React.createElement("div", { className: "mcp-chat-message-content" }, msg.content)),
732
692
  msg.role === "assistant" && !msg.isStreaming && (React.createElement("div", { className: "mcp-chat-message-timestamp" },
733
693
  msg.timestamp.toLocaleTimeString(),
734
694
  msg.tokenInfo && (React.createElement("span", { className: "mcp-chat-token-info" }, msg.tokenInfo)),
@@ -7,6 +7,17 @@ export interface CreateMCPHandlerConfig {
7
7
  openaiModel?: string;
8
8
  /** Override log directory. Falls back to MCP_LOG_DIR env var. */
9
9
  logDir?: string;
10
+ /**
11
+ * Whether to include OpenAI's code_interpreter tool.
12
+ * Disabled by default — enable only when the use-case needs computation,
13
+ * as each container-hour is billed separately.
14
+ */
15
+ enableCodeInterpreter?: boolean;
16
+ /**
17
+ * Memory limit for the code_interpreter container.
18
+ * Valid values: "1g" (default), "2g", "4g".
19
+ */
20
+ codeInterpreterMemoryLimit?: "1g" | "2g" | "4g";
10
21
  }
11
22
  /**
12
23
  * Creates a streaming MCP chat handler for Next.js API routes
@@ -1 +1 @@
1
- {"version":3,"file":"api-helpers.d.ts","sourceRoot":"","sources":["../src/api-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,sBAAsB,IACnD,SAAS,OAAO,uBAqH/B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,KACrB,SAAS,OAAO,uBAU/B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,kBAKtC"}
1
+ {"version":3,"file":"api-helpers.d.ts","sourceRoot":"","sources":["../src/api-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;OAGG;IACH,0BAA0B,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CACjD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,sBAAsB,IACnD,SAAS,OAAO,uBAuH/B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,KACrB,SAAS,OAAO,uBAU/B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,kBAKtC"}
@@ -18,6 +18,8 @@ export function createMCPChatHandler(config) {
18
18
  mcpServerCommand: config.mcpServerCommand,
19
19
  openaiModel: config.openaiModel,
20
20
  logDir: config.logDir || process.env.MCP_LOG_DIR,
21
+ enableCodeInterpreter: config.enableCodeInterpreter,
22
+ codeInterpreterMemoryLimit: config.codeInterpreterMemoryLimit,
21
23
  });
22
24
  await client.connect();
23
25
  clients.set(sessionId, client);
@@ -43,6 +43,20 @@ export interface MCPClientConfig {
43
43
  * Falls back to the MCP_LOG_DIR env var, then to ./logs relative to CWD.
44
44
  */
45
45
  logDir?: string;
46
+ /**
47
+ * Whether to include OpenAI's code_interpreter tool.
48
+ * Disabled by default — enable only when the use-case needs computation,
49
+ * as each container-hour is billed separately.
50
+ * Defaults to false.
51
+ */
52
+ enableCodeInterpreter?: boolean;
53
+ /**
54
+ * Memory limit for the code_interpreter container.
55
+ * Only applies when enableCodeInterpreter is true.
56
+ * Valid values: "1g" (default), "2g", "4g".
57
+ * Omit to use OpenAI's default (1 GB).
58
+ */
59
+ codeInterpreterMemoryLimit?: "1g" | "2g" | "4g";
46
60
  }
47
61
  interface UsageStats {
48
62
  inputTokens: number;
@@ -1 +1 @@
1
- {"version":3,"file":"openai-client.d.ts","sourceRoot":"","sources":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CAAC,SAAS;IAIjB;;;;;;;;OAQG;IACH,OAAO,CAAC,YAAY;IAmCpB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA8EzB,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,kBAAkB;IAQ1B;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IA2CzB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAsC9B;;OAEG;YACW,kBAAkB;IA4DhC;;;OAGG;YACW,mBAAmB;IAoBjC;;;OAGG;IACH,OAAO,CAAC,8BAA8B;IAatC;;OAEG;YACW,UAAU;IAuBxB;;OAEG;YACW,cAAc;IAqC5B;;OAEG;IACG,YAAY,CAChB,KAAK,EAAE,MAAM,EACb,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,EACtC,WAAW,CAAC,EAAE,WAAW,EACzB,kBAAkB,UAAQ,GACzB,OAAO,CAAC,MAAM,CAAC;IA2RlB;;OAEG;YACW,eAAe;CAgI9B"}
@@ -138,6 +138,8 @@ export class MCPClientOpenAI {
138
138
  hotContextTargetInputTokens: config.hotContextTargetInputTokens ?? 100000,
139
139
  maxToolOutputChars: config.maxToolOutputChars ?? 20000,
140
140
  logDir: config.logDir ?? process.env.MCP_LOG_DIR ?? path.resolve(process.cwd(), "logs"),
141
+ enableCodeInterpreter: config.enableCodeInterpreter ?? false,
142
+ codeInterpreterMemoryLimit: config.codeInterpreterMemoryLimit,
141
143
  };
142
144
  this.logger = new McpLogger(this.config.logDir);
143
145
  this.openai = new OpenAI({
@@ -567,6 +569,12 @@ export class MCPClientOpenAI {
567
569
  const toolsResponse = await this.client.listTools();
568
570
  return [
569
571
  { type: "web_search_preview" },
572
+ ...(this.config.enableCodeInterpreter ? [{
573
+ type: "code_interpreter",
574
+ container: this.config.codeInterpreterMemoryLimit
575
+ ? { type: "auto", memory_limit: this.config.codeInterpreterMemoryLimit }
576
+ : { type: "auto" },
577
+ }] : []),
570
578
  ...toolsResponse.tools
571
579
  .filter((t) => t.name !== "web_search" && t.name !== "fetch_webpage")
572
580
  .map((tool) => ({
@@ -734,6 +742,9 @@ export class MCPClientOpenAI {
734
742
  if (item.type === "web_search_call") {
735
743
  onThinking?.("🔍 web_search_preview");
736
744
  }
745
+ else if (item.type === "code_interpreter_call") {
746
+ onThinking?.("🖥️ code_interpreter");
747
+ }
737
748
  }
738
749
  const functionCalls = output.filter((item) => item.type === "function_call");
739
750
  if (functionCalls.length > 0) {
@@ -886,6 +897,9 @@ export class MCPClientOpenAI {
886
897
  if (item.type === "web_search_call") {
887
898
  onThinking?.("🔍 web_search_preview");
888
899
  }
900
+ else if (item.type === "code_interpreter_call") {
901
+ onThinking?.("🖥️ code_interpreter");
902
+ }
889
903
  }
890
904
  const functionCalls = output.filter((item) => item.type === "function_call");
891
905
  if (functionCalls.length > 0) {
@@ -625,6 +625,70 @@
625
625
  background: rgba(78, 161, 255, 0.06);
626
626
  }
627
627
 
628
+ /* ───────────────────────────────────────────────
629
+ JSON-table DataGrid
630
+ Rendered by <JsonDataTable /> instead of markdown pipe tables.
631
+ Uses the same CSS variables as .markdown-content table so it
632
+ inherits theme colours automatically.
633
+ ─────────────────────────────────────────────── */
634
+ .mcp-data-table-wrapper {
635
+ width: 100%;
636
+ overflow-x: auto;
637
+ margin: 0 0 14px 0;
638
+ border-radius: 6px;
639
+ }
640
+
641
+ .mcp-data-table {
642
+ width: 100%;
643
+ border-collapse: collapse;
644
+ font-size: 14px;
645
+ min-width: 400px;
646
+ }
647
+
648
+ .mcp-data-table thead {
649
+ background: rgba(78, 161, 255, 0.12);
650
+ }
651
+
652
+ .mcp-data-table th {
653
+ text-align: left;
654
+ font-weight: 600;
655
+ padding: 9px 13px;
656
+ border: 1px solid var(--mcp-border);
657
+ white-space: nowrap;
658
+ color: var(--mcp-text);
659
+ position: sticky;
660
+ top: 0;
661
+ background: inherit;
662
+ }
663
+
664
+ .mcp-data-table td {
665
+ padding: 7px 13px;
666
+ border: 1px solid var(--mcp-border);
667
+ vertical-align: top;
668
+ color: var(--mcp-text);
669
+ word-break: break-word;
670
+ }
671
+
672
+ .mcp-data-table tbody tr:nth-child(even) {
673
+ background: rgba(255, 255, 255, 0.03);
674
+ }
675
+
676
+ .mcp-data-table tbody tr:hover {
677
+ background: rgba(78, 161, 255, 0.08);
678
+ transition: background 0.12s;
679
+ }
680
+
681
+ /* Light theme overrides for json-table */
682
+ .mcp-root[data-theme="light"] .mcp-data-table thead {
683
+ background: rgba(29, 111, 232, 0.08);
684
+ }
685
+ .mcp-root[data-theme="light"] .mcp-data-table tbody tr:nth-child(even) {
686
+ background: rgba(0, 0, 0, 0.02);
687
+ }
688
+ .mcp-root[data-theme="light"] .mcp-data-table tbody tr:hover {
689
+ background: rgba(29, 111, 232, 0.06);
690
+ }
691
+
628
692
  /* Light theme overrides for markdown */
629
693
  .mcp-root[data-theme="light"] .markdown-content code {
630
694
  background: rgba(0, 0, 0, 0.06);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nqminds/mcp-client",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "Reusable MCP client component with AI chat interface",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",