@azure/ai-agents 1.1.0-beta.2 → 1.1.0

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.
Files changed (127) hide show
  1. package/README.md +0 -75
  2. package/dist/browser/api/agentsContext.js +2 -2
  3. package/dist/browser/api/agentsContext.js.map +1 -1
  4. package/dist/browser/api/runs/operations.d.ts.map +1 -1
  5. package/dist/browser/api/runs/operations.js +1 -4
  6. package/dist/browser/api/runs/operations.js.map +1 -1
  7. package/dist/browser/api/runs/options.d.ts +1 -5
  8. package/dist/browser/api/runs/options.d.ts.map +1 -1
  9. package/dist/browser/api/runs/options.js.map +1 -1
  10. package/dist/browser/constants.d.ts +1 -1
  11. package/dist/browser/constants.d.ts.map +1 -1
  12. package/dist/browser/constants.js +1 -1
  13. package/dist/browser/constants.js.map +1 -1
  14. package/dist/browser/index.d.ts +1 -2
  15. package/dist/browser/index.d.ts.map +1 -1
  16. package/dist/browser/index.js +0 -1
  17. package/dist/browser/index.js.map +1 -1
  18. package/dist/browser/models/index.d.ts +1 -1
  19. package/dist/browser/models/index.d.ts.map +1 -1
  20. package/dist/browser/models/index.js.map +1 -1
  21. package/dist/browser/models/models.d.ts +9 -257
  22. package/dist/browser/models/models.d.ts.map +1 -1
  23. package/dist/browser/models/models.js +6 -326
  24. package/dist/browser/models/models.js.map +1 -1
  25. package/dist/browser/utils/utils.d.ts +1 -61
  26. package/dist/browser/utils/utils.d.ts.map +1 -1
  27. package/dist/browser/utils/utils.js +0 -90
  28. package/dist/browser/utils/utils.js.map +1 -1
  29. package/dist/commonjs/api/agentsContext.js +2 -2
  30. package/dist/commonjs/api/agentsContext.js.map +1 -1
  31. package/dist/commonjs/api/runs/operations.d.ts.map +1 -1
  32. package/dist/commonjs/api/runs/operations.js +0 -3
  33. package/dist/commonjs/api/runs/operations.js.map +1 -1
  34. package/dist/commonjs/api/runs/options.d.ts +1 -5
  35. package/dist/commonjs/api/runs/options.d.ts.map +1 -1
  36. package/dist/commonjs/api/runs/options.js.map +1 -1
  37. package/dist/commonjs/constants.d.ts +1 -1
  38. package/dist/commonjs/constants.d.ts.map +1 -1
  39. package/dist/commonjs/constants.js +1 -1
  40. package/dist/commonjs/constants.js.map +1 -1
  41. package/dist/commonjs/index.d.ts +1 -2
  42. package/dist/commonjs/index.d.ts.map +1 -1
  43. package/dist/commonjs/index.js +1 -3
  44. package/dist/commonjs/index.js.map +1 -1
  45. package/dist/commonjs/models/index.d.ts +1 -1
  46. package/dist/commonjs/models/index.d.ts.map +1 -1
  47. package/dist/commonjs/models/index.js.map +1 -1
  48. package/dist/commonjs/models/models.d.ts +9 -257
  49. package/dist/commonjs/models/models.d.ts.map +1 -1
  50. package/dist/commonjs/models/models.js +6 -371
  51. package/dist/commonjs/models/models.js.map +1 -1
  52. package/dist/commonjs/tsdoc-metadata.json +1 -1
  53. package/dist/commonjs/utils/utils.d.ts +1 -61
  54. package/dist/commonjs/utils/utils.d.ts.map +1 -1
  55. package/dist/commonjs/utils/utils.js +0 -90
  56. package/dist/commonjs/utils/utils.js.map +1 -1
  57. package/dist/esm/api/agentsContext.js +2 -2
  58. package/dist/esm/api/agentsContext.js.map +1 -1
  59. package/dist/esm/api/runs/operations.d.ts.map +1 -1
  60. package/dist/esm/api/runs/operations.js +1 -4
  61. package/dist/esm/api/runs/operations.js.map +1 -1
  62. package/dist/esm/api/runs/options.d.ts +1 -5
  63. package/dist/esm/api/runs/options.d.ts.map +1 -1
  64. package/dist/esm/api/runs/options.js.map +1 -1
  65. package/dist/esm/constants.d.ts +1 -1
  66. package/dist/esm/constants.d.ts.map +1 -1
  67. package/dist/esm/constants.js +1 -1
  68. package/dist/esm/constants.js.map +1 -1
  69. package/dist/esm/index.d.ts +1 -2
  70. package/dist/esm/index.d.ts.map +1 -1
  71. package/dist/esm/index.js +0 -1
  72. package/dist/esm/index.js.map +1 -1
  73. package/dist/esm/models/index.d.ts +1 -1
  74. package/dist/esm/models/index.d.ts.map +1 -1
  75. package/dist/esm/models/index.js.map +1 -1
  76. package/dist/esm/models/models.d.ts +9 -257
  77. package/dist/esm/models/models.d.ts.map +1 -1
  78. package/dist/esm/models/models.js +6 -326
  79. package/dist/esm/models/models.js.map +1 -1
  80. package/dist/esm/utils/utils.d.ts +1 -61
  81. package/dist/esm/utils/utils.d.ts.map +1 -1
  82. package/dist/esm/utils/utils.js +0 -90
  83. package/dist/esm/utils/utils.js.map +1 -1
  84. package/dist/react-native/api/agentsContext.js +2 -2
  85. package/dist/react-native/api/agentsContext.js.map +1 -1
  86. package/dist/react-native/api/runs/operations.d.ts.map +1 -1
  87. package/dist/react-native/api/runs/operations.js +1 -4
  88. package/dist/react-native/api/runs/operations.js.map +1 -1
  89. package/dist/react-native/api/runs/options.d.ts +1 -5
  90. package/dist/react-native/api/runs/options.d.ts.map +1 -1
  91. package/dist/react-native/api/runs/options.js.map +1 -1
  92. package/dist/react-native/constants.d.ts +1 -1
  93. package/dist/react-native/constants.d.ts.map +1 -1
  94. package/dist/react-native/constants.js +1 -1
  95. package/dist/react-native/constants.js.map +1 -1
  96. package/dist/react-native/index.d.ts +1 -2
  97. package/dist/react-native/index.d.ts.map +1 -1
  98. package/dist/react-native/index.js +0 -1
  99. package/dist/react-native/index.js.map +1 -1
  100. package/dist/react-native/models/index.d.ts +1 -1
  101. package/dist/react-native/models/index.d.ts.map +1 -1
  102. package/dist/react-native/models/index.js.map +1 -1
  103. package/dist/react-native/models/models.d.ts +9 -257
  104. package/dist/react-native/models/models.d.ts.map +1 -1
  105. package/dist/react-native/models/models.js +6 -326
  106. package/dist/react-native/models/models.js.map +1 -1
  107. package/dist/react-native/utils/utils.d.ts +1 -61
  108. package/dist/react-native/utils/utils.d.ts.map +1 -1
  109. package/dist/react-native/utils/utils.js +0 -90
  110. package/dist/react-native/utils/utils.js.map +1 -1
  111. package/package.json +2 -1
  112. package/dist/browser/utils/MCPTool.d.ts +0 -78
  113. package/dist/browser/utils/MCPTool.d.ts.map +0 -1
  114. package/dist/browser/utils/MCPTool.js +0 -133
  115. package/dist/browser/utils/MCPTool.js.map +0 -1
  116. package/dist/commonjs/utils/MCPTool.d.ts +0 -78
  117. package/dist/commonjs/utils/MCPTool.d.ts.map +0 -1
  118. package/dist/commonjs/utils/MCPTool.js +0 -137
  119. package/dist/commonjs/utils/MCPTool.js.map +0 -1
  120. package/dist/esm/utils/MCPTool.d.ts +0 -78
  121. package/dist/esm/utils/MCPTool.d.ts.map +0 -1
  122. package/dist/esm/utils/MCPTool.js +0 -133
  123. package/dist/esm/utils/MCPTool.js.map +0 -1
  124. package/dist/react-native/utils/MCPTool.d.ts +0 -78
  125. package/dist/react-native/utils/MCPTool.d.ts.map +0 -1
  126. package/dist/react-native/utils/MCPTool.js +0 -133
  127. package/dist/react-native/utils/MCPTool.js.map +0 -1
