@opentiny/next-sdk 0.1.2 → 0.1.3-alpha.1

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.
@@ -42,6 +42,19 @@ export class AgentModelProvider {
42
42
  this.isGetMcpClients = true
43
43
  }
44
44
  }
45
+
46
+ async updateMcpServers(mcpServers: McpServerConfig[]) {
47
+ this.mcpServers = mcpServers
48
+ this.isGetMcpClients = false
49
+ return await this.initClients()
50
+ }
51
+
52
+ async insertMcpServers(mcpServers: McpServerConfig[]) {
53
+ this.mcpServers = [...this.mcpServers, ...mcpServers]
54
+ this.isGetMcpClients = false
55
+ return await this.initClients()
56
+ }
57
+
45
58
  async chat({
46
59
  model,
47
60
  maxSteps = 5,
@@ -23,7 +23,7 @@ export const getMcpClients = async (mcpServers: McpServerConfig[]) => {
23
23
  transport = item as MCPClientConfig['transport'] // sse 或 自定义的 MCPTranport
24
24
  }
25
25
 
26
- return createMCPClient({ transport: transport as MCPClientConfig['transport'] })
26
+ return await createMCPClient({ transport: transport as MCPClientConfig['transport'] })
27
27
  } catch (error) {
28
28
  console.error(`Failed to create MCP client`, item, error)
29
29
  return []
@@ -9,6 +9,8 @@ export declare class AgentModelProvider {
9
9
  mcpClients: any[];
10
10
  constructor({ llmConfig, mcpServers, llm }: IAgentModelProviderOption);
11
11
  initClients(): Promise<void>;
12
+ updateMcpServers(mcpServers: McpServerConfig[]): Promise<void>;
13
+ insertMcpServers(mcpServers: McpServerConfig[]): Promise<void>;
12
14
  chat({ model, maxSteps, ...options }: Parameters<typeof generateText>[0] & {
13
15
  maxSteps?: number;
14
16
  }): Promise<any>;
@@ -56,6 +56,20 @@ export class AgentModelProvider {
56
56
  }
57
57
  });
58
58
  }
59
+ updateMcpServers(mcpServers) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ this.mcpServers = mcpServers;
62
+ this.isGetMcpClients = false;
63
+ return yield this.initClients();
64
+ });
65
+ }
66
+ insertMcpServers(mcpServers) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ this.mcpServers = [...this.mcpServers, ...mcpServers];
69
+ this.isGetMcpClients = false;
70
+ return yield this.initClients();
71
+ });
72
+ }
59
73
  chat(_a) {
60
74
  return __awaiter(this, void 0, void 0, function* () {
61
75
  var { model, maxSteps = 5 } = _a, options = __rest(_a, ["model", "maxSteps"]);
@@ -28,7 +28,7 @@ export const getMcpClients = (mcpServers) => __awaiter(void 0, void 0, void 0, f
28
28
  else {
29
29
  transport = item; // sse 或 自定义的 MCPTranport
30
30
  }
31
- return createMCPClient({ transport: transport });
31
+ return yield createMCPClient({ transport: transport });
32
32
  }
33
33
  catch (error) {
34
34
  console.error(`Failed to create MCP client`, item, error);