rlm_setup_ollama
Set up Ollama on macOS using Homebrew: install, start as background service, and pull a default model (gemma3:12b) for local inference, enabling large-scale processing with Massive Context MCP.
Instructions
Install Ollama via Homebrew (macOS).
Requires Homebrew pre-installed. Uses 'brew install' and 'brew services'. PROS: Auto-updates, pre-built binaries, managed service. CONS: Requires Homebrew, may prompt for sudo on first Homebrew install.
Args: install: Install Ollama via Homebrew (requires Homebrew) start_service: Start Ollama as a background service via brew services pull_model: Pull the default model (gemma3:12b) model: Model to pull (default: gemma3:12b). Use gemma3:4b or gemma3:1b for lower RAM systems.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| install | No | ||
| start_service | No | ||
| pull_model | No | ||
| model | No | gemma3:12b |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/rlm_mcp_server.py:1232-1276 (handler)The main tool handler for rlm_setup_ollama. It is a FastMCP-decorated async function that delegates to the _setup_ollama helper for Homebrew-based Ollama installation, service management, and model pulling.
@mcp.tool() async def rlm_setup_ollama( install: bool = False, start_service: bool = False, pull_model: bool = False, model: str = "gemma3:12b", ) -> dict: """Install Ollama via Homebrew (macOS). Requires Homebrew pre-installed. Uses 'brew install' and 'brew services'. PROS: Auto-updates, pre-built binaries, managed service. CONS: Requires Homebrew, may prompt for sudo on first Homebrew install. Args: install: Install Ollama via Homebrew (requires Homebrew) start_service: Start Ollama as a background service via brew services pull_model: Pull the default model (gemma3:12b) model: Model to pull (default: gemma3:12b). Use gemma3:4b or gemma3:1b for lower RAM systems. """ # If no actions specified, just do a system check if not any([install, start_service, pull_model]): sys_check = _check_system_requirements() return { "message": "No actions specified. Use install=true, start_service=true, or pull_model=true.", "system_check": sys_check, "example": "rlm_setup_ollama(install=true, start_service=true, pull_model=true)", } result = await _setup_ollama( install=install, start_service=start_service, pull_model=pull_model, model=model, ) # Add summary if result["success"]: result["summary"] = ( f"Setup complete! Actions: {', '.join(result['actions_taken']) or 'none'}. " f"Skipped: {', '.join(result['actions_skipped']) or 'none'}." ) else: result["summary"] = f"Setup failed: {'; '.join(result['errors'])}" return result - src/rlm_mcp_server.py:684-815 (helper)The _setup_ollama helper function that performs the actual Homebrew-based installation, service start via brew services, and model pulling. Called by the rlm_setup_ollama handler.
async def _setup_ollama( install: bool = False, start_service: bool = False, pull_model: bool = False, model: str = "gemma3:12b", ) -> dict: """Setup Ollama: install via Homebrew, start service, and pull model.""" result = { "actions_taken": [], "actions_skipped": [], "errors": [], "success": True, } # First check system requirements sys_check = _check_system_requirements() result["system_check"] = sys_check if not sys_check["is_macos"]: result["errors"].append("Ollama auto-setup only supported on macOS") result["success"] = False return result if not sys_check["homebrew_installed"] and install: result["errors"].append( "Homebrew required for installation. Install with: " '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' ) result["success"] = False return result # Install Ollama via Homebrew if install: if sys_check["ollama_installed"]: result["actions_skipped"].append("Ollama already installed") else: try: install_proc = subprocess.run( ["brew", "install", "ollama"], capture_output=True, text=True, timeout=300, # 5 minute timeout for install ) if install_proc.returncode == 0: result["actions_taken"].append("Installed Ollama via Homebrew") sys_check["ollama_installed"] = True else: result["errors"].append(f"Failed to install Ollama: {install_proc.stderr}") result["success"] = False except subprocess.TimeoutExpired: result["errors"].append("Ollama installation timed out (5 min limit)") result["success"] = False except Exception as e: result["errors"].append(f"Installation error: {e}") result["success"] = False # Start Ollama service if start_service and result["success"]: if not sys_check["ollama_installed"]: result["errors"].append("Cannot start service: Ollama not installed") result["success"] = False else: try: # Check if already running status = await _check_ollama_status(force_refresh=True) if status.get("running"): result["actions_skipped"].append("Ollama service already running") else: # Start via brew services start_proc = subprocess.run( ["brew", "services", "start", "ollama"], capture_output=True, text=True, timeout=30, ) if start_proc.returncode == 0: result["actions_taken"].append("Started Ollama service via Homebrew") # Wait a moment for service to start await asyncio.sleep(2) else: # Fallback: try running ollama serve in background result["actions_skipped"].append("brew services failed, try: ollama serve &") except Exception as e: result["errors"].append(f"Failed to start service: {e}") # Pull model if pull_model and result["success"]: # Check RAM before pulling large model if model == "gemma3:12b" and not sys_check["ram_sufficient"]: result["errors"].append( f"Insufficient RAM ({sys_check['ram_gb']}GB) for {model}. " f"Need {MIN_RAM_GB}GB+. Consider: gemma3:4b or gemma3:1b" ) result["success"] = False elif not sys_check["ollama_installed"]: result["errors"].append("Cannot pull model: Ollama not installed") result["success"] = False else: # Check if model already exists status = await _check_ollama_status(force_refresh=True) model_base = model.split(":")[0] already_pulled = any(m.startswith(model_base) for m in status.get("models", [])) if already_pulled: result["actions_skipped"].append(f"Model {model} already available") else: try: result["actions_taken"].append(f"Pulling model {model} (this may take several minutes)...") pull_proc = subprocess.run( ["ollama", "pull", model], capture_output=True, text=True, timeout=1800, # 30 minute timeout for model download ) if pull_proc.returncode == 0: result["actions_taken"].append(f"Successfully pulled {model}") else: result["errors"].append(f"Failed to pull {model}: {pull_proc.stderr}") result["success"] = False except subprocess.TimeoutExpired: result["errors"].append("Model pull timed out (30 min limit)") result["success"] = False except Exception as e: result["errors"].append(f"Pull error: {e}") result["success"] = False # Final status check if result["success"]: final_status = await _check_ollama_status(force_refresh=True) result["ollama_status"] = final_status return result - src/rlm_mcp_server.py:330-451 (helper)The _check_system_requirements helper used by rlm_setup_ollama to verify macOS, Apple Silicon, RAM, Homebrew, and Ollama availability before proceeding with setup.
def _check_system_requirements() -> dict: """Check if the system meets requirements for running Ollama with gemma3:12b.""" import platform result = { "platform": platform.system(), "machine": platform.machine(), "is_macos": False, "is_apple_silicon": False, "ram_gb": 0, "ram_sufficient": False, "homebrew_installed": False, "ollama_installed": False, "meets_requirements": False, "issues": [], "recommendations": [], } # Check macOS if platform.system() == "Darwin": result["is_macos"] = True else: result["issues"].append(f"Not macOS (detected: {platform.system()})") result["recommendations"].append("Ollama auto-setup is only supported on macOS") # Check Apple Silicon (M1, M2, M3, M4) machine = platform.machine() if machine == "arm64": result["is_apple_silicon"] = True # Try to get specific chip info try: chip_info = subprocess.run( ["sysctl", "-n", "machdep.cpu.brand_string"], capture_output=True, text=True, timeout=5, ) if chip_info.returncode == 0: result["chip"] = chip_info.stdout.strip() except Exception: result["chip"] = "Apple Silicon (arm64)" else: result["issues"].append(f"Not Apple Silicon (detected: {machine})") result["recommendations"].append("Apple Silicon (M1/M2/M3/M4) recommended for optimal Ollama performance") # Check RAM try: if platform.system() == "Darwin": mem_info = subprocess.run( ["sysctl", "-n", "hw.memsize"], capture_output=True, text=True, timeout=5, ) if mem_info.returncode == 0: ram_bytes = int(mem_info.stdout.strip()) ram_gb = ram_bytes / (1024**3) result["ram_gb"] = round(ram_gb, 1) result["ram_sufficient"] = ram_gb >= MIN_RAM_GB if not result["ram_sufficient"]: result["issues"].append( f"Insufficient RAM: {result['ram_gb']}GB (need {MIN_RAM_GB}GB+ for gemma3:12b)" ) result["recommendations"].append( f"gemma3:12b requires ~{GEMMA3_12B_RAM_GB}GB RAM. " f"With {result['ram_gb']}GB total, consider using a smaller model." ) except Exception as e: result["issues"].append(f"Could not determine RAM: {e}") # Check Homebrew try: brew_check = subprocess.run( ["which", "brew"], capture_output=True, text=True, timeout=5, ) result["homebrew_installed"] = brew_check.returncode == 0 if result["homebrew_installed"]: result["homebrew_path"] = brew_check.stdout.strip() else: result["issues"].append("Homebrew not installed") result["recommendations"].append( 'Install Homebrew first: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' ) except Exception: result["issues"].append("Could not check for Homebrew") # Check if Ollama is already installed try: ollama_check = subprocess.run( ["which", "ollama"], capture_output=True, text=True, timeout=5, ) result["ollama_installed"] = ollama_check.returncode == 0 if result["ollama_installed"]: result["ollama_path"] = ollama_check.stdout.strip() # Get version try: version_check = subprocess.run( ["ollama", "--version"], capture_output=True, text=True, timeout=5, ) if version_check.returncode == 0: result["ollama_version"] = version_check.stdout.strip() except Exception: pass except Exception: pass # Determine if all requirements are met result["meets_requirements"] = ( result["is_macos"] and result["is_apple_silicon"] and result["ram_sufficient"] and result["homebrew_installed"] ) return result - src/rlm_mcp_server.py:1232-1276 (registration)The tool is registered via the @mcp.tool() decorator on line 1209/1232, which is the FastMCP decorator that registers the function as an MCP tool named 'rlm_setup_ollama'.
@mcp.tool() async def rlm_setup_ollama( install: bool = False, start_service: bool = False, pull_model: bool = False, model: str = "gemma3:12b", ) -> dict: """Install Ollama via Homebrew (macOS). Requires Homebrew pre-installed. Uses 'brew install' and 'brew services'. PROS: Auto-updates, pre-built binaries, managed service. CONS: Requires Homebrew, may prompt for sudo on first Homebrew install. Args: install: Install Ollama via Homebrew (requires Homebrew) start_service: Start Ollama as a background service via brew services pull_model: Pull the default model (gemma3:12b) model: Model to pull (default: gemma3:12b). Use gemma3:4b or gemma3:1b for lower RAM systems. """ # If no actions specified, just do a system check if not any([install, start_service, pull_model]): sys_check = _check_system_requirements() return { "message": "No actions specified. Use install=true, start_service=true, or pull_model=true.", "system_check": sys_check, "example": "rlm_setup_ollama(install=true, start_service=true, pull_model=true)", } result = await _setup_ollama( install=install, start_service=start_service, pull_model=pull_model, model=model, ) # Add summary if result["success"]: result["summary"] = ( f"Setup complete! Actions: {', '.join(result['actions_taken']) or 'none'}. " f"Skipped: {', '.join(result['actions_skipped']) or 'none'}." ) else: result["summary"] = f"Setup failed: {'; '.join(result['errors'])}" return result - src/rlm_mcp_server.py:1233-1238 (schema)Input schema/parameters for the tool: install (bool), start_service (bool), pull_model (bool), and model (str, default gemma3:12b). Defined as function parameters with type hints.
async def rlm_setup_ollama( install: bool = False, start_service: bool = False, pull_model: bool = False, model: str = "gemma3:12b", ) -> dict: