Skip to content

[Feature] Add MCP Protocol API as Alternative Interface to E2B#165

Open
bcfre wants to merge 1 commit intoopenkruise:masterfrom
bcfre:mcp-dev
Open

[Feature] Add MCP Protocol API as Alternative Interface to E2B#165
bcfre wants to merge 1 commit intoopenkruise:masterfrom
bcfre:mcp-dev

Conversation

@bcfre
Copy link
Copy Markdown
Contributor

@bcfre bcfre commented Feb 27, 2026

Ⅰ. Describe what this PR does

┌─────────────┐    ┌─────────────┐
│   E2B API   │    │   MCP API   │   <-- External Protocol Interfaces
└──────┬──────┘    └──────┬──────┘
       │                  │
       └────────┬─────────┘
                ▼
        ┌───────────────┐
        │ SandboxManager│              <-- Unified Management Layer
        └───────┬───────┘
                ▼
        ┌───────────────┐
        │  Sandbox CRs  │              <-- Kubernetes Resources
        └───────────────┘

Both E2B and MCP APIs share the same underlying sandbox infrastructure - they are simply different protocol adapters over the unified sandbox management layer.

Changes
1. MCP Server Integration (cmd/sandbox-manager/main.go)

  • Add MCP server alongside existing E2B server
  • Configure via environment variables: MCP_SERVER_ENABLED, MCP_SERVER_PORT, MCP_SANDBOX_TTL, MCP_SESSION_SYNC_PORT

2. Sandbox Event Callback (pkg/sandbox-manager/infra/)

  • Add SandboxEventHandler interface to propagate sandbox lifecycle events to MCP session layer
  • Enable MCP sessions to track their associated sandbox state

3. Session-Sandbox Binding (api/v1alpha1/sandboxset_types.go)

  • Add AnnotationMCPSessionID to link MCP sessions with underlying sandboxes

4. Expose Shared Components (pkg/servers/e2b/core.go, pkg/sandbox-manager/core.go)

  • Expose SandboxManager and KeyStorage for MCP server reuse
  • Add ListPeers() for MCP cluster discovery

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how to verify it

Ⅳ. Special notes for reviews

@kruise-bot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 77.52235% with 176 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.73%. Comparing base (3d164d7) to head (2539f26).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
pkg/sandbox-manager/infra/sandboxcr/infra.go 0.00% 29 Missing and 3 partials ⚠️
pkg/servers/mcp/handler.go 87.94% 22 Missing and 5 partials ⚠️
pkg/servers/mcp/sandbox.go 66.66% 25 Missing and 2 partials ⚠️
pkg/servers/mcp/server.go 71.57% 24 Missing and 3 partials ⚠️
pkg/servers/mcp/peer.go 82.35% 19 Missing and 2 partials ⚠️
pkg/servers/mcp/session.go 77.52% 18 Missing and 2 partials ⚠️
pkg/sandbox-manager/core.go 0.00% 7 Missing ⚠️
pkg/servers/e2b/core.go 0.00% 4 Missing ⚠️
pkg/servers/mcp/middleware.go 93.75% 1 Missing and 2 partials ⚠️
pkg/utils/sandbox-manager/proxyutils/default.go 25.00% 2 Missing and 1 partial ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #165      +/-   ##
==========================================
+ Coverage   56.87%   59.73%   +2.86%     
==========================================
  Files          94      103       +9     
  Lines        5734     6549     +815     
==========================================
+ Hits         3261     3912     +651     
- Misses       2236     2381     +145     
- Partials      237      256      +19     
Flag Coverage Δ
unittests 59.73% <77.52%> (+2.86%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AiRanthem
Copy link
Copy Markdown
Member

The coverage of 59.87805% seems to be not high enough

@kruise-bot
Copy link
Copy Markdown

@bcfre: PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants