aixtools 0.2.20__py3-none-any.whl → 0.2.22__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.
Potentially problematic release.
This version of aixtools might be problematic. Click here for more details.
- aixtools/_version.py +2 -2
- aixtools/a2a/google_sdk/pydantic_ai_adapter/agent_executor.py +5 -4
- aixtools/a2a/google_sdk/utils.py +12 -0
- aixtools/mcp/client.py +11 -4
- aixtools/utils/config.py +2 -0
- {aixtools-0.2.20.dist-info → aixtools-0.2.22.dist-info}/METADATA +1 -1
- {aixtools-0.2.20.dist-info → aixtools-0.2.22.dist-info}/RECORD +10 -10
- {aixtools-0.2.20.dist-info → aixtools-0.2.22.dist-info}/WHEEL +0 -0
- {aixtools-0.2.20.dist-info → aixtools-0.2.22.dist-info}/entry_points.txt +0 -0
- {aixtools-0.2.20.dist-info → aixtools-0.2.22.dist-info}/top_level.txt +0 -0
aixtools/_version.py
CHANGED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.2.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 2,
|
|
31
|
+
__version__ = version = '0.2.22'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 2, 22)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -20,7 +20,7 @@ from pydantic_ai import Agent, BinaryContent
|
|
|
20
20
|
|
|
21
21
|
from aixtools.a2a.google_sdk.pydantic_ai_adapter.storage import InMemoryHistoryStorage
|
|
22
22
|
from aixtools.a2a.google_sdk.remote_agent_connection import is_in_terminal_state
|
|
23
|
-
from aixtools.a2a.google_sdk.utils import get_session_id_tuple
|
|
23
|
+
from aixtools.a2a.google_sdk.utils import get_auth_token, get_session_id_tuple
|
|
24
24
|
from aixtools.agents import get_agent
|
|
25
25
|
from aixtools.agents.prompt import build_user_input
|
|
26
26
|
from aixtools.context import SessionIdTuple
|
|
@@ -100,7 +100,8 @@ class PydanticAgentExecutor(AgentExecutor):
|
|
|
100
100
|
event_queue (EventQueue): The event queue to enqueue events.
|
|
101
101
|
"""
|
|
102
102
|
session_tuple = get_session_id_tuple(context)
|
|
103
|
-
|
|
103
|
+
auth_token = get_auth_token(context)
|
|
104
|
+
agent = self._build_agent(session_tuple, auth_token)
|
|
104
105
|
if context.message is None:
|
|
105
106
|
raise ValueError("No message provided")
|
|
106
107
|
|
|
@@ -258,9 +259,9 @@ class PydanticAgentExecutor(AgentExecutor):
|
|
|
258
259
|
)
|
|
259
260
|
)
|
|
260
261
|
|
|
261
|
-
def _build_agent(self, session_tuple: SessionIdTuple) -> Agent:
|
|
262
|
+
def _build_agent(self, session_tuple: SessionIdTuple, auth_token: str | None) -> Agent:
|
|
262
263
|
params = self._agent_parameters
|
|
263
|
-
mcp_servers = get_configured_mcp_servers(session_tuple, params.mcp_servers)
|
|
264
|
+
mcp_servers = get_configured_mcp_servers(session_tuple, params.mcp_servers, auth_token=auth_token)
|
|
264
265
|
return get_agent(
|
|
265
266
|
system_prompt=params.system_prompt,
|
|
266
267
|
toolsets=mcp_servers,
|
aixtools/a2a/google_sdk/utils.py
CHANGED
|
@@ -96,3 +96,15 @@ def get_session_id_tuple(context: RequestContext) -> SessionIdTuple:
|
|
|
96
96
|
"""Get the user_id, session_id tuple from the request context."""
|
|
97
97
|
headers = context.call_context.state.get("headers", {})
|
|
98
98
|
return headers.get("user-id", DEFAULT_USER_ID), headers.get("session-id", DEFAULT_SESSION_ID)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def get_auth_token(context: RequestContext) -> str | None:
|
|
102
|
+
"""Get the Authorization bearer token from the request context."""
|
|
103
|
+
headers = context.call_context.state.get("headers", {})
|
|
104
|
+
auth_header = headers.get("Authorization") or headers.get("authorization")
|
|
105
|
+
auth_token = None
|
|
106
|
+
if auth_header and auth_header.lower().startswith("bearer "):
|
|
107
|
+
auth_token = auth_header.split(" ", 1)[1].strip()
|
|
108
|
+
else:
|
|
109
|
+
logger.warning("Cannot find bearer token in Authorization header: %s", auth_header)
|
|
110
|
+
return auth_token
|
aixtools/mcp/client.py
CHANGED
|
@@ -23,6 +23,7 @@ from pydantic_ai.toolsets.abstract import ToolsetTool
|
|
|
23
23
|
from aixtools.context import SessionIdTuple
|
|
24
24
|
from aixtools.logging.logging_config import get_logger
|
|
25
25
|
from aixtools.server.utils import create_session_headers
|
|
26
|
+
from aixtools.utils.config import MCP_TOOLS_MAX_RETRIES
|
|
26
27
|
|
|
27
28
|
MCP_TOOL_CACHE_TTL = 300 # 5 minutes
|
|
28
29
|
DEFAULT_MCP_CONNECTION_TIMEOUT = 30
|
|
@@ -31,7 +32,6 @@ CACHE_KEY = "TOOL_LIST"
|
|
|
31
32
|
|
|
32
33
|
logger = get_logger(__name__)
|
|
33
34
|
|
|
34
|
-
|
|
35
35
|
# Default log_handler for MCP clients
|
|
36
36
|
LOGGING_LEVEL_MAP = logging.getLevelNamesMapping()
|
|
37
37
|
|
|
@@ -87,6 +87,7 @@ def get_mcp_servers(
|
|
|
87
87
|
mcp_configs: list[MCPConfig],
|
|
88
88
|
session_id_tuple: SessionIdTuple,
|
|
89
89
|
auth_token: str = None,
|
|
90
|
+
max_retries: int = MCP_TOOLS_MAX_RETRIES,
|
|
90
91
|
*,
|
|
91
92
|
timeout: float = DEFAULT_MCP_CONNECTION_TIMEOUT,
|
|
92
93
|
):
|
|
@@ -115,7 +116,7 @@ def get_mcp_servers(
|
|
|
115
116
|
servers = []
|
|
116
117
|
for config in mcp_configs:
|
|
117
118
|
server = CachedMCPServerStreamableHTTP(
|
|
118
|
-
url=config.url, headers=headers, timeout=timeout, read_timeout=config.read_timeout
|
|
119
|
+
url=config.url, headers=headers, timeout=timeout, read_timeout=config.read_timeout, max_retries=max_retries
|
|
119
120
|
)
|
|
120
121
|
logger.info("Using MCP server at %s", config.url)
|
|
121
122
|
servers.append(server)
|
|
@@ -123,10 +124,16 @@ def get_mcp_servers(
|
|
|
123
124
|
|
|
124
125
|
|
|
125
126
|
def get_configured_mcp_servers(
|
|
126
|
-
session_id_tuple: SessionIdTuple,
|
|
127
|
+
session_id_tuple: SessionIdTuple,
|
|
128
|
+
mcp_urls: list[str],
|
|
129
|
+
*,
|
|
130
|
+
timeout: int = DEFAULT_MCP_CONNECTION_TIMEOUT,
|
|
131
|
+
auth_token: str | None = None,
|
|
127
132
|
):
|
|
128
133
|
"""Create MCP server instances from a list of URLs."""
|
|
129
|
-
return get_mcp_servers(
|
|
134
|
+
return get_mcp_servers(
|
|
135
|
+
[MCPConfig(url=url) for url in mcp_urls], session_id_tuple, timeout=timeout, auth_token=auth_token
|
|
136
|
+
)
|
|
130
137
|
|
|
131
138
|
|
|
132
139
|
class CachedMCPServerStreamableHTTP(MCPServerStreamableHTTP):
|
aixtools/utils/config.py
CHANGED
|
@@ -144,3 +144,5 @@ SKIP_MCP_AUTHORIZATION = str2bool(get_variable_env("SKIP_MCP_AUTHORIZATION", Tru
|
|
|
144
144
|
APP_DEFAULT_SCOPE = get_variable_env("APP_DEFAULT_SCOPE", allow_empty=True)
|
|
145
145
|
|
|
146
146
|
AUTH_TEST_TOKEN = get_variable_env("AUTH_TEST_TOKEN", allow_empty=True)
|
|
147
|
+
|
|
148
|
+
MCP_TOOLS_MAX_RETRIES = int(get_variable_env("MCP_TOOLS_MAX_RETRIES", default=10))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
aixtools/__init__.py,sha256=9NGHm7LjsQmsvjTZvw6QFJexSvAU4bCoN_KBk9SCa00,260
|
|
2
|
-
aixtools/_version.py,sha256=
|
|
2
|
+
aixtools/_version.py,sha256=I7oxlElEVr-U2wT5qgQ2G41IxS87cokjF8Z2fKVHGrc,706
|
|
3
3
|
aixtools/app.py,sha256=JzQ0nrv_bjDQokllIlGHOV0HEb-V8N6k_nGQH-TEsVU,5227
|
|
4
4
|
aixtools/chainlit.md,sha256=yC37Ly57vjKyiIvK4oUvf4DYxZCwH7iocTlx7bLeGLU,761
|
|
5
5
|
aixtools/context.py,sha256=I_MD40ZnvRm5WPKAKqBUAdXIf8YaurkYUUHSVVy-QvU,598
|
|
@@ -21,8 +21,8 @@ aixtools/a2a/app.py,sha256=p18G7fAInl9dcNYq6RStBjv1C3aD6oilQq3WXtBuk30,5069
|
|
|
21
21
|
aixtools/a2a/utils.py,sha256=EHr3IyyBJn23ni-JcfAf6i3VpQmPs0g1TSnAZazvY_8,4039
|
|
22
22
|
aixtools/a2a/google_sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
aixtools/a2a/google_sdk/remote_agent_connection.py,sha256=gFsIja_nIQsAzxElv3A7_hG9GpDI5pkV-B_KDlcYlnc,3329
|
|
24
|
-
aixtools/a2a/google_sdk/utils.py,sha256=
|
|
25
|
-
aixtools/a2a/google_sdk/pydantic_ai_adapter/agent_executor.py,sha256=
|
|
24
|
+
aixtools/a2a/google_sdk/utils.py,sha256=k5VtTr4XLxsSKQDqly9QtWcZ5xfm03VbPpQ8OwoXtiQ,4369
|
|
25
|
+
aixtools/a2a/google_sdk/pydantic_ai_adapter/agent_executor.py,sha256=xamLIKl-FeB8PElVKgiIKR-MhFKmPjywHmC_ow-fGAA,9904
|
|
26
26
|
aixtools/a2a/google_sdk/pydantic_ai_adapter/storage.py,sha256=nGoVL7MPoZJW7iVR71laqpUYP308yFKZIifJtvUgpiU,878
|
|
27
27
|
aixtools/agents/__init__.py,sha256=MAW196S2_G7uGqv-VNjvlOETRfuV44WlU1leO7SiR0A,282
|
|
28
28
|
aixtools/agents/agent.py,sha256=7ZxKVOqLI_9K5LsTnqoTwRRHp6i-nFgQrJ6yA4M9iUE,7700
|
|
@@ -62,7 +62,7 @@ aixtools/logging/mcp_logger.py,sha256=d2I5l4t0d6rQH17w23FpE1IUD8Ax-mSaKfByCH86q4
|
|
|
62
62
|
aixtools/logging/model_patch_logging.py,sha256=CW5-kKI-zNEgZhNV4vx3EQu6fbrEtX7VjA6fE5loRLQ,2916
|
|
63
63
|
aixtools/logging/open_telemetry.py,sha256=fJjF1ou_8GyfNfbyWDQPGK6JAUrUaPwURYPHhXEtDBE,1121
|
|
64
64
|
aixtools/mcp/__init__.py,sha256=y6Akm5xeEFJ0K0TNM6aiTsUSe5k5kft8LSTaSEaY7vE,404
|
|
65
|
-
aixtools/mcp/client.py,sha256=
|
|
65
|
+
aixtools/mcp/client.py,sha256=lu1780mO3uRMzfzb32p74wH2VUv7jwfrHfZeLB5s3ME,18610
|
|
66
66
|
aixtools/mcp/example_client.py,sha256=QCFGP3NCNJMOKWjUOnFwjnbJhUSb879IA1ZYmwjRnmc,889
|
|
67
67
|
aixtools/mcp/example_server.py,sha256=1SWCyrLWsAnOa81HC4QbPJo_lBVu0b3SZBWI-qDh1vQ,458
|
|
68
68
|
aixtools/mcp/exceptions.py,sha256=9m3hy9fRINbXTSgkE71XW_luklgH6xBRp7VnSRfpyzQ,173
|
|
@@ -85,7 +85,7 @@ aixtools/tools/doctor/mcp_tool_doctor.py,sha256=sX2q5GfNkmUYxnXrqMpeGIwGfeL1LpYJ
|
|
|
85
85
|
aixtools/tools/doctor/tool_doctor.py,sha256=EY1pshjLGLD0j6cc1ZFtbc0G19I5IbOZwHFDqypE49Q,2661
|
|
86
86
|
aixtools/tools/doctor/tool_recommendation.py,sha256=LYyVOSXdAorWiY4P-ucSA1vLlV5BTEfX4GzBXNE_X0M,1569
|
|
87
87
|
aixtools/utils/__init__.py,sha256=xT6almZBQYMfj4h7Hq9QXDHyVXbOOTxqLsmJsxYYnSw,757
|
|
88
|
-
aixtools/utils/config.py,sha256=
|
|
88
|
+
aixtools/utils/config.py,sha256=OGTlvkc8hxL9GJk9AqEWTUIKLntl6TeL10Ni7t6C0nE,5575
|
|
89
89
|
aixtools/utils/config_util.py,sha256=3Ya4Qqhj1RJ1qtTTykQ6iayf5uxlpigPXgEJlTi1wn4,2229
|
|
90
90
|
aixtools/utils/enum_with_description.py,sha256=zjSzWxG74eR4x7dpmb74pLTYCWNSMvauHd7_9LpDYIw,1088
|
|
91
91
|
aixtools/utils/files.py,sha256=8JnxwHJRJcjWCdFpjzWmo0po2fRg8esj4H7sOxElYXU,517
|
|
@@ -95,8 +95,8 @@ aixtools/utils/chainlit/cl_agent_show.py,sha256=vaRuowp4BRvhxEr5hw0zHEJ7iaSF_5bo
|
|
|
95
95
|
aixtools/utils/chainlit/cl_utils.py,sha256=fxaxdkcZg6uHdM8uztxdPowg3a2f7VR7B26VPY4t-3c,5738
|
|
96
96
|
aixtools/vault/__init__.py,sha256=fsr_NuX3GZ9WZ7dGfe0gp_5-z3URxAfwVRXw7Xyc0dU,141
|
|
97
97
|
aixtools/vault/vault.py,sha256=9dZLWdZQk9qN_Q9Djkofw9LUKnJqnrX5H0fGusVLBhA,6037
|
|
98
|
-
aixtools-0.2.
|
|
99
|
-
aixtools-0.2.
|
|
100
|
-
aixtools-0.2.
|
|
101
|
-
aixtools-0.2.
|
|
102
|
-
aixtools-0.2.
|
|
98
|
+
aixtools-0.2.22.dist-info/METADATA,sha256=JfIBvHI6hfSp7sjuKUg7lTnsx48sJFQfwpt5UzaZCeg,27958
|
|
99
|
+
aixtools-0.2.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
100
|
+
aixtools-0.2.22.dist-info/entry_points.txt,sha256=q8412TG4T0S8K0SKeWp2vkVPIDYQs0jNoHqcQ7qxOiA,155
|
|
101
|
+
aixtools-0.2.22.dist-info/top_level.txt,sha256=wBn-rw9bCtxrR4AYEYgjilNCUVmKY0LWby9Zan2PRJM,9
|
|
102
|
+
aixtools-0.2.22.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|