Skip to main content
Glama
mhyrr
by mhyrr

eval_ruby

Evaluate Ruby code directly within Sketchup using the MCP server, enabling prompt-assisted 3D modeling and scene manipulation through script execution.

Instructions

Evaluate arbitrary Ruby code in Sketchup

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Implementation Reference

  • The handler function for the 'eval_ruby' tool. It proxies the Ruby code to the SketchUp extension via a JSON-RPC socket connection and returns the formatted result.
    @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)
            })
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mhyrr/sketchup-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server