Skip to main content
Code execution engine for MCP tools. This module provides secure code execution capabilities for MCP clients, allowing agents to interact with tools through Python code instead of direct tool calls.

CodeExecutor

method init

Initialize the code executor.Parameters
MCPClient
required
The MCPClient instance to use for tool calls.
Signature

method execute

Execute Python code with access to MCP tools.Parameters
str
required
Python code to execute.
float
default:"30.0"
Execution timeout in seconds.
Returns
dict[str, Any]
Signature