Add MCP injection support to Jupyter backend

- start_kernel() now accepts injection_code and bridge_socket_path
- Bridge Unix domain socket mounted as volume in container
- Injection code executed once on kernel startup (silent, no history)
- New _execute_injection_code() helper method with error handling
- Parameters passed through SessionManager.create_session()
- Parameters passed through JupyterBackend.execute()
- Updated JUPYTER_IMPLEMENTATION_STATUS.md

This mirrors the MCP injection pattern from the simple executor,
allowing MCP tools to be available in Jupyter sessions.
This commit is contained in:
Hans Aschauer 2026-02-07 08:13:40 +01:00
parent ed58c6ad5a
commit 9cc43e4166
4 changed files with 106 additions and 13 deletions

View file

@ -55,7 +55,9 @@ class JupyterBackend:
memory: Optional[str] = None,
cpu_quota: Optional[int] = None,
custom_image: Optional[str] = None,
volumes: Optional[Dict[str, dict]] = None
volumes: Optional[Dict[str, dict]] = None,
injection_code: Optional[str] = None,
bridge_socket_path: Optional[str] = None
) -> ExecutionResult:
"""
Execute code in stateful session.
@ -71,6 +73,8 @@ class JupyterBackend:
cpu_quota: CPU quota (uses config default if None)
custom_image: Custom image name (uses config default if None)
volumes: Volume mounts dict
injection_code: Optional MCP tool injection code (executed once at session start)
bridge_socket_path: Optional path to MCP bridge socket for mounting
Returns:
ExecutionResult with execution output and metadata
@ -106,7 +110,7 @@ class JupyterBackend:
try:
self.session_manager.get_session(session_id)
except SessionError:
# Session doesn't exist, create it
# Session doesn't exist, create it with MCP injection
resource_limits = ResourceLimits(
memory=memory,
cpu_quota=cpu_quota,
@ -117,7 +121,9 @@ class JupyterBackend:
self.session_manager.create_session(
session_id=session_id,
resource_limits=resource_limits,
volumes=volumes
volumes=volumes,
injection_code=injection_code,
bridge_socket_path=bridge_socket_path
)
# Execute in session