Skip to content

Repository files navigation

mac-ai

A Rust CLI that orchestrates MCP tool calls using Apple's on-device Foundation Models (macOS 26+). Connect any MCP server, and mac-ai will pick the right tool, call it, and summarize the result. No API keys, no cloud, everything runs locally.

User query
    -> Fetch tools from MCP servers
    -> Foundation Models picks the best tool + args
    -> Call the tool via MCP
    -> Foundation Models summarizes the result
    -> Return answer

When no MCP tools are available (or none match), it answers directly via Apple Intelligence.

Requirements

  • macOS 26+ with Apple Intelligence enabled
  • Apple Silicon (M1 or later)
  • Rust 1.75+ and Swift 6.0+ (for building)

Install

Homebrew

brew tap viveky259259/tap
brew install mac-ai

From source

git clone https://github.com/viveky259259/mac-ai.git
cd mac-ai

# Build the Swift Foundation Models bridge
cd swift && swift build -c release && cd ..

# Build and install the Rust binary
cargo install --path .

Quick start

  1. Create a config with an MCP server (e.g., weather):
mkdir -p ~/.config/mac-ai
cat > ~/.config/mac-ai/config.json << 'EOF'
{
  "mcp_servers": [
    {
      "name": "weather",
      "command": "python3",
      "args": ["/path/to/weather_server.py"]
    }
  ],
  "model": {}
}
EOF
  1. Run a query:
mac-ai --query "What's the weather in Tokyo?"
  1. Or use it without any MCP servers for general questions:
mac-ai --query "Explain the Rust ownership model"

Config

Config lives at ~/.config/mac-ai/config.json:

{
  "mcp_servers": [
    {
      "name": "server-name",
      "command": "command-to-run",
      "args": ["arg1", "arg2"],
      "env": {"KEY": "value"}
    }
  ],
  "model": {
    "foundation_bridge_path": null,
    "llama_model_path": null,
    "max_tokens": 2048
  }
}

Each MCP server is spawned as a subprocess. Communication uses JSON-RPC 2.0 over stdio.

Architecture

src/
  main.rs              CLI entry point (clap)
  lib.rs               Public API
  orchestrator.rs      Core: fetch tools -> select -> call -> summarize
  config.rs            JSON config parsing
  mcp/
    client.rs          MCP JSON-RPC client (stdio transport)
    types.rs           MCP protocol types
  model/
    mod.rs             ModelBackend trait
    foundation.rs      Apple Foundation Models (Swift subprocess bridge)
    llama.rs           llama-cpp-2 backend (feature-gated)
swift/
  Sources/main.swift   Foundation Models bridge binary

The Swift bridge is a separate binary that Rust spawns as a subprocess. It reads JSON requests from stdin and writes JSON responses to stdout. This is necessary because Foundation Models is a Swift-only framework.

CLI options

mac-ai --query "your question"        # Process a query
mac-ai --query "..." --verbose        # Enable debug logging
mac-ai --query "..." --config path    # Custom config path
mac-ai --query "..." --backend llama  # Use llama-cpp backend (requires --features llama)

Bundled MCP server

A weather MCP server is included in mcp-servers/weather_server.py. It uses the free Open-Meteo API (no API key needed) and provides:

  • get_weather -- current weather for any city
  • get_forecast -- 7-day forecast for any city

License

MIT

About

MCP orchestrator powered by Apple Foundation Models

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages