Documentation Index
Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
Use this file to discover all available pages before exploring further.
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
from mcp_use.client.code_executor import CodeExecutor
method init
Initialize the code executor.Parameters
The MCPClient instance to use for tool calls.
Signaturedef __init__(client: MCPClient):
method execute
Execute Python code with access to MCP tools.Parameters
Execution timeout in seconds.
Returns
Signaturedef execute(code: str, timeout: float = 30.0):