eval
Evaluates a Pharo Smalltalk expression in a live image and returns the result or error.
Instructions
Evaluate a Pharo Smalltalk expression with PharoSmalltalkInteropServer.
Args: code: The Smalltalk code to evaluate
Returns: dict: API response with success/error and result - Success: {"success": True, "result": any} - result contains the evaluation result - Error: {"success": False, "error": str} - error contains error message
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The Smalltalk code to evaluate |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- pharo_smalltalk_interop_mcp_server/server.py:36-36 (registration)The tool 'eval' is registered via the @mcp.tool('eval') decorator on the eval_code function.
@mcp.tool("eval") - The MCP tool handler function 'eval_code' that receives the 'code' parameter and delegates to interop_eval().
def eval_code( _: Context, code: Annotated[str, Field(description="The Smalltalk code to evaluate")], ) -> dict[str, Any]: """ Evaluate a Pharo Smalltalk expression with PharoSmalltalkInteropServer. Args: code: The Smalltalk code to evaluate Returns: dict: API response with success/error and result - Success: {"success": True, "result": any} - result contains the evaluation result - Error: {"success": False, "error": str} - error contains error message """ return interop_eval(code) - Input schema: 'code' parameter is defined as Annotated[str, Field(description='The Smalltalk code to evaluate')].
_: Context, code: Annotated[str, Field(description="The Smalltalk code to evaluate")], - The interop_eval() helper function in core.py that gets the PharoClient and calls client.evaluate(code).
def interop_eval(code: str) -> dict[str, Any]: """ Evaluate a Pharo Smalltalk expression with PharoSmalltalkInteropServer. Args: code: The Smalltalk code to evaluate Returns: API response with success/error and result """ client = get_pharo_client() return client.evaluate(code) - The PharoClient.evaluate() method that POSTs the code to the /eval endpoint of the Pharo server.
def evaluate(self, code: str) -> dict[str, Any]: """Evaluate Smalltalk expression.""" data = {"code": code} return self._make_request("POST", "/eval", data)