Skip to content

fix(workspace): skip MCP gateway bootstrap when unused - #3193

Open
HsbcJone wants to merge 1 commit into
agentscope-ai:mainfrom
HsbcJone:cursor/skip-mcp-gateway-when-unused-ded9
Open

HsbcJone wants to merge 1 commit into
agentscope-ai:mainfrom
HsbcJone:cursor/skip-mcp-gateway-when-unused-ded9

Conversation

@HsbcJone

@HsbcJone HsbcJone commented Oct 9, 2026

Copy link
Copy Markdown

Summary

Fixes #2113.

SandboxedWorkspaceBase.initialize() treated the in-sandbox MCP gateway as part of every sandbox, so workspaces that only need Bash, file tools, and Skills still installed a gateway virtualenv and health-checked FastAPI.

This change splits Glob/Grep system bootstrap from the MCP gateway lifecycle:

  • _system_bootstrap_commands() / _ensure_system_runtime() still install ripgrep and the Glob helper on every initialize().
  • The gateway virtualenv, process, and health check run during initialize() only when default_mcps is non-empty or the restored .mcp file lists at least one server.
  • The first add_mcp() starts the gateway once (concurrent callers share that start; a failed start can be retried).
  • list_mcps() returns [] when no gateway exists; remove_mcp(), reset(), and close() stay valid in that case.
  • OpenSandbox, E2B, Daytona, Kubernetes, Apple Container, and Bubblewrap all use the same split.

Changes

  • Separate system runtime bootstrap from MCP gateway setup in SandboxedWorkspaceBase
  • Update OpenSandbox / E2B / Daytona / K8s / Apple Container / Bubblewrap workspaces accordingly
  • Extend Daytona / Bubblewrap / Apple Container tests for the new lifecycle

How I tested this

pytest tests/workspace_daytona_test.py tests/workspace_bubblewrap_test.py tests/workspace_applecontainer_test.py tests/workspace_docker_build_test.py tests/workspace_local_test.py tests/workspace_prewarm_test.py tests/workspace_skill_archive_test.py

158 passed, 31 skipped (existing live Docker/E2B/Daytona/Kubernetes/Bubblewrap/Apple Container suites).

black, flake8, and pylint (10.00/10) on the changed files; mypy on _base.py and _sandboxed_base.py reported no issues.

Checklist

  • Informative title for release notes
  • Single goal
  • Style checks on changed files
  • Tests updated / added
  • Docs (N/A for this internal workspace lifecycle change)

Sandboxed initialize always installed and health-checked the in-sandbox
MCP gateway, even with empty default_mcps and an empty or absent .mcp
file. Keep Glob/Grep setup on the base runtime path, start the gateway
only when an MCP is configured, and launch it on the first add_mcp.

Co-authored-by: mengxiaopeng <602012854@qq.com>
@github-actions github-actions Bot added the pr/awaiting-review Waiting for maintainers to review this PR label Oct 9, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr/awaiting-review Waiting for maintainers to review this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid unconditional MCP gateway bootstrap for workspaces that do not use MCP

2 participants