feat: Add support for R execution environments and enhance execution tooling

This commit is contained in:
Hans Aschauer 2026-03-05 00:04:01 +01:00
parent ac91362bd2
commit 17577d3fba
2 changed files with 41 additions and 7 deletions

View file

@ -2,7 +2,7 @@
## Overview ## Overview
MCP-Forge is an MCP (Model Context Protocol) server that provides intelligent code execution capabilities for AI agents. It enables agents to execute Python code in isolated containers while having access to other MCP tools, optimizing data processing by keeping large datasets in the execution environment rather than passing them through the LLM context. MCP-Forge is an MCP (Model Context Protocol) server that provides intelligent code execution capabilities for AI agents. It enables agents to execute Python and R code in isolated containers while having access to other MCP tools, optimizing data processing by keeping large datasets in the execution environment rather than passing them through the LLM context.
## Core Concept ## Core Concept
@ -12,7 +12,7 @@ MCP-Forge is an MCP (Model Context Protocol) server that provides intelligent co
- Limited by context window size - Limited by context window size
**Solution:** MCP-Forge provides a code execution environment where: **Solution:** MCP-Forge provides a code execution environment where:
- MCP tools are available as Python functions - MCP tools are available as language-native functions (Python and R)
- Agents can write code to process data locally - Agents can write code to process data locally
- Only relevant results flow back to the agent - Only relevant results flow back to the agent
- The agent already knows tool signatures from its own configuration - The agent already knows tool signatures from its own configuration
@ -58,7 +58,7 @@ MCP-Forge Server
│ └─ mcp-forge/custom:{user-env-name} │ └─ mcp-forge/custom:{user-env-name}
└─ Isolated Execution Containers └─ Isolated Execution Containers
├─ Python Runtime ├─ Python/R Runtime
├─ MCP Client (injected tools) ├─ MCP Client (injected tools)
└─ Session Volumes └─ Session Volumes
``` ```
@ -137,17 +137,19 @@ MCP-Forge Server
#### Tools #### Tools
**`execute_python`** **`execute_code`**
Execute Python code in an isolated container with MCP tools available. Execute Python or R code in an isolated container with MCP tools available.
Parameters: Parameters:
```json ```json
{ {
"code": "string (required) - Python code to execute", "code": "string (required) - Source code to execute",
"language": "string (optional) - 'python' (default) or 'r'",
"mcp_tools": "array (optional) - List of MCP tool names to inject", "mcp_tools": "array (optional) - List of MCP tool names to inject",
"session_id": "string (optional) - Session ID for stateful execution (null = stateless)", "session_id": "string (optional) - Session ID for stateful execution (null = stateless)",
"backend": "string (optional) - 'simple' (default) or 'jupyter'", "backend": "string (optional) - 'simple' (default) or 'jupyter'",
"kernel": "string (optional) - for jupyter backend: 'python' (ipykernel) or 'r' (rkernel)",
"timeout": "integer (optional) - Max execution time in seconds (default: 300)", "timeout": "integer (optional) - Max execution time in seconds (default: 300)",
"volumes": "object (optional) - Volume mount configuration", "volumes": "object (optional) - Volume mount configuration",
"custom_image": "string (optional) - Custom environment name to use", "custom_image": "string (optional) - Custom environment name to use",
@ -1446,3 +1448,28 @@ print(result['result'])
- Comprehensive monitoring - Comprehensive monitoring
- High availability setup - High availability setup
- Documentation and examples - Documentation and examples
## Multi-language Execution (Python + R)
MCP-Forge supports both Python and R execution modes:
- **Simple backend**
- `language=python` runs python shell execution (existing path)
- `language=r` runs R shell execution (new path)
- Stateless by default
- **Jupyter backend**
- `kernel=python` uses IPython kernel (existing path)
- `kernel=r` uses IRkernel (new path)
- Stateful sessions keyed by `session_id`
### Tool Injection for R
The MCP bridge protocol remains Unix-socket JSON based and language-agnostic.
R injection wrappers mirror Python wrappers at a behavioral level:
- Generate R wrapper functions per allowed MCP tool
- Forward tool calls over mounted bridge socket
- Decode JSON responses to R lists/vectors
This keeps execution containers air-gapped while preserving access to configured MCP tools.

View file

@ -68,6 +68,13 @@
- Phase 5.3: Integration & End-to-End Testing - Phase 5.3: Integration & End-to-End Testing
- Phase 6: Documentation & Deployment - Phase 6: Documentation & Deployment
**New Workstream (2026-03-04): R execution environments**
- Add language selection to execution tooling (`python` + `r`)
- Add simple backend R shell execution path
- Add stateful Jupyter R kernel support (`IRkernel`)
- Add MCP tool injection generator for R wrappers
- Add tests first for R simple/stateful execution and server dispatch
**Test Count:** 387 tests passing **Test Count:** 387 tests passing
**Last Updated:** 2026-02-06 **Last Updated:** 2026-02-06