@nqminds/mcp-client 1.0.31 → 1.0.32
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/api-helpers.d.ts +11 -0
- package/dist/api-helpers.d.ts.map +1 -1
- package/dist/api-helpers.js +2 -0
- package/dist/openai-client.d.ts +14 -0
- package/dist/openai-client.d.ts.map +1 -1
- package/dist/openai-client.js +14 -0
- package/package.json +1 -1
package/dist/api-helpers.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/api-helpers.js
CHANGED
|
@@ -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);
|
package/dist/openai-client.d.ts
CHANGED
|
@@ -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":["../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;
|
|
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,EA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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
|
@@ -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) {
|