@microsoft/agents-a365-tooling-extensions-openai 0.1.0-preview.30

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/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @microsoft/agents-a365-tooling-extensions-openai
2
+
3
+ [![npm](https://img.shields.io/npm/v/@microsoft/agents-a365-tooling-extensions-openai?label=npm&logo=npm)](https://www.npmjs.com/package/@microsoft/agents-a365-tooling-extensions-openai)
4
+ [![npm Downloads](https://img.shields.io/npm/dm/@microsoft/agents-a365-tooling-extensions-openai?label=Downloads&logo=npm)](https://www.npmjs.com/package/@microsoft/agents-a365-tooling-extensions-openai)
5
+
6
+ OpenAI Agents SDK integration for the Microsoft Agent 365 Tooling SDK. This package enables seamless integration of MCP (Model Context Protocol) tool servers with OpenAI Agents, providing automatic tool discovery and registration.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @microsoft/agents-a365-tooling-extensions-openai
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ For detailed usage examples and implementation guidance, see the [Microsoft Agent 365 Tooling Documentation](https://learn.microsoft.com/microsoft-agent-365/developer/tooling?tabs=nodejs).
17
+
18
+ ## Support
19
+
20
+ For issues, questions, or feedback:
21
+
22
+ - File issues in the [GitHub Issues](https://github.com/microsoft/Agent365-nodejs/issues) section
23
+ - See the [main documentation](../../README.md) for more information
24
+
25
+ ## Trademarks
26
+
27
+ *Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653.*
28
+
29
+ ## License
30
+
31
+ Copyright (c) Microsoft Corporation. All rights reserved.
32
+
33
+ Licensed under the MIT License - see the [LICENSE](../../LICENSE.md) file for details
@@ -0,0 +1,21 @@
1
+ import { TurnContext, Authorization } from '@microsoft/agents-hosting';
2
+ import { Agent } from '@openai/agents';
3
+ /**
4
+ * Discover MCP servers and list tools formatted for the OpenAI Agents SDK.
5
+ * Uses listToolServers to fetch server configs.
6
+ */
7
+ export declare class McpToolRegistrationService {
8
+ private configService;
9
+ /**
10
+ * Registers MCP tool servers and updates agent options with discovered tools and server configs.
11
+ * Call this to enable dynamic OpenAI tool access based on the current MCP environment.
12
+ * @param agent The OpenAI Agent instance to which MCP servers will be added.
13
+ * @param authorization Authorization object for token exchange.
14
+ * @param authHandlerName The name of the auth handler to use for token exchange.
15
+ * @param turnContext The TurnContext of the current request.
16
+ * @param authToken Optional bearer token for MCP server access.
17
+ * @returns The updated Agent instance with registered MCP servers.
18
+ */
19
+ addToolServersToAgent(agent: Agent, authorization: Authorization, authHandlerName: string, turnContext: TurnContext, authToken: string): Promise<Agent>;
20
+ }
21
+ //# sourceMappingURL=McpToolRegistrationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpToolRegistrationService.d.ts","sourceRoot":"","sources":["../../src/McpToolRegistrationService.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAGvE,OAAO,EAAE,KAAK,EAA2B,MAAM,gBAAgB,CAAC;AAEhE;;;GAGG;AACH,qBAAa,0BAA0B;IACrC,OAAO,CAAC,aAAa,CAA+E;IAGpG;;;;;;;;;OASG;IACG,qBAAqB,CACzB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,KAAK,CAAC;CAyClB"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.McpToolRegistrationService = void 0;
6
+ const agents_a365_tooling_1 = require("@microsoft/agents-a365-tooling");
7
+ const agents_a365_runtime_1 = require("@microsoft/agents-a365-runtime");
8
+ // OpenAI Agents SDK
9
+ const agents_1 = require("@openai/agents");
10
+ /**
11
+ * Discover MCP servers and list tools formatted for the OpenAI Agents SDK.
12
+ * Uses listToolServers to fetch server configs.
13
+ */
14
+ class McpToolRegistrationService {
15
+ constructor() {
16
+ this.configService = new agents_a365_tooling_1.McpToolServerConfigurationService();
17
+ }
18
+ /**
19
+ * Registers MCP tool servers and updates agent options with discovered tools and server configs.
20
+ * Call this to enable dynamic OpenAI tool access based on the current MCP environment.
21
+ * @param agent The OpenAI Agent instance to which MCP servers will be added.
22
+ * @param authorization Authorization object for token exchange.
23
+ * @param authHandlerName The name of the auth handler to use for token exchange.
24
+ * @param turnContext The TurnContext of the current request.
25
+ * @param authToken Optional bearer token for MCP server access.
26
+ * @returns The updated Agent instance with registered MCP servers.
27
+ */
28
+ async addToolServersToAgent(agent, authorization, authHandlerName, turnContext, authToken) {
29
+ if (!agent) {
30
+ throw new Error('Agent is Required');
31
+ }
32
+ if (!authToken) {
33
+ authToken = await agents_a365_runtime_1.AgenticAuthenticationService.GetAgenticUserToken(authorization, authHandlerName, turnContext);
34
+ }
35
+ // Validate the authentication token
36
+ agents_a365_tooling_1.Utility.ValidateAuthToken(authToken);
37
+ const agenticAppId = agents_a365_runtime_1.Utility.ResolveAgentIdentity(turnContext, authToken);
38
+ const servers = await this.configService.listToolServers(agenticAppId, authToken);
39
+ const mcpServers = [];
40
+ for (const server of servers) {
41
+ // Compose headers if values are available
42
+ const headers = {};
43
+ if (authToken) {
44
+ headers['Authorization'] = `Bearer ${authToken}`;
45
+ }
46
+ // Create MCPServerStreamableHttp instance for OpenAI agents
47
+ const mcpServer = new agents_1.MCPServerStreamableHttp({
48
+ url: server.url,
49
+ name: server.mcpServerName,
50
+ requestInit: {
51
+ headers: headers,
52
+ }
53
+ });
54
+ mcpServers.push(mcpServer);
55
+ }
56
+ agent.mcpServers = agent.mcpServers ?? [];
57
+ agent.mcpServers.push(...mcpServers);
58
+ return agent;
59
+ }
60
+ }
61
+ exports.McpToolRegistrationService = McpToolRegistrationService;
62
+ //# sourceMappingURL=McpToolRegistrationService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpToolRegistrationService.js","sourceRoot":"","sources":["../../src/McpToolRegistrationService.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,wEAA4F;AAC5F,wEAAyG;AAKzG,oBAAoB;AACpB,2CAAgE;AAEhE;;;GAGG;AACH,MAAa,0BAA0B;IAAvC;QACU,kBAAa,GAAuC,IAAI,uDAAiC,EAAE,CAAC;IA4DtG,CAAC;IAzDC;;;;;;;;;OASG;IACH,KAAK,CAAC,qBAAqB,CACzB,KAAY,EACZ,aAA4B,EAC5B,eAAuB,EACvB,WAAwB,EACxB,SAAiB;QAGjB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS,GAAG,MAAM,kDAA4B,CAAC,mBAAmB,CAAC,aAAa,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;QAClH,CAAC;QAED,oCAAoC;QACpC,6BAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAErC,MAAM,YAAY,GAAG,6BAAc,CAAC,oBAAoB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACjF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QAClF,MAAM,UAAU,GAA8B,EAAE,CAAC;QAEjD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,0CAA0C;YAC1C,MAAM,OAAO,GAA2B,EAAE,CAAC;YAC3C,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,SAAS,EAAE,CAAC;YACnD,CAAC;YAED,4DAA4D;YAC5D,MAAM,SAAS,GAAG,IAAI,gCAAuB,CAAC;gBAC5C,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,IAAI,EAAE,MAAM,CAAC,aAAa;gBAC1B,WAAW,EAAE;oBACX,OAAO,EAAE,OAAO;iBACjB;aACF,CAAC,CAAC;YAEH,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7B,CAAC;QAED,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;QAC1C,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;QAErC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA7DD,gEA6DC"}
@@ -0,0 +1,2 @@
1
+ export * from './McpToolRegistrationService';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./McpToolRegistrationService"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C"}
@@ -0,0 +1,21 @@
1
+ import { TurnContext, Authorization } from '@microsoft/agents-hosting';
2
+ import { Agent } from '@openai/agents';
3
+ /**
4
+ * Discover MCP servers and list tools formatted for the OpenAI Agents SDK.
5
+ * Uses listToolServers to fetch server configs.
6
+ */
7
+ export declare class McpToolRegistrationService {
8
+ private configService;
9
+ /**
10
+ * Registers MCP tool servers and updates agent options with discovered tools and server configs.
11
+ * Call this to enable dynamic OpenAI tool access based on the current MCP environment.
12
+ * @param agent The OpenAI Agent instance to which MCP servers will be added.
13
+ * @param authorization Authorization object for token exchange.
14
+ * @param authHandlerName The name of the auth handler to use for token exchange.
15
+ * @param turnContext The TurnContext of the current request.
16
+ * @param authToken Optional bearer token for MCP server access.
17
+ * @returns The updated Agent instance with registered MCP servers.
18
+ */
19
+ addToolServersToAgent(agent: Agent, authorization: Authorization, authHandlerName: string, turnContext: TurnContext, authToken: string): Promise<Agent>;
20
+ }
21
+ //# sourceMappingURL=McpToolRegistrationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpToolRegistrationService.d.ts","sourceRoot":"","sources":["../../src/McpToolRegistrationService.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAGvE,OAAO,EAAE,KAAK,EAA2B,MAAM,gBAAgB,CAAC;AAEhE;;;GAGG;AACH,qBAAa,0BAA0B;IACrC,OAAO,CAAC,aAAa,CAA+E;IAGpG;;;;;;;;;OASG;IACG,qBAAqB,CACzB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,KAAK,CAAC;CAyClB"}
@@ -0,0 +1,58 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { McpToolServerConfigurationService, Utility } from '@microsoft/agents-a365-tooling';
4
+ import { AgenticAuthenticationService, Utility as RuntimeUtility } from '@microsoft/agents-a365-runtime';
5
+ // OpenAI Agents SDK
6
+ import { MCPServerStreamableHttp } from '@openai/agents';
7
+ /**
8
+ * Discover MCP servers and list tools formatted for the OpenAI Agents SDK.
9
+ * Uses listToolServers to fetch server configs.
10
+ */
11
+ export class McpToolRegistrationService {
12
+ constructor() {
13
+ this.configService = new McpToolServerConfigurationService();
14
+ }
15
+ /**
16
+ * Registers MCP tool servers and updates agent options with discovered tools and server configs.
17
+ * Call this to enable dynamic OpenAI tool access based on the current MCP environment.
18
+ * @param agent The OpenAI Agent instance to which MCP servers will be added.
19
+ * @param authorization Authorization object for token exchange.
20
+ * @param authHandlerName The name of the auth handler to use for token exchange.
21
+ * @param turnContext The TurnContext of the current request.
22
+ * @param authToken Optional bearer token for MCP server access.
23
+ * @returns The updated Agent instance with registered MCP servers.
24
+ */
25
+ async addToolServersToAgent(agent, authorization, authHandlerName, turnContext, authToken) {
26
+ if (!agent) {
27
+ throw new Error('Agent is Required');
28
+ }
29
+ if (!authToken) {
30
+ authToken = await AgenticAuthenticationService.GetAgenticUserToken(authorization, authHandlerName, turnContext);
31
+ }
32
+ // Validate the authentication token
33
+ Utility.ValidateAuthToken(authToken);
34
+ const agenticAppId = RuntimeUtility.ResolveAgentIdentity(turnContext, authToken);
35
+ const servers = await this.configService.listToolServers(agenticAppId, authToken);
36
+ const mcpServers = [];
37
+ for (const server of servers) {
38
+ // Compose headers if values are available
39
+ const headers = {};
40
+ if (authToken) {
41
+ headers['Authorization'] = `Bearer ${authToken}`;
42
+ }
43
+ // Create MCPServerStreamableHttp instance for OpenAI agents
44
+ const mcpServer = new MCPServerStreamableHttp({
45
+ url: server.url,
46
+ name: server.mcpServerName,
47
+ requestInit: {
48
+ headers: headers,
49
+ }
50
+ });
51
+ mcpServers.push(mcpServer);
52
+ }
53
+ agent.mcpServers = agent.mcpServers ?? [];
54
+ agent.mcpServers.push(...mcpServers);
55
+ return agent;
56
+ }
57
+ }
58
+ //# sourceMappingURL=McpToolRegistrationService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpToolRegistrationService.js","sourceRoot":"","sources":["../../src/McpToolRegistrationService.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,iCAAiC,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAKzG,oBAAoB;AACpB,OAAO,EAAS,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,0BAA0B;IAAvC;QACU,kBAAa,GAAuC,IAAI,iCAAiC,EAAE,CAAC;IA4DtG,CAAC;IAzDC;;;;;;;;;OASG;IACH,KAAK,CAAC,qBAAqB,CACzB,KAAY,EACZ,aAA4B,EAC5B,eAAuB,EACvB,WAAwB,EACxB,SAAiB;QAGjB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,SAAS,GAAG,MAAM,4BAA4B,CAAC,mBAAmB,CAAC,aAAa,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;QAClH,CAAC;QAED,oCAAoC;QACpC,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAErC,MAAM,YAAY,GAAG,cAAc,CAAC,oBAAoB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACjF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QAClF,MAAM,UAAU,GAA8B,EAAE,CAAC;QAEjD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,0CAA0C;YAC1C,MAAM,OAAO,GAA2B,EAAE,CAAC;YAC3C,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,SAAS,EAAE,CAAC;YACnD,CAAC;YAED,4DAA4D;YAC5D,MAAM,SAAS,GAAG,IAAI,uBAAuB,CAAC;gBAC5C,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,IAAI,EAAE,MAAM,CAAC,aAAa;gBAC1B,WAAW,EAAE;oBACX,OAAO,EAAE,OAAO;iBACjB;aACF,CAAC,CAAC;YAEH,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7B,CAAC;QAED,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;QAC1C,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;QAErC,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export * from './McpToolRegistrationService';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './McpToolRegistrationService';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@microsoft/agents-a365-tooling-extensions-openai",
3
+ "version": "0.1.0-preview.30",
4
+ "description": "Agent 365 Tooling SDK for OpenAI for AI agents built with TypeScript/Node.js",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "scripts": {
9
+ "build:cjs": "npx tsc --project tsconfig.cjs.json",
10
+ "build:esm": "npx tsc --project tsconfig.esm.json",
11
+ "build": "npm run build:cjs && npm run build:esm",
12
+ "build:watch": "npx tsc --watch",
13
+ "clean": "npx rimraf dist",
14
+ "test": "jest --passWithNoTests",
15
+ "test:watch": "jest --watch",
16
+ "lint": "eslint src/**/*.ts",
17
+ "lint:fix": "eslint src/**/*.ts --fix",
18
+ "prepublishOnly": "npm run clean && npm run build",
19
+ "ci": "npm ci",
20
+ "pack": "npm pack --pack-destination=../"
21
+ },
22
+ "keywords": [
23
+ "ai",
24
+ "agents",
25
+ "azure",
26
+ "typescript",
27
+ "openai"
28
+ ],
29
+ "author": "Microsoft Corporation",
30
+ "license": "See license file",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/microsoft/Agent365-nodejs.git",
34
+ "directory": "packages/agents-a365-tooling-extensions-openai"
35
+ },
36
+ "dependencies": {
37
+ "@microsoft/agents-a365-tooling": "0.1.0-preview.30",
38
+ "@microsoft/agents-a365-runtime": "0.1.0-preview.30",
39
+ "@openai/agents": "*",
40
+ "@microsoft/agents-hosting": "*"
41
+ },
42
+ "devDependencies": {
43
+ "@types/jest": "^29.5.14",
44
+ "@types/node": "^20.0.0",
45
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
46
+ "@typescript-eslint/parser": "^6.0.0",
47
+ "eslint": "^8.0.0",
48
+ "jest": "^29.0.0",
49
+ "rimraf": "^5.0.0",
50
+ "ts-jest": "^29.0.0",
51
+ "typescript": "^5.0.0"
52
+ },
53
+ "engines": {
54
+ "node": ">=18.0.0"
55
+ },
56
+ "files": [
57
+ "dist/**/*",
58
+ "README.md",
59
+ "CHANGELOG.md"
60
+ ]
61
+ }