Skip to content

Support remote MCP servers over SSE/HTTP and harden the MCP client runtime#125

Merged
warren618 merged 3 commits into
HKUDS:mainfrom
shadowinlife:feat/builtin-agent-mcp-next
May 17, 2026
Merged

Support remote MCP servers over SSE/HTTP and harden the MCP client runtime#125
warren618 merged 3 commits into
HKUDS:mainfrom
shadowinlife:feat/builtin-agent-mcp-next

Conversation

@shadowinlife
Copy link
Copy Markdown
Contributor

Summary

This PR extends the built-in agent's MCP client support from stdio-only to remote SSE and streamable HTTP servers.

It also hardens the runtime path by removing retry-on-timeout for remote tool calls, moving MCP registry construction off the async session loop, and making transport-switching config overrides safe.

Why

Before this change, the built-in agent could load external MCP tools only through local stdio subprocesses. Remote HTTP-based MCP servers were not actually supported.

Supporting remote transports also required fixing a few correctness issues around retries, async startup, and config merging.

Testing

  • Existing tests pass (pytest --ignore=agent/tests/e2e_backtest --tb=short -q)
  • New tests added (if applicable)
  • Tested manually (describe below)

Checklist

  • No changes to protected areas (src/agent/, src/session/, src/providers/) without prior discussion
  • No hardcoded values (API keys, file paths, magic numbers)
  • Code follows CONTRIBUTING.md guidelines
  • Documentation updated (if user-facing change)

shadowinlife and others added 2 commits May 17, 2026 13:24
Stop retrying remote MCP tool calls, move registry discovery off the session event loop, and make MCP transport overrides reset incompatible fields instead of poisoning the merged config.\n\nRequire explicit HTTP transport types for URL-based servers, add regression coverage for the merge and session startup paths, and align the operator docs with the current transport support.\n\nCo-Authored-By: Claude Code <noreply@anthropic.com>\nAI-Model: gpt-5.4\nAI-Contributed/Feature: 197/197\nAI-Contributed/UT: 300/300
Co-Authored-By: github-copilot <noreply@ai-tool.com>
AI-Contributed/Feature: 197/197
AI-Contributed/UT: 300/300
Add the pending SSE and streamable HTTP MCP integration fixtures and tests, mark the integration suites explicitly, and clean up the existing stdio integration notes.\n\nThe HTTP-based fixtures now bind an OS-assigned port and write the real port back to the test helper, so readiness checks no longer rely on race-prone port guessing.\n\nCo-Authored-By: Claude Code <noreply@anthropic.com>\nAI-Model: gpt-5.4\nAI-Contributed/Feature: 0/0\nAI-Contributed/UT: 602/602
Co-Authored-By: github-copilot <noreply@ai-tool.com>
AI-Contributed/Feature: 0/0
AI-Contributed/UT: 602/602
Copilot AI review requested due to automatic review settings May 17, 2026 08:46
@shadowinlife shadowinlife marked this pull request as draft May 17, 2026 08:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the agent’s MCP client from stdio-only subprocess servers to also support remote MCP servers over SSE and streamable HTTP, and hardens startup/config behavior to avoid unsafe retries and event-loop blocking during registry construction.

Changes:

  • Add SSE and streamable HTTP MCP transports (client adapter + schema validation) and document the new config fields.
  • Harden MCP runtime: remove retry-on-timeout for remote tool calls and build the MCP/tool registry off the async session loop.
  • Add integration + regression tests covering SSE/HTTP MCP discovery/calls, enabledTools filtering, unreachable-server behavior, and registry-build responsiveness.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
README.md Documents new MCP transport fields and updated transport support notes.
agent/SKILL.md Updates MCP server configuration docs for stdio vs HTTP transports.
agent/src/tools/mcp.py Adds SSE/streamable HTTP transports and removes timeout retries for remote tool calls.
agent/src/config/schema.py Validates transport-specific MCP server config; requires explicit type for URL-based servers.
agent/src/config/loader.py Makes override merging transport-aware and safely falls back on invalid merged configs.
agent/src/session/service.py Moves registry construction into the executor to keep the async loop responsive.
agent/tests/test_agent_config.py Expands schema + override-merge tests for new transport behaviors.
agent/tests/test_mcp_client_adapter.py Adds adapter unit tests for transport selection + updated retry behavior.
agent/tests/test_session_service_mcp.py Regression test ensuring registry build doesn’t block the event loop.
agent/tests/mcp_http_test_helpers.py Adds shared subprocess/port/ready-check helpers for HTTP MCP integration tests.
agent/tests/test_mcp_sse_integration.py Full-stack SSE MCP integration tests with a real FastMCP server subprocess.
agent/tests/test_mcp_streamable_http_integration.py Full-stack streamable HTTP MCP integration tests with a real FastMCP server subprocess.
agent/tests/test_mcp_stdio_integration.py Marks stdio MCP integration tests as integration.
agent/tests/fixtures/fake_mcp_sse_server.py Minimal FastMCP SSE server fixture for integration tests.
agent/tests/fixtures/fake_mcp_streamable_http_server.py Minimal FastMCP streamable HTTP server fixture for integration tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread agent/src/tools/mcp.py Outdated
Comment thread agent/tests/mcp_http_test_helpers.py
Align MCP transport resolution with schema validation, update the README
field matrix, and normalize new MCP HTTP test helper messages to English.

Co-Authored-By: Claude Code <noreply@anthropic.com>
AI-Model: GPT-5.4
Co-Authored-By: github-copilot <noreply@ai-tool.com>
AI-Contributed/Feature: 27/27
AI-Contributed/UT: 39/39
@shadowinlife shadowinlife marked this pull request as ready for review May 17, 2026 09:21
@warren618 warren618 merged commit 55257b9 into HKUDS:main May 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants