Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions astrbot/core/agent/mcp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from astrbot.core.agent.run_context import ContextWrapper
from astrbot.core.utils.log_pipe import LogPipe

from .mcp_oauth import create_mcp_http_auth, has_mcp_oauth_config
from .run_context import TContext
from .tool import FunctionTool

Expand Down Expand Up @@ -428,9 +429,12 @@ def logging_callback(
self.server_errlogs.append(log_msg)

if "url" in cfg:
success, error_msg = await _quick_test_mcp_connection(cfg)
if not success:
raise Exception(error_msg)
auth = await create_mcp_http_auth(cfg)

if not has_mcp_oauth_config(cfg):
success, error_msg = await _quick_test_mcp_connection(cfg)
if not success:
raise Exception(error_msg)

if "transport" in cfg:
transport_type = cfg["transport"]
Expand All @@ -446,6 +450,7 @@ def logging_callback(
headers=cfg.get("headers", {}),
timeout=cfg.get("timeout", 5),
sse_read_timeout=cfg.get("sse_read_timeout", 60 * 5),
auth=auth,
)
streams = await self.exit_stack.enter_async_context(
self._streams_context,
Expand All @@ -471,6 +476,7 @@ def logging_callback(
timeout=timeout,
sse_read_timeout=sse_read_timeout,
terminate_on_close=cfg.get("terminate_on_close", True),
auth=auth,
)
read_s, write_s, _ = await self.exit_stack.enter_async_context(
self._streams_context,
Expand Down
Loading
Loading