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.
- macOS 26+ with Apple Intelligence enabled
- Apple Silicon (M1 or later)
- Rust 1.75+ and Swift 6.0+ (for building)
brew tap viveky259259/tap
brew install mac-aigit 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 .- 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- Run a query:
mac-ai --query "What's the weather in Tokyo?"- Or use it without any MCP servers for general questions:
mac-ai --query "Explain the Rust ownership model"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.
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.
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)
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 cityget_forecast-- 7-day forecast for any city
MIT