@inkeep/agents-run-api 0.0.0-dev-20251003220013 → 0.0.0-dev-20251003235339
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/index.cjs +49 -2
- package/dist/index.js +49 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -6656,6 +6656,8 @@ var Agent = class {
|
|
|
6656
6656
|
__publicField(this, "isDelegatedAgent", false);
|
|
6657
6657
|
__publicField(this, "contextResolver");
|
|
6658
6658
|
__publicField(this, "credentialStoreRegistry");
|
|
6659
|
+
__publicField(this, "mcpClientCache", /* @__PURE__ */ new Map());
|
|
6660
|
+
__publicField(this, "mcpConnectionLocks", /* @__PURE__ */ new Map());
|
|
6659
6661
|
this.artifactComponents = config.artifactComponents || [];
|
|
6660
6662
|
let processedDataComponents = config.dataComponents || [];
|
|
6661
6663
|
if (processedDataComponents.length > 0) {
|
|
@@ -6978,6 +6980,7 @@ var Agent = class {
|
|
|
6978
6980
|
};
|
|
6979
6981
|
}
|
|
6980
6982
|
async getMcpTool(tool3) {
|
|
6983
|
+
const cacheKey = `${this.config.tenantId}-${this.config.projectId}-${tool3.id}-${tool3.credentialReferenceId || "no-cred"}`;
|
|
6981
6984
|
const credentialReferenceId = tool3.credentialReferenceId;
|
|
6982
6985
|
const toolsForAgent = await agentsCore.getToolsForAgent(dbClient_default)({
|
|
6983
6986
|
scopes: {
|
|
@@ -7046,12 +7049,56 @@ var Agent = class {
|
|
|
7046
7049
|
},
|
|
7047
7050
|
"Built MCP server config with credentials"
|
|
7048
7051
|
);
|
|
7052
|
+
let client = this.mcpClientCache.get(cacheKey);
|
|
7053
|
+
if (client && !client.isConnected()) {
|
|
7054
|
+
this.mcpClientCache.delete(cacheKey);
|
|
7055
|
+
client = void 0;
|
|
7056
|
+
}
|
|
7057
|
+
if (!client) {
|
|
7058
|
+
let connectionPromise = this.mcpConnectionLocks.get(cacheKey);
|
|
7059
|
+
if (!connectionPromise) {
|
|
7060
|
+
connectionPromise = this.createMcpConnection(tool3, serverConfig);
|
|
7061
|
+
this.mcpConnectionLocks.set(cacheKey, connectionPromise);
|
|
7062
|
+
}
|
|
7063
|
+
try {
|
|
7064
|
+
client = await connectionPromise;
|
|
7065
|
+
this.mcpClientCache.set(cacheKey, client);
|
|
7066
|
+
} catch (error) {
|
|
7067
|
+
this.mcpConnectionLocks.delete(cacheKey);
|
|
7068
|
+
logger17.error(
|
|
7069
|
+
{
|
|
7070
|
+
toolName: tool3.name,
|
|
7071
|
+
agentId: this.config.id,
|
|
7072
|
+
cacheKey,
|
|
7073
|
+
error: error instanceof Error ? error.message : String(error)
|
|
7074
|
+
},
|
|
7075
|
+
"MCP connection failed"
|
|
7076
|
+
);
|
|
7077
|
+
throw error;
|
|
7078
|
+
}
|
|
7079
|
+
}
|
|
7080
|
+
const tools = await client.tools();
|
|
7081
|
+
return tools;
|
|
7082
|
+
}
|
|
7083
|
+
async createMcpConnection(tool3, serverConfig) {
|
|
7049
7084
|
const client = new agentsCore.McpClient({
|
|
7050
7085
|
name: tool3.name,
|
|
7051
7086
|
server: serverConfig
|
|
7052
7087
|
});
|
|
7053
|
-
|
|
7054
|
-
|
|
7088
|
+
try {
|
|
7089
|
+
await client.connect();
|
|
7090
|
+
return client;
|
|
7091
|
+
} catch (error) {
|
|
7092
|
+
logger17.error(
|
|
7093
|
+
{
|
|
7094
|
+
toolName: tool3.name,
|
|
7095
|
+
agentId: this.config.id,
|
|
7096
|
+
error: error instanceof Error ? error.message : String(error)
|
|
7097
|
+
},
|
|
7098
|
+
"Agent failed to connect to MCP server"
|
|
7099
|
+
);
|
|
7100
|
+
throw error;
|
|
7101
|
+
}
|
|
7055
7102
|
}
|
|
7056
7103
|
getFunctionTools(streamRequestId) {
|
|
7057
7104
|
if (!this.config.functionTools) return {};
|
package/dist/index.js
CHANGED
|
@@ -6163,6 +6163,8 @@ var Agent = class {
|
|
|
6163
6163
|
__publicField(this, "isDelegatedAgent", false);
|
|
6164
6164
|
__publicField(this, "contextResolver");
|
|
6165
6165
|
__publicField(this, "credentialStoreRegistry");
|
|
6166
|
+
__publicField(this, "mcpClientCache", /* @__PURE__ */ new Map());
|
|
6167
|
+
__publicField(this, "mcpConnectionLocks", /* @__PURE__ */ new Map());
|
|
6166
6168
|
this.artifactComponents = config.artifactComponents || [];
|
|
6167
6169
|
let processedDataComponents = config.dataComponents || [];
|
|
6168
6170
|
if (processedDataComponents.length > 0) {
|
|
@@ -6485,6 +6487,7 @@ var Agent = class {
|
|
|
6485
6487
|
};
|
|
6486
6488
|
}
|
|
6487
6489
|
async getMcpTool(tool3) {
|
|
6490
|
+
const cacheKey = `${this.config.tenantId}-${this.config.projectId}-${tool3.id}-${tool3.credentialReferenceId || "no-cred"}`;
|
|
6488
6491
|
const credentialReferenceId = tool3.credentialReferenceId;
|
|
6489
6492
|
const toolsForAgent = await getToolsForAgent(dbClient_default)({
|
|
6490
6493
|
scopes: {
|
|
@@ -6553,12 +6556,56 @@ var Agent = class {
|
|
|
6553
6556
|
},
|
|
6554
6557
|
"Built MCP server config with credentials"
|
|
6555
6558
|
);
|
|
6559
|
+
let client = this.mcpClientCache.get(cacheKey);
|
|
6560
|
+
if (client && !client.isConnected()) {
|
|
6561
|
+
this.mcpClientCache.delete(cacheKey);
|
|
6562
|
+
client = void 0;
|
|
6563
|
+
}
|
|
6564
|
+
if (!client) {
|
|
6565
|
+
let connectionPromise = this.mcpConnectionLocks.get(cacheKey);
|
|
6566
|
+
if (!connectionPromise) {
|
|
6567
|
+
connectionPromise = this.createMcpConnection(tool3, serverConfig);
|
|
6568
|
+
this.mcpConnectionLocks.set(cacheKey, connectionPromise);
|
|
6569
|
+
}
|
|
6570
|
+
try {
|
|
6571
|
+
client = await connectionPromise;
|
|
6572
|
+
this.mcpClientCache.set(cacheKey, client);
|
|
6573
|
+
} catch (error) {
|
|
6574
|
+
this.mcpConnectionLocks.delete(cacheKey);
|
|
6575
|
+
logger16.error(
|
|
6576
|
+
{
|
|
6577
|
+
toolName: tool3.name,
|
|
6578
|
+
agentId: this.config.id,
|
|
6579
|
+
cacheKey,
|
|
6580
|
+
error: error instanceof Error ? error.message : String(error)
|
|
6581
|
+
},
|
|
6582
|
+
"MCP connection failed"
|
|
6583
|
+
);
|
|
6584
|
+
throw error;
|
|
6585
|
+
}
|
|
6586
|
+
}
|
|
6587
|
+
const tools = await client.tools();
|
|
6588
|
+
return tools;
|
|
6589
|
+
}
|
|
6590
|
+
async createMcpConnection(tool3, serverConfig) {
|
|
6556
6591
|
const client = new McpClient({
|
|
6557
6592
|
name: tool3.name,
|
|
6558
6593
|
server: serverConfig
|
|
6559
6594
|
});
|
|
6560
|
-
|
|
6561
|
-
|
|
6595
|
+
try {
|
|
6596
|
+
await client.connect();
|
|
6597
|
+
return client;
|
|
6598
|
+
} catch (error) {
|
|
6599
|
+
logger16.error(
|
|
6600
|
+
{
|
|
6601
|
+
toolName: tool3.name,
|
|
6602
|
+
agentId: this.config.id,
|
|
6603
|
+
error: error instanceof Error ? error.message : String(error)
|
|
6604
|
+
},
|
|
6605
|
+
"Agent failed to connect to MCP server"
|
|
6606
|
+
);
|
|
6607
|
+
throw error;
|
|
6608
|
+
}
|
|
6562
6609
|
}
|
|
6563
6610
|
getFunctionTools(streamRequestId) {
|
|
6564
6611
|
if (!this.config.functionTools) return {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-run-api",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20251003235339",
|
|
4
4
|
"description": "Agents Run API for Inkeep Agent Framework - handles chat, agent execution, and streaming",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"traverse": "^0.6.11",
|
|
52
52
|
"ts-pattern": "^5.7.1",
|
|
53
53
|
"zod": "^4.1.11",
|
|
54
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
54
|
+
"@inkeep/agents-core": "^0.0.0-dev-20251003235339"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
57
|
"keytar": "^7.9.0"
|