eval_ruby
Execute Ruby code directly in Sketchup through the SketchupMCP server, enabling dynamic 3D modeling, scene manipulation, and integration with AI-driven workflows.
Instructions
Evaluate arbitrary Ruby code in Sketchup
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "eval_ruby"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |
Implementation Reference
- src/sketchup_mcp/server.py:538-575 (handler)The core handler function for the 'eval_ruby' tool. It is decorated with @mcp.tool() for automatic registration and schema inference from type hints and docstring. The function evaluates the provided Ruby code by forwarding it to the SketchUp connection.
@mcp.tool() def eval_ruby( ctx: Context, code: str ) -> str: """Evaluate arbitrary Ruby code in Sketchup""" try: logger.info(f"eval_ruby called with code length: {len(code)}") sketchup = get_sketchup_connection() result = sketchup.send_command( method="tools/call", params={ "name": "eval_ruby", "arguments": { "code": code } }, request_id=ctx.request_id ) logger.info(f"eval_ruby result: {result}") # Format the response to include the result response = { "success": True, "result": result.get("content", [{"text": "Success"}])[0].get("text", "Success") if isinstance(result.get("content"), list) and len(result.get("content", [])) > 0 else "Success" } return json.dumps(response) except Exception as e: logger.error(f"Error in eval_ruby: {str(e)}") return json.dumps({ "success": False, "error": str(e) })