fast-agent-mcp 0.2.41__py3-none-any.whl → 0.2.43__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 fast-agent-mcp might be problematic. Click here for more details.

@@ -84,7 +84,9 @@ class OpenAIAugmentedLLM(AugmentedLLM[ChatCompletionMessageParam, ChatCompletion
84
84
  # TODO -- move this to model capabilities, add o4.
85
85
  chosen_model = self.default_request_params.model if self.default_request_params else None
86
86
  self._reasoning = chosen_model and (
87
- chosen_model.startswith("o3") or chosen_model.startswith("o1")
87
+ chosen_model.startswith("o3")
88
+ or chosen_model.startswith("o1")
89
+ or chosen_model.startswith("o4")
88
90
  )
89
91
  if self._reasoning:
90
92
  self.logger.info(
@@ -8,6 +8,7 @@ Logger module for the MCP Agent, which provides:
8
8
  """
9
9
 
10
10
  import asyncio
11
+ import logging
11
12
  import threading
12
13
  import time
13
14
  from contextlib import asynccontextmanager, contextmanager
@@ -206,6 +207,12 @@ class LoggingConfig:
206
207
  if cls._initialized:
207
208
  return
208
209
 
210
+ # Suppress boto3/botocore logging to prevent flooding
211
+ logging.getLogger('boto3').setLevel(logging.WARNING)
212
+ logging.getLogger('botocore').setLevel(logging.WARNING)
213
+ logging.getLogger('urllib3').setLevel(logging.WARNING)
214
+ logging.getLogger('s3transfer').setLevel(logging.WARNING)
215
+
209
216
  bus = AsyncEventBus.get(transport=transport)
210
217
 
211
218
  # Add standard listeners
mcp_agent/mcp/hf_auth.py CHANGED
@@ -69,14 +69,29 @@ def should_add_hf_auth(url: str, existing_headers: Optional[Dict[str, str]]) ->
69
69
  """
70
70
  # Only add HF auth if:
71
71
  # 1. URL is a HuggingFace URL
72
- # 2. No existing Authorization header is set
72
+ # 2. No existing Authorization/X-HF-Authorization header is set
73
73
  # 3. HF_TOKEN environment variable is available
74
74
 
75
75
  if not is_huggingface_url(url):
76
76
  return False
77
77
 
78
- if existing_headers and "Authorization" in existing_headers:
79
- return False
78
+ if existing_headers:
79
+ # Check if this is a .hf.space domain
80
+ try:
81
+ parsed = urlparse(url)
82
+ hostname = parsed.hostname
83
+ if hostname and hostname.endswith(".hf.space"):
84
+ # For .hf.space, check for X-HF-Authorization header
85
+ if "X-HF-Authorization" in existing_headers:
86
+ return False
87
+ else:
88
+ # For other HF domains, check for Authorization header
89
+ if "Authorization" in existing_headers:
90
+ return False
91
+ except Exception:
92
+ # Fallback to checking Authorization header
93
+ if "Authorization" in existing_headers:
94
+ return False
80
95
 
81
96
  return get_hf_token_from_env() is not None
82
97
 
@@ -101,6 +116,19 @@ def add_hf_auth_header(url: str, headers: Optional[Dict[str, str]]) -> Optional[
101
116
 
102
117
  # Create new headers dict or copy existing one
103
118
  result_headers = dict(headers) if headers else {}
104
- result_headers["Authorization"] = f"Bearer {hf_token}"
119
+
120
+ # Check if this is a .hf.space domain
121
+ try:
122
+ parsed = urlparse(url)
123
+ hostname = parsed.hostname
124
+ if hostname and hostname.endswith(".hf.space"):
125
+ # Use X-HF-Authorization for .hf.space domains
126
+ result_headers["X-HF-Authorization"] = f"Bearer {hf_token}"
127
+ else:
128
+ # Use standard Authorization header for other HF domains
129
+ result_headers["Authorization"] = f"Bearer {hf_token}"
130
+ except Exception:
131
+ # Fallback to standard Authorization header
132
+ result_headers["Authorization"] = f"Bearer {hf_token}"
105
133
 
106
134
  return result_headers
@@ -258,7 +258,12 @@ class MCPAggregator(ContextDependent):
258
258
  },
259
259
  )
260
260
 
261
- async def fetch_tools(client: ClientSession):
261
+ async def fetch_tools(client: ClientSession, server_name: str) -> List[Tool]:
262
+ # Only fetch tools if the server supports them
263
+ if not await self.server_supports_feature(server_name, "tools"):
264
+ logger.debug(f"Server '{server_name}' does not support tools")
265
+ return []
266
+
262
267
  try:
263
268
  result: ListToolsResult = await client.list_tools()
264
269
  return result.tools or []
@@ -287,7 +292,7 @@ class MCPAggregator(ContextDependent):
287
292
  server_connection = await self._persistent_connection_manager.get_server(
288
293
  server_name, client_session_factory=MCPAgentClientSession
289
294
  )
290
- tools = await fetch_tools(server_connection.session)
295
+ tools = await fetch_tools(server_connection.session, server_name)
291
296
  prompts = await fetch_prompts(server_connection.session, server_name)
292
297
  else:
293
298
  # Create a factory function for the client session
@@ -326,7 +331,7 @@ class MCPAggregator(ContextDependent):
326
331
  server_registry=self.context.server_registry,
327
332
  client_session_factory=create_session,
328
333
  ) as client:
329
- tools = await fetch_tools(client)
334
+ tools = await fetch_tools(client, server_name)
330
335
  prompts = await fetch_prompts(client, server_name)
331
336
 
332
337
  return server_name, tools, prompts
@@ -962,6 +967,11 @@ class MCPAggregator(ContextDependent):
962
967
  logger.error(f"Cannot refresh tools for unknown server '{server_name}'")
963
968
  return
964
969
 
970
+ # Check if server supports tools capability
971
+ if not await self.server_supports_feature(server_name, "tools"):
972
+ logger.debug(f"Server '{server_name}' does not support tools")
973
+ return
974
+
965
975
  await self.display.show_tool_update(aggregator=self, updated_server=server_name)
966
976
 
967
977
  async with self._refresh_lock:
@@ -1103,6 +1113,10 @@ class MCPAggregator(ContextDependent):
1103
1113
  Raises:
1104
1114
  Exception: If the resource couldn't be found or other error occurs
1105
1115
  """
1116
+ # Check if server supports resources capability
1117
+ if not await self.server_supports_feature(server_name, "resources"):
1118
+ raise ValueError(f"Server '{server_name}' does not support resources")
1119
+
1106
1120
  logger.info(
1107
1121
  "Requesting resource",
1108
1122
  data={
@@ -1163,6 +1177,11 @@ class MCPAggregator(ContextDependent):
1163
1177
  # Initialize empty list for this server
1164
1178
  results[s_name] = []
1165
1179
 
1180
+ # Check if server supports resources capability
1181
+ if not await self.server_supports_feature(s_name, "resources"):
1182
+ logger.debug(f"Server '{s_name}' does not support resources")
1183
+ continue
1184
+
1166
1185
  try:
1167
1186
  # Use the _execute_on_server method to call list_resources on the server
1168
1187
  result = await self._execute_on_server(