Skip to content

Mcp Env #976

Open
vyomakesh0728 wants to merge 17 commits intoPrimeIntellect-ai:mainfrom
vyomakesh0728:mcp_foundation
Open

Mcp Env #976
vyomakesh0728 wants to merge 17 commits intoPrimeIntellect-ai:mainfrom
vyomakesh0728:mcp_foundation

Conversation

@vyomakesh0728
Copy link

@vyomakesh0728 vyomakesh0728 commented Mar 3, 2026

Description

New transport-backed MCPEnv for current main, adapted from the broader MCP foundation proposed in #566

  • Adds verifiers/utils/mcp_utils/ with shared MCP utilities, tool wrapping, config models, and transports for stdio, remote streamable HTTP, sandboxed streamable HTTP, and synthetic/in-memory backends.

  • MCPEnv is ported onto the current StatefulToolEnv / tool_defs architecture, supports shared or rollout-scoped MCP connections, preserves direct env.call_tool(...) compatibility, and keeps it stable across reconnects.

  • transports are an interface for creating and using mcp servers with environments
  • a base transport defines the basic methods needed by a transport, with the 2 main being stdio and http
  • the sandbox transport is an extension of the http transport given it is still running streamable http mcp just with some extra steps and additional resource management
  • during initialization of a transport a client session connected to the server is created and the list of tools available from the server
  • streamable HTTP for the MCP server protocol
  • TCP for Prime sandbox port exposure
class MCPTransport(ABC):
    """Base transport for MCP connections."""

    @abstractmethod
    async def connect(self) -> dict[str, MCPTool]:
        """Connect and return available tools."""

    @abstractmethod
    async def call_tool(self, tool_name: str, arguments: dict) -> Any:
        """Execute a tool call."""

    @abstractmethod
    async def disconnect(self) -> None:
        """Disconnect and clean up transport resources."""

    @abstractmethod
    async def is_connected(self) -> bool:
        """Check connection status."""

Validation

Screenshot 1947-12-12 at 6 00 42 PM
  • focused tests, ty, and pre-commit passed
  • stdio validated with a MCP server
  • http validated with a streamable HTTP MCP server
  • sandbox validated end-to-end with a Prime sandbox MCP server using TCP exposure

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test improvement

Testing

  • All existing tests pass when running uv run pytest locally.
  • New tests have been added to cover the changes

Checklist

  • My code follows the style guidelines of this project as outlined in AGENTS.md
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Additional Notes

This PR is the current-main port for the broader MCP foundation proposed in #566, adapted to today's StatefulToolEnv / tool_defs APIs and envs.


Note

Cursor Bugbot is generating a summary for commit 595d8bf. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

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.

1 participant