Skip to main content
Glama
egoughnour

Massive Context MCP

by egoughnour

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

TableJSON Schema
NameRequiredDescriptionDefault
installNo
start_serviceNo
pull_modelNo
modelNogemma3:12b

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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
  • 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
  • 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
  • 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
  • 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:
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It discloses installation method, dependency on Homebrew, potential sudo prompt, and explains each boolean flag. It also suggests model alternatives for lower RAM. However, it does not mention error handling or idempotency, so not a 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, front-loads the purpose, and uses bullet points for args. Every sentence adds value (purpose, prerequisite, pros/cons, parameter details). No unnecessary text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the existence of an output schema, return value details are not needed. The description covers prerequisites, pros/cons, and all parameters. Missing some behavioral details like idempotency, but overall complete for a setup tool with 4 params.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must explain all parameters. It clearly explains each boolean flag's action (install, start service, pull model) and the model parameter's default and alternatives, fully compensating for the lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool installs Ollama via Homebrew on macOS, and lists specific sub-actions. However, it does not explicitly differentiate from sibling tool rlm_setup_ollama_direct, so it falls short of a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions a prerequisite (Homebrew pre-installed) and lists pros/cons, but does not explicitly state when to use this tool versus alternatives like rlm_setup_ollama_direct. Usage context is present but no exclusion guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/egoughnour/massive-context-mcp'

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