@@ -1,78 +0,0 @@
1
- import { MCPToolDefinition, ToolResources } from "../index.js";
2
- /**
3
- * A tool that connects to Model Context Protocol (MCP) servers.
4
- * Supports managing MCP server connections and allowed tools dynamically.
5
- */
6
- export declare class MCPTool {
7
- private _serverLabel;
8
- private _serverUrl;
9
- private _allowedTools;
10
- private _requireApproval?;
11
- private _headers;
12
- /**
13
- * Constructor initializes the tool with MCP server configuration.
14
- * @param serverLabel - The label for the MCP server
15
- * @param serverUrl - The endpoint for the MCP server
16
- * @param allowedTools - List of allowed tools for MCP server
17
- */
18
- constructor(serverLabel: string, serverUrl: string, allowedTools?: string[]);
19
- /**
20
- * Get the MCP tool resource.
21
- * @returns The MCP tool resource
22
- */
23
- private get _resource();
24
- /**
25
- * Set the MCP tool definition.
26
- * @returns The MCP tool definition
27
- * */
28
- private get _definition();
29
- /**
30
- * Get the MCP tool definition.
31
- * @returns A list containing the MCP tool definition
32
- */
33
- get definitions(): MCPToolDefinition[];
34
- /**
35
- * Add a tool to the list of allowed tools.
36
- * @param toolName - The name of the tool to allow
37
- */
38
- allowTool(toolName: string): void;
39
- /**
40
- * Remove a tool from the list of allowed tools.
41
- * @param toolName - The name of the tool to remove from allowed tools
42
- * @throws Error if the tool is not in the allowed tools list
43
- */
44
- disallowTool(toolName: string): void;
45
- /**
46
- * Update the approval mode for the MCP tool.
47
- * @param requireApproval - The require_approval setting to update
48
- */
49
- setApprovalMode(requireApproval?: "always" | "never"): void;
50
- /**
51
- * Update the headers for the MCP tool.
52
- * @param key - The header key to update
53
- * @param value - The new value for the header key
54
- * @throws Error if the key is empty
55
- */
56
- updateHeaders(key: string, value: string): void;
57
- /**
58
- * Get the server label for the MCP tool.
59
- */
60
- get serverLabel(): string;
61
- /**
62
- * Get the server URL for the MCP tool.
63
- */
64
- get serverUrl(): string;
65
- /**
66
- * Get the list of allowed tools for the MCP server.
67
- */
68
- get allowedTools(): string[];
69
- /**
70
- * Get the headers for the MCP tool.
71
- */
72
- get headers(): Record<string, string>;
73
- /**
74
- * Get the tool resources for the agent.
75
- */
76
- get resources(): ToolResources;
77
- }
78
- //# sourceMappingURL=MCPTool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MCPTool.d.ts","sourceRoot":"","sources":["../../../src/utils/MCPTool.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAChF;;;GAGG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,gBAAgB,CAAC,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAyB;IAEzC;;;;;OAKG;gBACS,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE;IAO3E;;;OAGG;IACH,OAAO,KAAK,SAAS,GAMpB;IAED;;;SAGK;IACL,OAAO,KAAK,WAAW,GAOtB;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,iBAAiB,EAAE,CAErC;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMjC;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IASpC;;;OAGG;IACH,eAAe,CAAC,eAAe,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI;IAI3D;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ/C;;OAEG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,EAAE,CAE3B;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEpC;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,aAAa,CAI7B;CACF"}
@@ -1,137 +0,0 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.MCPTool = void 0;
6
- /**
7
- * A tool that connects to Model Context Protocol (MCP) servers.
8
- * Supports managing MCP server connections and allowed tools dynamically.
9
- */
10
- class MCPTool {
11
- _serverLabel;
12
- _serverUrl;
13
- _allowedTools;
14
- _requireApproval;
15
- _headers;
16
- /**
17
- * Constructor initializes the tool with MCP server configuration.
18
- * @param serverLabel - The label for the MCP server
19
- * @param serverUrl - The endpoint for the MCP server
20
- * @param allowedTools - List of allowed tools for MCP server
21
- */
22
- constructor(serverLabel, serverUrl, allowedTools) {
23
- this._serverLabel = serverLabel;
24
- this._serverUrl = serverUrl;
25
- this._allowedTools = allowedTools || [];
26
- this._requireApproval = "always"; // Default to always require approval
27
- this._headers = {};
28
- }
29
- /**
30
- * Get the MCP tool resource.
31
- * @returns The MCP tool resource
32
- */
33
- get _resource() {
34
- return {
35
- serverLabel: this._serverLabel,
36
- headers: this._headers,
37
- requireApproval: this._requireApproval,
38
- };
39
- }
40
- /**
41
- * Set the MCP tool definition.
42
- * @returns The MCP tool definition
43
- * */
44
- get _definition() {
45
- return {
46
- type: "mcp",
47
- serverLabel: this._serverLabel,
48
- serverUrl: this._serverUrl,
49
- allowedTools: this._allowedTools.length > 0 ? this._allowedTools : undefined,
50
- };
51
- }
52
- /**
53
- * Get the MCP tool definition.
54
- * @returns A list containing the MCP tool definition
55
- */
56
- get definitions() {
57
- return [this._definition];
58
- }
59
- /**
60
- * Add a tool to the list of allowed tools.
61
- * @param toolName - The name of the tool to allow
62
- */
63
- allowTool(toolName) {
64
- if (!this._allowedTools.includes(toolName)) {
65
- this._allowedTools.push(toolName);
66
- }
67
- }
68
- /**
69
- * Remove a tool from the list of allowed tools.
70
- * @param toolName - The name of the tool to remove from allowed tools
71
- * @throws Error if the tool is not in the allowed tools list
72
- */
73
- disallowTool(toolName) {
74
- const index = this._allowedTools.indexOf(toolName);
75
- if (index > -1) {
76
- this._allowedTools.splice(index, 1);
77
- }
78
- else {
79
- throw new Error(`Tool '${toolName}' is not in the allowed tools list.`);
80
- }
81
- }
82
- /**
83
- * Update the approval mode for the MCP tool.
84
- * @param requireApproval - The require_approval setting to update
85
- */
86
- setApprovalMode(requireApproval) {
87
- this._requireApproval = requireApproval;
88
- }
89
- /**
90
- * Update the headers for the MCP tool.
91
- * @param key - The header key to update
92
- * @param value - The new value for the header key
93
- * @throws Error if the key is empty
94
- */
95
- updateHeaders(key, value) {
96
- if (key) {
97
- this._headers[key] = value;
98
- }
99
- else {
100
- throw new Error("Header key cannot be empty.");
101
- }
102
- }
103
- /**
104
- * Get the server label for the MCP tool.
105
- */
106
- get serverLabel() {
107
- return this._serverLabel;
108
- }
109
- /**
110
- * Get the server URL for the MCP tool.
111
- */
112
- get serverUrl() {
113
- return this._serverUrl;
114
- }
115
- /**
116
- * Get the list of allowed tools for the MCP server.
117
- */
118
- get allowedTools() {
119
- return [...this._allowedTools];
120
- }
121
- /**
122
- * Get the headers for the MCP tool.
123
- */
124
- get headers() {
125
- return { ...this._headers };
126
- }
127
- /**
128
- * Get the tool resources for the agent.
129
- */
130
- get resources() {
131
- return {
132
- mcp: [this._resource],
133
- };
134
- }
135
- }
136
- exports.MCPTool = MCPTool;
137
- //# sourceMappingURL=MCPTool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MCPTool.js","sourceRoot":"","sources":["../../../src/utils/MCPTool.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { MCPToolDefinition, MCPToolResource, ToolResources } from \"../index.js\";\n/**\n * A tool that connects to Model Context Protocol (MCP) servers.\n * Supports managing MCP server connections and allowed tools dynamically.\n */\nexport class MCPTool {\n private _serverLabel: string;\n private _serverUrl: string;\n private _allowedTools: string[];\n private _requireApproval?: \"always\" | \"never\";\n private _headers: Record<string, string>;\n\n /**\n * Constructor initializes the tool with MCP server configuration.\n * @param serverLabel - The label for the MCP server\n * @param serverUrl - The endpoint for the MCP server\n * @param allowedTools - List of allowed tools for MCP server\n */\n constructor(serverLabel: string, serverUrl: string, allowedTools?: string[]) {\n this._serverLabel = serverLabel;\n this._serverUrl = serverUrl;\n this._allowedTools = allowedTools || [];\n this._requireApproval = \"always\"; // Default to always require approval\n this._headers = {};\n }\n /**\n * Get the MCP tool resource.\n * @returns The MCP tool resource\n */\n private get _resource(): MCPToolResource {\n return {\n serverLabel: this._serverLabel,\n headers: this._headers,\n requireApproval: this._requireApproval,\n };\n }\n\n /**\n * Set the MCP tool definition.\n * @returns The MCP tool definition\n * */\n private get _definition(): MCPToolDefinition {\n return {\n type: \"mcp\",\n serverLabel: this._serverLabel,\n serverUrl: this._serverUrl,\n allowedTools: this._allowedTools.length > 0 ? this._allowedTools : undefined,\n };\n }\n\n /**\n * Get the MCP tool definition.\n * @returns A list containing the MCP tool definition\n */\n get definitions(): MCPToolDefinition[] {\n return [this._definition];\n }\n\n /**\n * Add a tool to the list of allowed tools.\n * @param toolName - The name of the tool to allow\n */\n allowTool(toolName: string): void {\n if (!this._allowedTools.includes(toolName)) {\n this._allowedTools.push(toolName);\n }\n }\n\n /**\n * Remove a tool from the list of allowed tools.\n * @param toolName - The name of the tool to remove from allowed tools\n * @throws Error if the tool is not in the allowed tools list\n */\n disallowTool(toolName: string): void {\n const index = this._allowedTools.indexOf(toolName);\n if (index > -1) {\n this._allowedTools.splice(index, 1);\n } else {\n throw new Error(`Tool '${toolName}' is not in the allowed tools list.`);\n }\n }\n\n /**\n * Update the approval mode for the MCP tool.\n * @param requireApproval - The require_approval setting to update\n */\n setApprovalMode(requireApproval?: \"always\" | \"never\"): void {\n this._requireApproval = requireApproval;\n }\n\n /**\n * Update the headers for the MCP tool.\n * @param key - The header key to update\n * @param value - The new value for the header key\n * @throws Error if the key is empty\n */\n updateHeaders(key: string, value: string): void {\n if (key) {\n this._headers[key] = value;\n } else {\n throw new Error(\"Header key cannot be empty.\");\n }\n }\n\n /**\n * Get the server label for the MCP tool.\n */\n get serverLabel(): string {\n return this._serverLabel;\n }\n\n /**\n * Get the server URL for the MCP tool.\n */\n get serverUrl(): string {\n return this._serverUrl;\n }\n\n /**\n * Get the list of allowed tools for the MCP server.\n */\n get allowedTools(): string[] {\n return [...this._allowedTools];\n }\n\n /**\n * Get the headers for the MCP tool.\n */\n get headers(): Record<string, string> {\n return { ...this._headers };\n }\n\n /**\n * Get the tool resources for the agent.\n */\n get resources(): ToolResources {\n return {\n mcp: [this._resource],\n };\n }\n}\n"]}
@@ -1,78 +0,0 @@
1
- import { MCPToolDefinition, ToolResources } from "../index.js";
2
- /**
3
- * A tool that connects to Model Context Protocol (MCP) servers.
4
- * Supports managing MCP server connections and allowed tools dynamically.
5
- */
6
- export declare class MCPTool {
7
- private _serverLabel;
8
- private _serverUrl;
9
- private _allowedTools;
10
- private _requireApproval?;
11
- private _headers;
12
- /**
13
- * Constructor initializes the tool with MCP server configuration.
14
- * @param serverLabel - The label for the MCP server
15
- * @param serverUrl - The endpoint for the MCP server
16
- * @param allowedTools - List of allowed tools for MCP server
17
- */
18
- constructor(serverLabel: string, serverUrl: string, allowedTools?: string[]);
19
- /**
20
- * Get the MCP tool resource.
21
- * @returns The MCP tool resource
22
- */
23
- private get _resource();
24
- /**
25
- * Set the MCP tool definition.
26
- * @returns The MCP tool definition
27
- * */
28
- private get _definition();
29
- /**
30
- * Get the MCP tool definition.
31
- * @returns A list containing the MCP tool definition
32
- */
33
- get definitions(): MCPToolDefinition[];
34
- /**
35
- * Add a tool to the list of allowed tools.
36
- * @param toolName - The name of the tool to allow
37
- */
38
- allowTool(toolName: string): void;
39
- /**
40
- * Remove a tool from the list of allowed tools.
41
- * @param toolName - The name of the tool to remove from allowed tools
42
- * @throws Error if the tool is not in the allowed tools list
43
- */
44
- disallowTool(toolName: string): void;
45
- /**
46
- * Update the approval mode for the MCP tool.
47
- * @param requireApproval - The require_approval setting to update
48
- */
49
- setApprovalMode(requireApproval?: "always" | "never"): void;
50
- /**
51
- * Update the headers for the MCP tool.
52
- * @param key - The header key to update
53
- * @param value - The new value for the header key
54
- * @throws Error if the key is empty
55
- */
56
- updateHeaders(key: string, value: string): void;
57
- /**
58
- * Get the server label for the MCP tool.
59
- */
60
- get serverLabel(): string;
61
- /**
62
- * Get the server URL for the MCP tool.
63
- */
64
- get serverUrl(): string;
65
- /**
66
- * Get the list of allowed tools for the MCP server.
67
- */
68
- get allowedTools(): string[];
69
- /**
70
- * Get the headers for the MCP tool.
71
- */
72
- get headers(): Record<string, string>;
73
- /**
74
- * Get the tool resources for the agent.
75
- */
76
- get resources(): ToolResources;
77
- }
78
- //# sourceMappingURL=MCPTool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MCPTool.d.ts","sourceRoot":"","sources":["../../../src/utils/MCPTool.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAChF;;;GAGG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,gBAAgB,CAAC,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAyB;IAEzC;;;;;OAKG;gBACS,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE;IAO3E;;;OAGG;IACH,OAAO,KAAK,SAAS,GAMpB;IAED;;;SAGK;IACL,OAAO,KAAK,WAAW,GAOtB;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,iBAAiB,EAAE,CAErC;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMjC;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IASpC;;;OAGG;IACH,eAAe,CAAC,eAAe,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI;IAI3D;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ/C;;OAEG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,EAAE,CAE3B;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEpC;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,aAAa,CAI7B;CACF"}
@@ -1,133 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- /**
4
- * A tool that connects to Model Context Protocol (MCP) servers.
5
- * Supports managing MCP server connections and allowed tools dynamically.
6
- */
7
- export class MCPTool {
8
- _serverLabel;
9
- _serverUrl;
10
- _allowedTools;
11
- _requireApproval;
12
- _headers;
13
- /**
14
- * Constructor initializes the tool with MCP server configuration.
15
- * @param serverLabel - The label for the MCP server
16
- * @param serverUrl - The endpoint for the MCP server
17
- * @param allowedTools - List of allowed tools for MCP server
18
- */
19
- constructor(serverLabel, serverUrl, allowedTools) {
20
- this._serverLabel = serverLabel;
21
- this._serverUrl = serverUrl;
22
- this._allowedTools = allowedTools || [];
23
- this._requireApproval = "always"; // Default to always require approval
24
- this._headers = {};
25
- }
26
- /**
27
- * Get the MCP tool resource.
28
- * @returns The MCP tool resource
29
- */
30
- get _resource() {
31
- return {
32
- serverLabel: this._serverLabel,
33
- headers: this._headers,
34
- requireApproval: this._requireApproval,
35
- };
36
- }
37
- /**
38
- * Set the MCP tool definition.
39
- * @returns The MCP tool definition
40
- * */
41
- get _definition() {
42
- return {
43
- type: "mcp",
44
- serverLabel: this._serverLabel,
45
- serverUrl: this._serverUrl,
46
- allowedTools: this._allowedTools.length > 0 ? this._allowedTools : undefined,
47
- };
48
- }
49
- /**
50
- * Get the MCP tool definition.
51
- * @returns A list containing the MCP tool definition
52
- */
53
- get definitions() {
54
- return [this._definition];
55
- }
56
- /**
57
- * Add a tool to the list of allowed tools.
58
- * @param toolName - The name of the tool to allow
59
- */
60
- allowTool(toolName) {
61
- if (!this._allowedTools.includes(toolName)) {
62
- this._allowedTools.push(toolName);
63
- }
64
- }
65
- /**
66
- * Remove a tool from the list of allowed tools.
67
- * @param toolName - The name of the tool to remove from allowed tools
68
- * @throws Error if the tool is not in the allowed tools list
69
- */
70
- disallowTool(toolName) {
71
- const index = this._allowedTools.indexOf(toolName);
72
- if (index > -1) {
73
- this._allowedTools.splice(index, 1);
74
- }
75
- else {
76
- throw new Error(`Tool '${toolName}' is not in the allowed tools list.`);
77
- }
78
- }
79
- /**
80
- * Update the approval mode for the MCP tool.
81
- * @param requireApproval - The require_approval setting to update
82
- */
83
- setApprovalMode(requireApproval) {
84
- this._requireApproval = requireApproval;
85
- }
86
- /**
87
- * Update the headers for the MCP tool.
88
- * @param key - The header key to update
89
- * @param value - The new value for the header key
90
- * @throws Error if the key is empty
91
- */
92
- updateHeaders(key, value) {
93
- if (key) {
94
- this._headers[key] = value;
95
- }
96
- else {
97
- throw new Error("Header key cannot be empty.");
98
- }
99
- }
100
- /**
101
- * Get the server label for the MCP tool.
102
- */
103
- get serverLabel() {
104
- return this._serverLabel;
105
- }
106
- /**
107
- * Get the server URL for the MCP tool.
108
- */
109
- get serverUrl() {
110
- return this._serverUrl;
111
- }
112
- /**
113
- * Get the list of allowed tools for the MCP server.
114
- */
115
- get allowedTools() {
116
- return [...this._allowedTools];
117
- }
118
- /**
119
- * Get the headers for the MCP tool.
120
- */
121
- get headers() {
122
- return { ...this._headers };
123
- }
124
- /**
125
- * Get the tool resources for the agent.
126
- */
127
- get resources() {
128
- return {
129
- mcp: [this._resource],
130
- };
131
- }
132
- }
133
- //# sourceMappingURL=MCPTool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MCPTool.js","sourceRoot":"","sources":["../../../src/utils/MCPTool.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { MCPToolDefinition, MCPToolResource, ToolResources } from \"../index.js\";\n/**\n * A tool that connects to Model Context Protocol (MCP) servers.\n * Supports managing MCP server connections and allowed tools dynamically.\n */\nexport class MCPTool {\n private _serverLabel: string;\n private _serverUrl: string;\n private _allowedTools: string[];\n private _requireApproval?: \"always\" | \"never\";\n private _headers: Record<string, string>;\n\n /**\n * Constructor initializes the tool with MCP server configuration.\n * @param serverLabel - The label for the MCP server\n * @param serverUrl - The endpoint for the MCP server\n * @param allowedTools - List of allowed tools for MCP server\n */\n constructor(serverLabel: string, serverUrl: string, allowedTools?: string[]) {\n this._serverLabel = serverLabel;\n this._serverUrl = serverUrl;\n this._allowedTools = allowedTools || [];\n this._requireApproval = \"always\"; // Default to always require approval\n this._headers = {};\n }\n /**\n * Get the MCP tool resource.\n * @returns The MCP tool resource\n */\n private get _resource(): MCPToolResource {\n return {\n serverLabel: this._serverLabel,\n headers: this._headers,\n requireApproval: this._requireApproval,\n };\n }\n\n /**\n * Set the MCP tool definition.\n * @returns The MCP tool definition\n * */\n private get _definition(): MCPToolDefinition {\n return {\n type: \"mcp\",\n serverLabel: this._serverLabel,\n serverUrl: this._serverUrl,\n allowedTools: this._allowedTools.length > 0 ? this._allowedTools : undefined,\n };\n }\n\n /**\n * Get the MCP tool definition.\n * @returns A list containing the MCP tool definition\n */\n get definitions(): MCPToolDefinition[] {\n return [this._definition];\n }\n\n /**\n * Add a tool to the list of allowed tools.\n * @param toolName - The name of the tool to allow\n */\n allowTool(toolName: string): void {\n if (!this._allowedTools.includes(toolName)) {\n this._allowedTools.push(toolName);\n }\n }\n\n /**\n * Remove a tool from the list of allowed tools.\n * @param toolName - The name of the tool to remove from allowed tools\n * @throws Error if the tool is not in the allowed tools list\n */\n disallowTool(toolName: string): void {\n const index = this._allowedTools.indexOf(toolName);\n if (index > -1) {\n this._allowedTools.splice(index, 1);\n } else {\n throw new Error(`Tool '${toolName}' is not in the allowed tools list.`);\n }\n }\n\n /**\n * Update the approval mode for the MCP tool.\n * @param requireApproval - The require_approval setting to update\n */\n setApprovalMode(requireApproval?: \"always\" | \"never\"): void {\n this._requireApproval = requireApproval;\n }\n\n /**\n * Update the headers for the MCP tool.\n * @param key - The header key to update\n * @param value - The new value for the header key\n * @throws Error if the key is empty\n */\n updateHeaders(key: string, value: string): void {\n if (key) {\n this._headers[key] = value;\n } else {\n throw new Error(\"Header key cannot be empty.\");\n }\n }\n\n /**\n * Get the server label for the MCP tool.\n */\n get serverLabel(): string {\n return this._serverLabel;\n }\n\n /**\n * Get the server URL for the MCP tool.\n */\n get serverUrl(): string {\n return this._serverUrl;\n }\n\n /**\n * Get the list of allowed tools for the MCP server.\n */\n get allowedTools(): string[] {\n return [...this._allowedTools];\n }\n\n /**\n * Get the headers for the MCP tool.\n */\n get headers(): Record<string, string> {\n return { ...this._headers };\n }\n\n /**\n * Get the tool resources for the agent.\n */\n get resources(): ToolResources {\n return {\n mcp: [this._resource],\n };\n }\n}\n"]}
@@ -1,78 +0,0 @@
1
- import { MCPToolDefinition, ToolResources } from "../index.js";
2
- /**
3
- * A tool that connects to Model Context Protocol (MCP) servers.
4
- * Supports managing MCP server connections and allowed tools dynamically.
5
- */
6
- export declare class MCPTool {
7
- private _serverLabel;
8
- private _serverUrl;
9
- private _allowedTools;
10
- private _requireApproval?;
11
- private _headers;
12
- /**
13
- * Constructor initializes the tool with MCP server configuration.
14
- * @param serverLabel - The label for the MCP server
15
- * @param serverUrl - The endpoint for the MCP server
16
- * @param allowedTools - List of allowed tools for MCP server
17
- */
18
- constructor(serverLabel: string, serverUrl: string, allowedTools?: string[]);
19
- /**
20
- * Get the MCP tool resource.
21
- * @returns The MCP tool resource
22
- */
23
- private get _resource();
24
- /**
25
- * Set the MCP tool definition.
26
- * @returns The MCP tool definition
27
- * */
28
- private get _definition();
29
- /**
30
- * Get the MCP tool definition.
31
- * @returns A list containing the MCP tool definition
32
- */
33
- get definitions(): MCPToolDefinition[];
34
- /**
35
- * Add a tool to the list of allowed tools.
36
- * @param toolName - The name of the tool to allow
37
- */
38
- allowTool(toolName: string): void;
39
- /**
40
- * Remove a tool from the list of allowed tools.
41
- * @param toolName - The name of the tool to remove from allowed tools
42
- * @throws Error if the tool is not in the allowed tools list
43
- */
44
- disallowTool(toolName: string): void;
45
- /**
46
- * Update the approval mode for the MCP tool.
47
- * @param requireApproval - The require_approval setting to update
48
- */
49
- setApprovalMode(requireApproval?: "always" | "never"): void;
50
- /**
51
- * Update the headers for the MCP tool.
52
- * @param key - The header key to update
53
- * @param value - The new value for the header key
54
- * @throws Error if the key is empty
55
- */
56
- updateHeaders(key: string, value: string): void;
57
- /**
58
- * Get the server label for the MCP tool.
59
- */
60
- get serverLabel(): string;
61
- /**
62
- * Get the server URL for the MCP tool.
63
- */
64
- get serverUrl(): string;
65
- /**
66
- * Get the list of allowed tools for the MCP server.
67
- */
68
- get allowedTools(): string[];
69
- /**
70
- * Get the headers for the MCP tool.
71
- */
72
- get headers(): Record<string, string>;
73
- /**
74
- * Get the tool resources for the agent.
75
- */
76
- get resources(): ToolResources;
77
- }
78
- //# sourceMappingURL=MCPTool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MCPTool.d.ts","sourceRoot":"","sources":["../../../src/utils/MCPTool.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAChF;;;GAGG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,gBAAgB,CAAC,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAyB;IAEzC;;;;;OAKG;gBACS,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE;IAO3E;;;OAGG;IACH,OAAO,KAAK,SAAS,GAMpB;IAED;;;SAGK;IACL,OAAO,KAAK,WAAW,GAOtB;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,iBAAiB,EAAE,CAErC;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMjC;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IASpC;;;OAGG;IACH,eAAe,CAAC,eAAe,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI;IAI3D;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ/C;;OAEG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,EAAE,CAE3B;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEpC;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,aAAa,CAI7B;CACF"}
@@ -1,133 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- /**
4
- * A tool that connects to Model Context Protocol (MCP) servers.
5
- * Supports managing MCP server connections and allowed tools dynamically.
6
- */
7
- export class MCPTool {
8
- _serverLabel;
9
- _serverUrl;
10
- _allowedTools;
11
- _requireApproval;
12
- _headers;
13
- /**
14
- * Constructor initializes the tool with MCP server configuration.
15
- * @param serverLabel - The label for the MCP server
16
- * @param serverUrl - The endpoint for the MCP server
17
- * @param allowedTools - List of allowed tools for MCP server
18
- */
19
- constructor(serverLabel, serverUrl, allowedTools) {
20
- this._serverLabel = serverLabel;
21
- this._serverUrl = serverUrl;
22
- this._allowedTools = allowedTools || [];
23
- this._requireApproval = "always"; // Default to always require approval
24
- this._headers = {};
25
- }
26
- /**
27
- * Get the MCP tool resource.
28
- * @returns The MCP tool resource
29
- */
30
- get _resource() {
31
- return {
32
- serverLabel: this._serverLabel,
33
- headers: this._headers,
34
- requireApproval: this._requireApproval,
35
- };
36
- }
37
- /**
38
- * Set the MCP tool definition.
39
- * @returns The MCP tool definition
40
- * */
41
- get _definition() {
42
- return {
43
- type: "mcp",
44
- serverLabel: this._serverLabel,
45
- serverUrl: this._serverUrl,
46
- allowedTools: this._allowedTools.length > 0 ? this._allowedTools : undefined,
47
- };
48
- }
49
- /**
50
- * Get the MCP tool definition.
51
- * @returns A list containing the MCP tool definition
52
- */
53
- get definitions() {
54
- return [this._definition];
55
- }
56
- /**
57
- * Add a tool to the list of allowed tools.
58
- * @param toolName - The name of the tool to allow
59
- */
60
- allowTool(toolName) {
61
- if (!this._allowedTools.includes(toolName)) {
62
- this._allowedTools.push(toolName);
63
- }
64
- }
65
- /**
66
- * Remove a tool from the list of allowed tools.
67
- * @param toolName - The name of the tool to remove from allowed tools
68
- * @throws Error if the tool is not in the allowed tools list
69
- */
70
- disallowTool(toolName) {
71
- const index = this._allowedTools.indexOf(toolName);
72
- if (index > -1) {
73
- this._allowedTools.splice(index, 1);
74
- }
75
- else {
76
- throw new Error(`Tool '${toolName}' is not in the allowed tools list.`);
77
- }
78
- }
79
- /**
80
- * Update the approval mode for the MCP tool.
81
- * @param requireApproval - The require_approval setting to update
82
- */
83
- setApprovalMode(requireApproval) {
84
- this._requireApproval = requireApproval;
85
- }
86
- /**
87
- * Update the headers for the MCP tool.
88
- * @param key - The header key to update
89
- * @param value - The new value for the header key
90
- * @throws Error if the key is empty
91
- */
92
- updateHeaders(key, value) {
93
- if (key) {
94
- this._headers[key] = value;
95
- }
96
- else {
97
- throw new Error("Header key cannot be empty.");
98
- }
99
- }
100
- /**
101
- * Get the server label for the MCP tool.
102
- */
103
- get serverLabel() {
104
- return this._serverLabel;
105
- }
106
- /**
107
- * Get the server URL for the MCP tool.
108
- */
109
- get serverUrl() {
110
- return this._serverUrl;
111
- }
112
- /**
113
- * Get the list of allowed tools for the MCP server.
114
- */
115
- get allowedTools() {
116
- return [...this._allowedTools];
117
- }
118
- /**
119
- * Get the headers for the MCP tool.
120
- */
121
- get headers() {
122
- return { ...this._headers };
123
- }
124
- /**
125
- * Get the tool resources for the agent.
126
- */
127
- get resources() {
128
- return {
129
- mcp: [this._resource],
130
- };
131
- }
132
- }
133
- //# sourceMappingURL=MCPTool.js.map