@nqminds/mcp-client 1.0.32 → 1.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MCPChat.d.ts.map +1 -1
- package/dist/MCPChat.js +58 -98
- package/dist/api-helpers.d.ts.map +1 -1
- package/dist/api-helpers.js +9 -5
- package/dist/openai-client.d.ts +11 -0
- package/dist/openai-client.d.ts.map +1 -1
- package/dist/openai-client.js +7 -1
- package/dist/styles/MCPChat.css +64 -0
- package/package.json +1 -1
package/dist/MCPChat.d.ts.map
CHANGED
|
@@ -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;
|
|
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
|
-
*
|
|
15
|
+
* Renders a structured json-table block as an HTML table.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
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
|
-
*
|
|
31
|
-
*
|
|
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
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
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(
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)),
|
|
@@ -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;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,
|
|
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,uBA0H/B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,KACrB,SAAS,OAAO,uBAW/B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,kBAKtC"}
|
package/dist/api-helpers.js
CHANGED
|
@@ -9,9 +9,10 @@ const clients = new Map();
|
|
|
9
9
|
*/
|
|
10
10
|
export function createMCPChatHandler(config) {
|
|
11
11
|
return async (request) => {
|
|
12
|
-
const { message, context, sessionId = "default", bypassSystemPrompt = false } = await request.json();
|
|
12
|
+
const { message, context, sessionId = "default", bypassSystemPrompt = false, systemPromptName = "system-prompt" } = await request.json();
|
|
13
13
|
// Get or create client for this session
|
|
14
|
-
|
|
14
|
+
const cacheKey = `${sessionId}:${systemPromptName}`;
|
|
15
|
+
let client = clients.get(cacheKey);
|
|
15
16
|
if (!client) {
|
|
16
17
|
client = new MCPClientOpenAI({
|
|
17
18
|
openaiApiKey: config.openaiApiKey,
|
|
@@ -20,9 +21,11 @@ export function createMCPChatHandler(config) {
|
|
|
20
21
|
logDir: config.logDir || process.env.MCP_LOG_DIR,
|
|
21
22
|
enableCodeInterpreter: config.enableCodeInterpreter,
|
|
22
23
|
codeInterpreterMemoryLimit: config.codeInterpreterMemoryLimit,
|
|
24
|
+
systemPromptName,
|
|
25
|
+
systemPromptArgs: sessionId !== "default" ? { company_number: sessionId } : {},
|
|
23
26
|
});
|
|
24
27
|
await client.connect();
|
|
25
|
-
clients.set(
|
|
28
|
+
clients.set(cacheKey, client);
|
|
26
29
|
}
|
|
27
30
|
// Create an AbortController to handle client disconnection
|
|
28
31
|
const abortController = new AbortController();
|
|
@@ -118,8 +121,9 @@ export function createMCPChatHandler(config) {
|
|
|
118
121
|
*/
|
|
119
122
|
export function createMCPClearHandler() {
|
|
120
123
|
return async (request) => {
|
|
121
|
-
const { sessionId = "default" } = await request.json();
|
|
122
|
-
const
|
|
124
|
+
const { sessionId = "default", systemPromptName = "system-prompt" } = await request.json();
|
|
125
|
+
const cacheKey = `${sessionId}:${systemPromptName}`;
|
|
126
|
+
const client = clients.get(cacheKey);
|
|
123
127
|
if (client) {
|
|
124
128
|
client.clearHistory();
|
|
125
129
|
}
|
package/dist/openai-client.d.ts
CHANGED
|
@@ -57,6 +57,17 @@ export interface MCPClientConfig {
|
|
|
57
57
|
* Omit to use OpenAI's default (1 GB).
|
|
58
58
|
*/
|
|
59
59
|
codeInterpreterMemoryLimit?: "1g" | "2g" | "4g";
|
|
60
|
+
/**
|
|
61
|
+
* Name of the MCP prompt to use as the system prompt.
|
|
62
|
+
* Defaults to "system-prompt".
|
|
63
|
+
*/
|
|
64
|
+
systemPromptName?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Optional arguments to pass when fetching the system prompt from the MCP server.
|
|
67
|
+
* Required when the prompt has a non-empty argsSchema (e.g. company_financial_synopsis needs company_number).
|
|
68
|
+
* Defaults to {} (no arguments).
|
|
69
|
+
*/
|
|
70
|
+
systemPromptArgs?: Record<string, string>;
|
|
60
71
|
}
|
|
61
72
|
interface UsageStats {
|
|
62
73
|
inputTokens: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-client.d.ts","sourceRoot":"","sources":["../src/openai-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAsEH,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;;;;OAKG;IACH,0BAA0B,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"openai-client.d.ts","sourceRoot":"","sources":["../src/openai-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAsEH,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;;;;OAKG;IACH,0BAA0B,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAEhD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAID,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;CACxB;AAiBD,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAuB;IAExC;;;OAGG;IACH,OAAO,CAAC,YAAY,CAAuB;IAE3C;;;OAGG;IACH,OAAO,CAAC,mBAAmB,CAA2B;IAEtD;;;OAGG;IACH,OAAO,CAAC,UAAU,CAGhB;IAEF;;OAEG;IACH,OAAO,CAAC,eAAe,CAAK;IAE5B;;OAEG;IACH,OAAO,CAAC,SAAS,CAOf;IAEF;;;;OAIG;IACH,OAAO,CAAC,SAAS,CAKf;IAEF,OAAO,CAAC,MAAM,CAA0L;IACxM,OAAO,CAAC,MAAM,CAAa;gBAEf,MAAM,EAAE,eAAe;IA2C7B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B,YAAY,IAAI,IAAI;IAmBpB,QAAQ,IAAI,UAAU;IAItB;;;OAGG;YACW,kBAAkB;IA8BhC;;;OAGG;IACH,OAAO,CAAC,UAAU;IAalB;;;OAGG;YACW,gBAAgB;IAuB9B;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAUhC;;OAEG;IACH,OAAO,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"}
|
package/dist/openai-client.js
CHANGED
|
@@ -140,6 +140,8 @@ export class MCPClientOpenAI {
|
|
|
140
140
|
logDir: config.logDir ?? process.env.MCP_LOG_DIR ?? path.resolve(process.cwd(), "logs"),
|
|
141
141
|
enableCodeInterpreter: config.enableCodeInterpreter ?? false,
|
|
142
142
|
codeInterpreterMemoryLimit: config.codeInterpreterMemoryLimit,
|
|
143
|
+
systemPromptName: config.systemPromptName ?? "system-prompt",
|
|
144
|
+
systemPromptArgs: config.systemPromptArgs ?? {},
|
|
143
145
|
};
|
|
144
146
|
this.logger = new McpLogger(this.config.logDir);
|
|
145
147
|
this.openai = new OpenAI({
|
|
@@ -198,7 +200,11 @@ export class MCPClientOpenAI {
|
|
|
198
200
|
try {
|
|
199
201
|
// SDK typing may not expose getPrompt.
|
|
200
202
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
201
|
-
const
|
|
203
|
+
const promptArgs = this.config.systemPromptArgs;
|
|
204
|
+
const result = await this.client.getPrompt({
|
|
205
|
+
name: this.config.systemPromptName,
|
|
206
|
+
...(Object.keys(promptArgs).length > 0 && { arguments: promptArgs }),
|
|
207
|
+
});
|
|
202
208
|
const parts = [];
|
|
203
209
|
for (const msg of result.messages ?? []) {
|
|
204
210
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/dist/styles/MCPChat.css
CHANGED
|
@@ -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);
|