fast-agent-mcp 0.2.29__py3-none-any.whl → 0.2.30__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.
- {fast_agent_mcp-0.2.29.dist-info → fast_agent_mcp-0.2.30.dist-info}/METADATA +1 -1
- {fast_agent_mcp-0.2.29.dist-info → fast_agent_mcp-0.2.30.dist-info}/RECORD +15 -14
- mcp_agent/cli/commands/check_config.py +11 -2
- mcp_agent/config.py +16 -1
- mcp_agent/core/enhanced_prompt.py +105 -0
- mcp_agent/llm/model_factory.py +6 -0
- mcp_agent/llm/provider_key_manager.py +1 -0
- mcp_agent/llm/provider_types.py +2 -0
- mcp_agent/llm/providers/augmented_llm_aliyun.py +30 -0
- mcp_agent/llm/providers/augmented_llm_deepseek.py +15 -1
- mcp_agent/mcp/hf_auth.py +20 -1
- mcp_agent/mcp/mcp_aggregator.py +2 -1
- {fast_agent_mcp-0.2.29.dist-info → fast_agent_mcp-0.2.30.dist-info}/WHEEL +0 -0
- {fast_agent_mcp-0.2.29.dist-info → fast_agent_mcp-0.2.30.dist-info}/entry_points.txt +0 -0
- {fast_agent_mcp-0.2.29.dist-info → fast_agent_mcp-0.2.30.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
mcp_agent/__init__.py,sha256=18T0AG0W9sJhTY38O9GFFOzliDhxx9p87CvRyti9zbw,1620
|
2
2
|
mcp_agent/app.py,sha256=3mtHP1nRQcRaKhhxgTmCOv00alh70nT7UxNA8bN47QE,5560
|
3
|
-
mcp_agent/config.py,sha256=
|
3
|
+
mcp_agent/config.py,sha256=c3KxDNXuOhLSBQ7InVw6sUaTc_5K5YbzVPnTMxgF_34,13924
|
4
4
|
mcp_agent/console.py,sha256=Gjf2QLFumwG1Lav__c07X_kZxxEUSkzV-1_-YbAwcwo,813
|
5
5
|
mcp_agent/context.py,sha256=H7JbaZ_8SzzTagLmIgUPUPxX5370C5qjQAsasFPZG2Y,7510
|
6
6
|
mcp_agent/context_dependent.py,sha256=QXfhw3RaQCKfscEEBRGuZ3sdMWqkgShz2jJ1ivGGX1I,1455
|
@@ -22,7 +22,7 @@ mcp_agent/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
22
|
mcp_agent/cli/__main__.py,sha256=AVZ7tQFhU_sDOGuUGJq8ujgKtcxsYJBJwHbVaaiRDlI,166
|
23
23
|
mcp_agent/cli/main.py,sha256=XjrgXMBaPKkVqAFo8T9LJz6Tp1-ivrKDOuNYWke99YA,3090
|
24
24
|
mcp_agent/cli/terminal.py,sha256=GRwD-RGW7saIz2IOWZn5vD6JjiArscELBThm1GTFkuI,1065
|
25
|
-
mcp_agent/cli/commands/check_config.py,sha256=
|
25
|
+
mcp_agent/cli/commands/check_config.py,sha256=JKOHniuMlU1bJ5vmyY7g05HDP7ZYGSQktl19bNx5I4Y,18775
|
26
26
|
mcp_agent/cli/commands/go.py,sha256=LIsOJQuTdfCUcNm7JT-NQDU8cI-GCnYwYjN2VOWxvqs,8658
|
27
27
|
mcp_agent/cli/commands/quickstart.py,sha256=SM3CHMzDgvTxIpKjFuX9BrS_N1vRoXNBDaO90aWx1Rk,14586
|
28
28
|
mcp_agent/cli/commands/setup.py,sha256=eOEd4TL-b0DaDeSJMGOfNOsTEItoZ67W88eTP4aP-bo,6482
|
@@ -32,7 +32,7 @@ mcp_agent/core/agent_app.py,sha256=aVvOzMrXZ3TfRGyAsnvcrMMYZxBf8Saa0UuHiA7DV0w,9
|
|
32
32
|
mcp_agent/core/agent_types.py,sha256=bQVQMTwKH7qHIJsNglj4C_d6PNFBBzC_0RIkcENSII4,1459
|
33
33
|
mcp_agent/core/direct_decorators.py,sha256=aaVR4G6a8H9pVg6X_PGEZ8GzreP0ZO1-48ksIKvMNDI,14452
|
34
34
|
mcp_agent/core/direct_factory.py,sha256=d96OM1yS3eIocIiaA9FQt6C2zr6VDUyCJBTZCp_D4bs,17912
|
35
|
-
mcp_agent/core/enhanced_prompt.py,sha256=
|
35
|
+
mcp_agent/core/enhanced_prompt.py,sha256=_JlX_7tBpWm1rScBaprD9Tvcep1qPPfXrUsFlnWrTpE,23497
|
36
36
|
mcp_agent/core/error_handling.py,sha256=xoyS2kLe0eG0bj2eSJCJ2odIhGUve2SbDR7jP-A-uRw,624
|
37
37
|
mcp_agent/core/exceptions.py,sha256=ENAD_qGG67foxy6vDkIvc-lgopIUQy6O7zvNPpPXaQg,2289
|
38
38
|
mcp_agent/core/fastagent.py,sha256=uS_NSXeniUYFu6xce8OHGJ9PbEYNU-gm1XVpa1r0rZc,22893
|
@@ -54,17 +54,18 @@ mcp_agent/llm/augmented_llm_passthrough.py,sha256=zHcctNpwg4EFJvD1x9Eg443SVX-uyz
|
|
54
54
|
mcp_agent/llm/augmented_llm_playback.py,sha256=6L_RWIK__R67oZK7u3Xt3hWy1T2LnHXIO-efqgP3tPw,4177
|
55
55
|
mcp_agent/llm/augmented_llm_slow.py,sha256=6h4LXdBGBzDfKnvPBcfBh0RdfYl-UXo50EimA-W3tOY,1586
|
56
56
|
mcp_agent/llm/memory.py,sha256=HQ_c1QemOUjrkY6Z2omE6BG5fXga7y4jN7KCMOuGjPs,3345
|
57
|
-
mcp_agent/llm/model_factory.py,sha256=
|
57
|
+
mcp_agent/llm/model_factory.py,sha256=gR_MBL74f-KF9PvYbVjXc9Qv5GyoMrRR7biXO6oGDvk,10686
|
58
58
|
mcp_agent/llm/prompt_utils.py,sha256=yWQHykoK13QRF7evHUKxVF0SpVLN-Bsft0Yixzvn0g0,4825
|
59
|
-
mcp_agent/llm/provider_key_manager.py,sha256
|
60
|
-
mcp_agent/llm/provider_types.py,sha256=
|
59
|
+
mcp_agent/llm/provider_key_manager.py,sha256=usMWozSMhek_FIlM1MeVDwAbs-P96SrEVPGd3YwF9E4,2833
|
60
|
+
mcp_agent/llm/provider_types.py,sha256=AkQl1r67wZ0gSIY6CXsiZiS3uw5DBF9E5yhIn3THayk,633
|
61
61
|
mcp_agent/llm/sampling_converter.py,sha256=C7wPBlmT0eD90XWabC22zkxsrVHKCrjwIwg6cG628cI,2926
|
62
62
|
mcp_agent/llm/sampling_format_converter.py,sha256=xGz4odHpOcP7--eFaJaFtUR8eR9jxZS7MnLH6J7n0EU,1263
|
63
63
|
mcp_agent/llm/providers/__init__.py,sha256=heVxtmuqFJOnjjxHz4bWSqTAxXoN1E8twC_gQ_yJpHk,265
|
64
64
|
mcp_agent/llm/providers/anthropic_utils.py,sha256=vYDN5G5jKMhD2CQg8veJYab7tvvzYkDMq8M1g_hUAQg,3275
|
65
|
+
mcp_agent/llm/providers/augmented_llm_aliyun.py,sha256=XylkJKZ9theSVUxJKOZkf1244hgzng4Ng4Dr209Qb-w,1101
|
65
66
|
mcp_agent/llm/providers/augmented_llm_anthropic.py,sha256=gK_IvllVBNJUUrSfpgFpdhM-d4liCt0MLq7d2lXS7RI,15510
|
66
67
|
mcp_agent/llm/providers/augmented_llm_azure.py,sha256=VPrD6lNrEw6EdYUTa9MDvHDNIPjJU5CG5xnKCM3JYdA,5878
|
67
|
-
mcp_agent/llm/providers/augmented_llm_deepseek.py,sha256=
|
68
|
+
mcp_agent/llm/providers/augmented_llm_deepseek.py,sha256=zI9a90dwT4r6E1f_xp4K50Cj9sD7y7kNRgjo0s1pd5w,3804
|
68
69
|
mcp_agent/llm/providers/augmented_llm_generic.py,sha256=5Uq8ZBhcFuQTt7koP_5ykolREh2iWu8zKhNbh3pM9lQ,1210
|
69
70
|
mcp_agent/llm/providers/augmented_llm_google_native.py,sha256=Axk6oKH5ctB6rXGnCjRKVkJq6O7rRqlD7aJ2He6UuZ8,20406
|
70
71
|
mcp_agent/llm/providers/augmented_llm_google_oai.py,sha256=cO4dvjTl9ymqEurCOo5nP09ATfXVjgkuk1yZAlWpS1s,1137
|
@@ -89,11 +90,11 @@ mcp_agent/logging/transport.py,sha256=m8YsLLu5T8eof_ndpLQs4gHOzqqEL98xsVwBwDsBfx
|
|
89
90
|
mcp_agent/mcp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
90
91
|
mcp_agent/mcp/common.py,sha256=MpSC0fLO21RcDz4VApah4C8_LisVGz7OXkR17Xw-9mY,431
|
91
92
|
mcp_agent/mcp/gen_client.py,sha256=fAVwFVCgSamw4PwoWOV4wrK9TABx1S_zZv8BctRyF2k,3030
|
92
|
-
mcp_agent/mcp/hf_auth.py,sha256
|
93
|
+
mcp_agent/mcp/hf_auth.py,sha256=YwEt7hMDJODFUIc6Zi1HLYsfVnvANGvyhpQwcPCMAgI,3379
|
93
94
|
mcp_agent/mcp/interfaces.py,sha256=PAou8znAl2HgtvfCpLQOZFbKra9F72OcVRfBJbboNX8,6965
|
94
95
|
mcp_agent/mcp/logger_textio.py,sha256=vljC1BtNTCxBAda9ExqNB-FwVNUZIuJT3h1nWmCjMws,3172
|
95
96
|
mcp_agent/mcp/mcp_agent_client_session.py,sha256=V17Lj21rMGIKKVAIyNx5l5gmC8jQuohjJGpRcoCXfVA,6862
|
96
|
-
mcp_agent/mcp/mcp_aggregator.py,sha256=
|
97
|
+
mcp_agent/mcp/mcp_aggregator.py,sha256=CrUtj-BHXXCb7sUlc_MF1d7HkiF9rjh6MKaGprflBB4,47076
|
97
98
|
mcp_agent/mcp/mcp_connection_manager.py,sha256=5JekxOJsB46spHsiXt7pyRPicg8TGHMiSJRtXRW2JB8,17074
|
98
99
|
mcp_agent/mcp/mime_utils.py,sha256=difepNR_gpb4MpMLkBRAoyhDk-AjXUHTiqKvT_VwS1o,1805
|
99
100
|
mcp_agent/mcp/prompt_message_multipart.py,sha256=BDwRdNwyWHb2q2bccDb2iR2VlORqVvkvoG3xYzcMpCE,4403
|
@@ -154,8 +155,8 @@ mcp_agent/resources/examples/workflows/router.py,sha256=E4x_-c3l4YW9w1i4ARcDtkde
|
|
154
155
|
mcp_agent/resources/examples/workflows/short_story.txt,sha256=X3y_1AyhLFN2AKzCKvucJtDgAFIJfnlbsbGZO5bBWu0,1187
|
155
156
|
mcp_agent/tools/tool_definition.py,sha256=L3Pxl-uLEXqlVoo-bYuFTFALeI-2pIU44YgFhsTKEtM,398
|
156
157
|
mcp_agent/ui/console_display.py,sha256=UKqax5V2TC0hkZZORmmd6UqUk0DGX7A25E3h1k9f42k,10982
|
157
|
-
fast_agent_mcp-0.2.
|
158
|
-
fast_agent_mcp-0.2.
|
159
|
-
fast_agent_mcp-0.2.
|
160
|
-
fast_agent_mcp-0.2.
|
161
|
-
fast_agent_mcp-0.2.
|
158
|
+
fast_agent_mcp-0.2.30.dist-info/METADATA,sha256=7q7NZipQQtERgEt6C6t60vtvEwqzyvjadJllHE5KOC4,30799
|
159
|
+
fast_agent_mcp-0.2.30.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
160
|
+
fast_agent_mcp-0.2.30.dist-info/entry_points.txt,sha256=bRniFM5zk3Kix5z7scX0gf9VnmGQ2Cz_Q1Gh7Ir4W00,186
|
161
|
+
fast_agent_mcp-0.2.30.dist-info/licenses/LICENSE,sha256=cN3FxDURL9XuzE5mhK9L2paZo82LTfjwCYVT7e3j0e4,10939
|
162
|
+
fast_agent_mcp-0.2.30.dist-info/RECORD,,
|
@@ -226,8 +226,17 @@ def get_config_summary(config_path: Optional[Path]) -> dict:
|
|
226
226
|
|
227
227
|
# Determine transport type
|
228
228
|
if "url" in server_config:
|
229
|
-
|
230
|
-
server_info["url"] =
|
229
|
+
url = server_config.get("url", "")
|
230
|
+
server_info["url"] = url
|
231
|
+
|
232
|
+
# Use URL path to determine transport type
|
233
|
+
try:
|
234
|
+
from .url_parser import parse_server_url
|
235
|
+
_, transport_type, _ = parse_server_url(url)
|
236
|
+
server_info["transport"] = transport_type.upper()
|
237
|
+
except Exception:
|
238
|
+
# Fallback to HTTP if URL parsing fails
|
239
|
+
server_info["transport"] = "HTTP"
|
231
240
|
|
232
241
|
# Get command and args
|
233
242
|
command = server_config.get("command", "")
|
mcp_agent/config.py
CHANGED
@@ -222,6 +222,15 @@ class TensorZeroSettings(BaseModel):
|
|
222
222
|
model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)
|
223
223
|
|
224
224
|
|
225
|
+
class HuggingFaceSettings(BaseModel):
|
226
|
+
"""
|
227
|
+
Settings for HuggingFace authentication (used for MCP connections).
|
228
|
+
"""
|
229
|
+
|
230
|
+
api_key: Optional[str] = None
|
231
|
+
model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)
|
232
|
+
|
233
|
+
|
225
234
|
class LoggerSettings(BaseModel):
|
226
235
|
"""
|
227
236
|
Logger settings for the fast-agent application.
|
@@ -291,7 +300,7 @@ class Settings(BaseSettings):
|
|
291
300
|
Default model for agents. Format is provider.model_name.<reasoning_effort>, for example openai.o3-mini.low
|
292
301
|
Aliases are provided for common models e.g. sonnet, haiku, gpt-4.1, o3-mini etc.
|
293
302
|
"""
|
294
|
-
|
303
|
+
|
295
304
|
auto_sampling: bool = True
|
296
305
|
"""Enable automatic sampling model selection if not explicitly configured"""
|
297
306
|
|
@@ -322,6 +331,12 @@ class Settings(BaseSettings):
|
|
322
331
|
azure: AzureSettings | None = None
|
323
332
|
"""Settings for using Azure OpenAI Service in the fast-agent application"""
|
324
333
|
|
334
|
+
aliyun: OpenAISettings | None = None
|
335
|
+
"""Settings for using Aliyun OpenAI Service in the fast-agent application"""
|
336
|
+
|
337
|
+
huggingface: HuggingFaceSettings | None = None
|
338
|
+
"""Settings for HuggingFace authentication (used for MCP connections)"""
|
339
|
+
|
325
340
|
logger: LoggerSettings | None = LoggerSettings()
|
326
341
|
"""Logger settings for the fast-agent application"""
|
327
342
|
|
@@ -2,6 +2,11 @@
|
|
2
2
|
Enhanced prompt functionality with advanced prompt_toolkit features.
|
3
3
|
"""
|
4
4
|
|
5
|
+
import asyncio
|
6
|
+
import os
|
7
|
+
import shlex
|
8
|
+
import subprocess
|
9
|
+
import tempfile
|
5
10
|
from importlib.metadata import version
|
6
11
|
from typing import List, Optional
|
7
12
|
|
@@ -96,6 +101,85 @@ class AgentCompleter(Completer):
|
|
96
101
|
)
|
97
102
|
|
98
103
|
|
104
|
+
# Helper function to open text in an external editor
|
105
|
+
def get_text_from_editor(initial_text: str = "") -> str:
|
106
|
+
"""
|
107
|
+
Opens the user\'s configured editor ($VISUAL or $EDITOR) to edit the initial_text.
|
108
|
+
Falls back to \'nano\' (Unix) or \'notepad\' (Windows) if neither is set.
|
109
|
+
Returns the edited text, or the original text if an error occurs.
|
110
|
+
"""
|
111
|
+
editor_cmd_str = os.environ.get("VISUAL") or os.environ.get("EDITOR")
|
112
|
+
|
113
|
+
if not editor_cmd_str:
|
114
|
+
if os.name == "nt": # Windows
|
115
|
+
editor_cmd_str = "notepad"
|
116
|
+
else: # Unix-like (Linux, macOS)
|
117
|
+
editor_cmd_str = "nano" # A common, usually available, simple editor
|
118
|
+
|
119
|
+
# Use shlex.split to handle editors with arguments (e.g., "code --wait")
|
120
|
+
try:
|
121
|
+
editor_cmd_list = shlex.split(editor_cmd_str)
|
122
|
+
if not editor_cmd_list: # Handle empty string from shlex.split
|
123
|
+
raise ValueError("Editor command string is empty or invalid.")
|
124
|
+
except ValueError as e:
|
125
|
+
rich_print(f"[red]Error: Invalid editor command string ('{editor_cmd_str}'): {e}[/red]")
|
126
|
+
return initial_text
|
127
|
+
|
128
|
+
# Create a temporary file for the editor to use.
|
129
|
+
# Using a suffix can help some editors with syntax highlighting or mode.
|
130
|
+
try:
|
131
|
+
with tempfile.NamedTemporaryFile(
|
132
|
+
mode="w+", delete=False, suffix=".txt", encoding="utf-8"
|
133
|
+
) as tmp_file:
|
134
|
+
if initial_text:
|
135
|
+
tmp_file.write(initial_text)
|
136
|
+
tmp_file.flush() # Ensure content is written to disk before editor opens it
|
137
|
+
temp_file_path = tmp_file.name
|
138
|
+
except Exception as e:
|
139
|
+
rich_print(f"[red]Error: Could not create temporary file for editor: {e}[/red]")
|
140
|
+
return initial_text
|
141
|
+
|
142
|
+
try:
|
143
|
+
# Construct the full command: editor_parts + [temp_file_path]
|
144
|
+
# e.g., [\'vim\', \'/tmp/somefile.txt\'] or [\'code\', \'--wait\', \'/tmp/somefile.txt\']
|
145
|
+
full_cmd = editor_cmd_list + [temp_file_path]
|
146
|
+
|
147
|
+
# Run the editor. This is a blocking call.
|
148
|
+
subprocess.run(full_cmd, check=True)
|
149
|
+
|
150
|
+
# Read the content back from the temporary file.
|
151
|
+
with open(temp_file_path, "r", encoding="utf-8") as f:
|
152
|
+
edited_text = f.read()
|
153
|
+
|
154
|
+
except FileNotFoundError:
|
155
|
+
rich_print(
|
156
|
+
f"[red]Error: Editor command '{editor_cmd_list[0]}' not found. "
|
157
|
+
f"Please set $VISUAL or $EDITOR correctly, or install '{editor_cmd_list[0]}'.[/red]"
|
158
|
+
)
|
159
|
+
return initial_text
|
160
|
+
except subprocess.CalledProcessError as e:
|
161
|
+
rich_print(
|
162
|
+
f"[red]Error: Editor '{editor_cmd_list[0]}' closed with an error (code {e.returncode}).[/red]"
|
163
|
+
)
|
164
|
+
return initial_text
|
165
|
+
except Exception as e:
|
166
|
+
rich_print(
|
167
|
+
f"[red]An unexpected error occurred while launching or using the editor: {e}[/red]"
|
168
|
+
)
|
169
|
+
return initial_text
|
170
|
+
finally:
|
171
|
+
# Always attempt to clean up the temporary file.
|
172
|
+
if "temp_file_path" in locals() and os.path.exists(temp_file_path):
|
173
|
+
try:
|
174
|
+
os.remove(temp_file_path)
|
175
|
+
except Exception as e:
|
176
|
+
rich_print(
|
177
|
+
f"[yellow]Warning: Could not remove temporary file {temp_file_path}: {e}[/yellow]"
|
178
|
+
)
|
179
|
+
|
180
|
+
return edited_text.strip() # Added strip() to remove trailing newlines often added by editors
|
181
|
+
|
182
|
+
|
99
183
|
def create_keybindings(on_toggle_multiline=None, app=None):
|
100
184
|
"""Create custom key bindings."""
|
101
185
|
kb = KeyBindings()
|
@@ -140,6 +224,27 @@ def create_keybindings(on_toggle_multiline=None, app=None):
|
|
140
224
|
"""Ctrl+L: Clear the input buffer."""
|
141
225
|
event.current_buffer.text = ""
|
142
226
|
|
227
|
+
@kb.add("c-e")
|
228
|
+
async def _(event) -> None:
|
229
|
+
"""Ctrl+E: Edit current buffer in $EDITOR."""
|
230
|
+
current_text = event.app.current_buffer.text
|
231
|
+
try:
|
232
|
+
# Run the synchronous editor function in a thread
|
233
|
+
edited_text = await event.app.loop.run_in_executor(
|
234
|
+
None, get_text_from_editor, current_text
|
235
|
+
)
|
236
|
+
event.app.current_buffer.text = edited_text
|
237
|
+
# Optionally, move cursor to the end of the edited text
|
238
|
+
event.app.current_buffer.cursor_position = len(edited_text)
|
239
|
+
except asyncio.CancelledError:
|
240
|
+
rich_print("[yellow]Editor interaction cancelled.[/yellow]")
|
241
|
+
except Exception as e:
|
242
|
+
rich_print(f"[red]Error during editor interaction: {e}[/red]")
|
243
|
+
finally:
|
244
|
+
# Ensure the UI is updated
|
245
|
+
if event.app:
|
246
|
+
event.app.invalidate()
|
247
|
+
|
143
248
|
return kb
|
144
249
|
|
145
250
|
|
mcp_agent/llm/model_factory.py
CHANGED
@@ -10,6 +10,7 @@ from mcp_agent.llm.augmented_llm_passthrough import PassthroughLLM
|
|
10
10
|
from mcp_agent.llm.augmented_llm_playback import PlaybackLLM
|
11
11
|
from mcp_agent.llm.augmented_llm_slow import SlowLLM
|
12
12
|
from mcp_agent.llm.provider_types import Provider
|
13
|
+
from mcp_agent.llm.providers.augmented_llm_aliyun import AliyunAugmentedLLM
|
13
14
|
from mcp_agent.llm.providers.augmented_llm_anthropic import AnthropicAugmentedLLM
|
14
15
|
from mcp_agent.llm.providers.augmented_llm_azure import AzureOpenAIAugmentedLLM
|
15
16
|
from mcp_agent.llm.providers.augmented_llm_deepseek import DeepSeekAugmentedLLM
|
@@ -103,6 +104,10 @@ class ModelFactory:
|
|
103
104
|
"gemini-2.0-flash": Provider.GOOGLE,
|
104
105
|
"gemini-2.5-flash-preview-05-20": Provider.GOOGLE,
|
105
106
|
"gemini-2.5-pro-preview-05-06": Provider.GOOGLE,
|
107
|
+
"qwen-turbo": Provider.ALIYUN,
|
108
|
+
"qwen-plus": Provider.ALIYUN,
|
109
|
+
"qwen-max": Provider.ALIYUN,
|
110
|
+
"qwen-long": Provider.ALIYUN,
|
106
111
|
}
|
107
112
|
|
108
113
|
MODEL_ALIASES = {
|
@@ -136,6 +141,7 @@ class ModelFactory:
|
|
136
141
|
Provider.OPENROUTER: OpenRouterAugmentedLLM,
|
137
142
|
Provider.TENSORZERO: TensorZeroAugmentedLLM,
|
138
143
|
Provider.AZURE: AzureOpenAIAugmentedLLM,
|
144
|
+
Provider.ALIYUN: AliyunAugmentedLLM,
|
139
145
|
}
|
140
146
|
|
141
147
|
# Mapping of special model names to their specific LLM classes
|
mcp_agent/llm/provider_types.py
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
from mcp_agent.core.request_params import RequestParams
|
2
|
+
from mcp_agent.llm.provider_types import Provider
|
3
|
+
from mcp_agent.llm.providers.augmented_llm_openai import OpenAIAugmentedLLM
|
4
|
+
|
5
|
+
ALIYUN_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
6
|
+
DEFAULT_QWEN_MODEL = "qwen-turbo"
|
7
|
+
|
8
|
+
|
9
|
+
class AliyunAugmentedLLM(OpenAIAugmentedLLM):
|
10
|
+
def __init__(self, *args, **kwargs) -> None:
|
11
|
+
super().__init__(*args, provider=Provider.ALIYUN, **kwargs)
|
12
|
+
|
13
|
+
def _initialize_default_params(self, kwargs: dict) -> RequestParams:
|
14
|
+
"""Initialize Aliyun-specific default parameters"""
|
15
|
+
chosen_model = kwargs.get("model", DEFAULT_QWEN_MODEL)
|
16
|
+
|
17
|
+
return RequestParams(
|
18
|
+
model=chosen_model,
|
19
|
+
systemPrompt=self.instruction,
|
20
|
+
parallel_tool_calls=True,
|
21
|
+
max_iterations=10,
|
22
|
+
use_history=True,
|
23
|
+
)
|
24
|
+
|
25
|
+
def _base_url(self) -> str:
|
26
|
+
base_url = None
|
27
|
+
if self.context.config and self.context.config.aliyun:
|
28
|
+
base_url = self.context.config.aliyun.base_url
|
29
|
+
|
30
|
+
return base_url if base_url else ALIYUN_BASE_URL
|
@@ -1,4 +1,10 @@
|
|
1
|
-
from
|
1
|
+
from copy import copy
|
2
|
+
from typing import List, Tuple, Type, cast
|
3
|
+
|
4
|
+
from openai.types.chat import (
|
5
|
+
ChatCompletionAssistantMessageParam,
|
6
|
+
ChatCompletionMessage,
|
7
|
+
)
|
2
8
|
|
3
9
|
from mcp_agent.core.request_params import RequestParams
|
4
10
|
from mcp_agent.llm.provider_types import Provider
|
@@ -77,3 +83,11 @@ class DeepSeekAugmentedLLM(OpenAIAugmentedLLM):
|
|
77
83
|
multipart_messages, request_params
|
78
84
|
)
|
79
85
|
return self._structured_from_multipart(result, model)
|
86
|
+
|
87
|
+
@classmethod
|
88
|
+
def convert_message_to_message_param(cls, message: ChatCompletionMessage, **kwargs) -> ChatCompletionAssistantMessageParam:
|
89
|
+
"""Convert a response object to an input parameter object to allow LLM calls to be chained."""
|
90
|
+
if hasattr(message, "reasoning_content"):
|
91
|
+
message = copy(message)
|
92
|
+
del message.reasoning_content
|
93
|
+
return cast("ChatCompletionAssistantMessageParam", message)
|
mcp_agent/mcp/hf_auth.py
CHANGED
@@ -22,7 +22,26 @@ def is_huggingface_url(url: str) -> bool:
|
|
22
22
|
return False
|
23
23
|
|
24
24
|
# Check for HuggingFace domains
|
25
|
-
|
25
|
+
if hostname in {"hf.co", "huggingface.co"}:
|
26
|
+
return True
|
27
|
+
|
28
|
+
# Check for HuggingFace Spaces (*.hf.space)
|
29
|
+
# Use endswith to match subdomains like space-name.hf.space
|
30
|
+
# but ensure exact match to prevent spoofing like evil.hf.space.com
|
31
|
+
if hostname.endswith(".hf.space") and hostname.count(".") >= 2:
|
32
|
+
# Additional validation: ensure it's a valid HF Space domain
|
33
|
+
# Format should be: {space-name}.hf.space
|
34
|
+
parts = hostname.split(".")
|
35
|
+
if len(parts) == 3 and parts[-2:] == ["hf", "space"]:
|
36
|
+
space_name = parts[0]
|
37
|
+
# Validate space name: not empty, not just hyphens/dots, no spaces
|
38
|
+
return (len(space_name) > 0 and
|
39
|
+
space_name != "-" and
|
40
|
+
not space_name.startswith(".") and
|
41
|
+
not space_name.endswith(".") and
|
42
|
+
" " not in space_name)
|
43
|
+
|
44
|
+
return False
|
26
45
|
except Exception:
|
27
46
|
return False
|
28
47
|
|
mcp_agent/mcp/mcp_aggregator.py
CHANGED
@@ -82,13 +82,14 @@ class MCPAggregator(ContextDependent):
|
|
82
82
|
await self.context._connection_manager.__aenter__()
|
83
83
|
self._persistent_connection_manager = self.context._connection_manager
|
84
84
|
|
85
|
-
await self.load_servers()
|
86
85
|
# Import the display component here to avoid circular imports
|
87
86
|
from mcp_agent.ui.console_display import ConsoleDisplay
|
88
87
|
|
89
88
|
# Initialize the display component
|
90
89
|
self.display = ConsoleDisplay(config=self.context.config)
|
91
90
|
|
91
|
+
await self.load_servers()
|
92
|
+
|
92
93
|
return self
|
93
94
|
|
94
95
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
File without changes
|
File without changes
|
File without changes
|