microsoft-agents-a365-tooling-extensions-agentframework 0.2.1.dev4__py3-none-any.whl → 0.2.1.dev7__py3-none-any.whl
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.
- microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py +24 -3
- {microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev4.dist-info → microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev7.dist-info}/METADATA +3 -2
- {microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev4.dist-info → microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev7.dist-info}/RECORD +5 -5
- {microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev4.dist-info → microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev7.dist-info}/WHEEL +0 -0
- {microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev4.dist-info → microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev7.dist-info}/top_level.txt +0 -0
microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py
CHANGED
|
@@ -9,6 +9,7 @@ from typing import Any, List, Optional, Sequence, Union
|
|
|
9
9
|
from agent_framework import ChatAgent, ChatMessage, ChatMessageStoreProtocol, MCPStreamableHTTPTool
|
|
10
10
|
from agent_framework.azure import AzureOpenAIChatClient
|
|
11
11
|
from agent_framework.openai import OpenAIChatClient
|
|
12
|
+
import httpx
|
|
12
13
|
|
|
13
14
|
from microsoft_agents.hosting.core import Authorization, TurnContext
|
|
14
15
|
|
|
@@ -24,6 +25,10 @@ from microsoft_agents_a365.tooling.utils.utility import (
|
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
|
|
28
|
+
# Default timeout for MCP server HTTP requests (in seconds)
|
|
29
|
+
MCP_HTTP_CLIENT_TIMEOUT_SECONDS = 90.0
|
|
30
|
+
|
|
31
|
+
|
|
27
32
|
class McpToolRegistrationService:
|
|
28
33
|
"""
|
|
29
34
|
Provides MCP tool registration services for Agent Framework agents.
|
|
@@ -46,6 +51,7 @@ class McpToolRegistrationService:
|
|
|
46
51
|
logger=self._logger
|
|
47
52
|
)
|
|
48
53
|
self._connected_servers = []
|
|
54
|
+
self._http_clients: List[httpx.AsyncClient] = []
|
|
49
55
|
|
|
50
56
|
async def add_tool_servers_to_agent(
|
|
51
57
|
self,
|
|
@@ -114,11 +120,17 @@ class McpToolRegistrationService:
|
|
|
114
120
|
self._orchestrator_name
|
|
115
121
|
)
|
|
116
122
|
|
|
117
|
-
# Create
|
|
123
|
+
# Create httpx client with auth headers configured
|
|
124
|
+
http_client = httpx.AsyncClient(
|
|
125
|
+
headers=headers, timeout=MCP_HTTP_CLIENT_TIMEOUT_SECONDS
|
|
126
|
+
)
|
|
127
|
+
self._http_clients.append(http_client)
|
|
128
|
+
|
|
129
|
+
# Create and configure MCPStreamableHTTPTool with http_client
|
|
118
130
|
mcp_tools = MCPStreamableHTTPTool(
|
|
119
131
|
name=server_name,
|
|
120
132
|
url=config.url,
|
|
121
|
-
|
|
133
|
+
http_client=http_client,
|
|
122
134
|
description=f"MCP tools from {server_name}",
|
|
123
135
|
)
|
|
124
136
|
|
|
@@ -339,12 +351,21 @@ class McpToolRegistrationService:
|
|
|
339
351
|
async def cleanup(self):
|
|
340
352
|
"""Clean up any resources used by the service."""
|
|
341
353
|
try:
|
|
354
|
+
# Close MCP server connections
|
|
342
355
|
for plugin in self._connected_servers:
|
|
343
356
|
try:
|
|
344
357
|
if hasattr(plugin, "close"):
|
|
345
358
|
await plugin.close()
|
|
346
359
|
except Exception as cleanup_ex:
|
|
347
|
-
self._logger.debug(f"Error during cleanup: {cleanup_ex}")
|
|
360
|
+
self._logger.debug(f"Error during plugin cleanup: {cleanup_ex}")
|
|
348
361
|
self._connected_servers.clear()
|
|
362
|
+
|
|
363
|
+
# Close httpx clients to prevent connection/file descriptor leaks
|
|
364
|
+
for http_client in self._http_clients:
|
|
365
|
+
try:
|
|
366
|
+
await http_client.aclose()
|
|
367
|
+
except Exception as client_ex:
|
|
368
|
+
self._logger.debug(f"Error closing http client: {client_ex}")
|
|
369
|
+
self._http_clients.clear()
|
|
349
370
|
except Exception as ex:
|
|
350
371
|
self._logger.debug(f"Error during service cleanup: {ex}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: microsoft-agents-a365-tooling-extensions-agentframework
|
|
3
|
-
Version: 0.2.1.
|
|
3
|
+
Version: 0.2.1.dev7
|
|
4
4
|
Summary: Agent Framework integration tools for Agent 365 AI agent tooling
|
|
5
5
|
Author-email: Microsoft <support@microsoft.com>
|
|
6
6
|
License: MIT
|
|
@@ -19,10 +19,11 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
19
19
|
Requires-Python: >=3.11
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
Requires-Dist: microsoft-agents-a365-tooling>=0.0.0
|
|
22
|
-
Requires-Dist: microsoft-agents-hosting-core
|
|
22
|
+
Requires-Dist: microsoft-agents-hosting-core>=0.4.0
|
|
23
23
|
Requires-Dist: agent-framework-azure-ai>=1.0.0b251114
|
|
24
24
|
Requires-Dist: azure-identity>=1.12.0
|
|
25
25
|
Requires-Dist: typing-extensions>=4.0.0
|
|
26
|
+
Requires-Dist: httpx>=0.27.0
|
|
26
27
|
Provides-Extra: dev
|
|
27
28
|
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
28
29
|
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
microsoft_agents_a365/tooling/extensions/agentframework/__init__.py,sha256=f_v_Uqi-rG_ramG91wrw-u8hzANbn5qS2wbp62S_bNw,905
|
|
2
2
|
microsoft_agents_a365/tooling/extensions/agentframework/services/__init__.py,sha256=Xw_MZvaAiiPCFnTTU59FnG6AS6FxVj5qN2vxazB1I50,363
|
|
3
|
-
microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py,sha256=
|
|
4
|
-
microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.
|
|
5
|
-
microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.
|
|
6
|
-
microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.
|
|
7
|
-
microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.
|
|
3
|
+
microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py,sha256=9DZiJL_EpVWRojaZlboerl-q5AJl1B17wP_mP7zETpw,14952
|
|
4
|
+
microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev7.dist-info/METADATA,sha256=-oLgM2USbJHfs82ALLcQ6wUE1P-5aut1aMgJtg139Tc,3514
|
|
5
|
+
microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
6
|
+
microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev7.dist-info/top_level.txt,sha256=G3c2_4sy5_EM_BWO67SbK2tKj4G8XFn-QXRbh8g9Lgk,22
|
|
7
|
+
microsoft_agents_a365_tooling_extensions_agentframework-0.2.1.dev7.dist-info/RECORD,,
|
|
File without changes
|