Local models: Ollama, LM Studio, llama.cpp and vLLM
Mercury CLI connects to local model servers running on your computer: Ollama, LM Studio, vLLM and llama.cpp. By default, Mercury probes loopback ports 11434 (Ollama), 1234 (LM Studio), 8000 (vLLM) and 8080 (llama.cpp); MERCURY_LOCAL_PROBE_TARGETS controls discovery and MERCURY_LOCAL_PROBE_TARGETS=none disables it. Mercury speaks Ollama's native /api/chat transport and OpenAI-compatible /v1/chat/completions for LM Studio, vLLM and llama.cpp, discovering models live while their servers answer. Run /localsetup to connect a running server, set up Ollama, pull a GGUF from Hugging Face into a local Bank, or start a GGUF already in the Bank, with every step confirmed and nothing selected for you.
Walk through /localsetup
In /localsetup, use the arrow keys and Enter to choose; Escape keeps your current model. On macOS and Linux, step 1 also offers TensorFold (or run /tensorfold) for MLX, NVFP4 or EXL3 checkpoints on Apple silicon or an NVIDIA GPU.
Ollama or a running server
Choose Ollama / running server to connect a server already running or set up Ollama:
- Mercury discovers Ollama, LM Studio, vLLM or llama.cpp. If several local servers answer, an Ollama server with models is chosen first. An existing compatible server supplies models without installing anything.
- When Ollama is not running,
/localsetupcan find or install Ollama and start it. Each command asks first, and any command needing administrator access says so. - Choose an installed model or a listed Ollama pull. Sizes and memory fit appear before the pull, and progress updates in the dialog.
- Mercury sets the context window where the server allows it, selects the model and requests a short reply.
Ollama keeps its own model store and server settings, and a server started through the Ollama path stays running after the dialog closes.
Pull a GGUF from Hugging Face
Choose Hugging Face and enter a repository id such as author/model-GGUF, or open the file list directly:
/localsetup author/model-GGUF
- The list shows each complete GGUF quantisation (split GGUF files appear as one choice), its download size and the projected memory for its context window.
- Pick a quantisation. If the repository includes one
mmprojvision projector, it accompanies the model; if it has several, choose one from the next list. - Confirm the download.
/localsetupshows the combined size and Bank folder: it uses your configured folder or an existing model-bank folder, or creates~/mercury-model-bankafter you accept the pull. - Downloads pin the Hugging Face commit revision and selected files, resume after interruption via
huggingface_hub, and verify file sizes and SHA-256 hashes against the repository manifest before the model starts. - Review the
llama-servercommand and its memory requirement. Mercury uses its locally builtllama.cppengine when present, thenllama-serveronPATHor Homebrew (on macOS,brew install llama.cppsupplies it). Models carrying NextN/MTP tensors start with--spec-type draft-mtp. llama-serverlistens only on127.0.0.1:8080; Mercury never replaces an occupied port and checks free memory again just before loading.- Once the server answers with the selected model and window, press Enter to select
local/<GGUF filename without .gguf>and request a short reply.
The server stays running as the local-gguf project service for later Mercury sessions, and the Service tool can inspect its logs or stop it. Pressing Escape or hitting a failure before setup finishes stops only the server the dialog started; existing servers keep running and downloads stay in the Bank.
Start a GGUF already in the Bank
Choose Bank to list GGUF models registered by Bank downloads. Pick a model and accept the server command. Mercury hashes the files again before starting, with no download needed. /llmhost shares the same Bank.
Context window sizing
How Mercury sizes the context window depends on which server runs the model:
- GGUF models started by
/localsetup: Mercury reads the GGUF header's attention geometry and any vision projector weights, then startsllama-serverwith the largest of32k,64kor128kthat fits the memory usable for models, never above the model's trained maximum. - Ollama: if the model's Modelfile sets
num_ctx, Mercury uses it (capped at the model's trained maximum). Otherwise, when KV geometry and machine memory are available, Mercury picks the largest of32k,64kor128kthat fits memory (more only when you pin trained max or a number) and sendsnum_ctxon every request. - LM Studio: LM Studio's model list gives no KV-cache geometry, so the window is not fitted to memory. Mercury uses the model's
max_context_lengthcapped at128k; when LM Studio holds the model at another length, Mercury unloads its instances throughPOST /api/v1/models/unloadand loads it throughPOST /api/v1/models/load. - Running
vLLMandllama.cppservers: the context window is set when the server starts and is not toggled from Mercury. - Changing the window: for Ollama and LM Studio, press
ctrl+win the/modelpicker to cycle the window, or set the Local model window row in/config. - Servers connected through
/llmhost: each model row displays the server's reported context window, and settingmodels["compat/<name>/<model>"].contextWindowin user settings overrides the server's reported value.
What a local model is sent
On local models and rented TensorFold pods, Mercury uses a local prompt profile by default:
- Mercury sends a compact system prompt and schemas only for the core tools (
BashorPowerShell,Read,Edit,Write,Glob,Grep,ToolSearch, andStructuredOutputwhen requested), most shortened; other tools wait behindToolSearchunless pinned to load. SetMERCURY_LOCAL_PROMPT_PROFILE=0to turn this off. - When a local server reports that a model lacks native tool support (from Ollama
/api/showor LM Studiotrained_for_tool_use), Mercury puts tool definitions in the prompt and parses<tool_call>blocks. - On servers connected through
/llmhost: each conversation on a multi-slotllama.cppserver reuses itsid_slotwithcache_prompt: true;/effortsendschat_template_kwargs.reasoning_efforttollama.cppand top-levelreasoning_efforttovLLM,SGLangandOllama; and conversations onllama.cpp,vLLMandSGLangkeep assistantreasoning_contentacross tool turns and continuations.
Connect a remote or token-protected server with /llmhost
To connect a server on another machine, behind a reverse proxy, over an SSH tunnel, or behind an API token, run /llmhost in the foreground chat, open More options →, and choose A server that’s already running:
- The server address: enter the OpenAI-compatible API base URL (a local port, a direct HTTPS URL, or the local port of an SSH tunnel you already opened). Mercury appends
/v1to a bare host and port; include the full path behind a reverse proxy. Mercury contacts only the address you enter. - The server dialect: Mercury probes for SGLang, vLLM, llama.cpp or Ollama metadata. Confirm the detected dialect, or pick SGLang, vLLM, llama.cpp, Ollama, LM Studio, chat completions or Responses.
- The key: if the server requires authentication, paste the token or key into the masked field; leave it blank for keyless servers. Keys are stored in Mercury's credential store, never in a settings file.
- The model: if the server lists one model, Mercury picks it automatically; otherwise pick a model from the list showing each served context window.
- Name, register and check: choose a provider name (default
llmhost), confirm registration and run the reply check. The popup shows the reply, elapsed time, and output tokens and tokens/s when the server returns usage numbers.
Mercury saves the endpoint under compatProvider.<name> in user settings and lists the model in /model as compat/<name>/<model> (default compat/llmhost/<model>). Registering an existing server leaves your current session's model unchanged until you switch to it with /model. Reopen A server that’s already running and select a registered server to check a reply again, change the address and check it (without sending the old stored key, credential command or custom headers), or remove this provider and its stored key while leaving the server running.
To run Ollama or llama.cpp as a loopback login service (launchd on macOS, systemd --user on Linux, Scheduled Task on Windows) on your own computer or another machine over SSH, open /llmhost and choose My computers (or More options →, then One of my computers), or use mercury host.
Switch models with /model
Run /model to switch back and forth between local models, compat/<name>/<model> endpoints and other configured providers mid-conversation. The switch applies immediately between turns, or queues until an active turn finishes.
- Text and tool results carry over unchanged.
- When a switch would drop history details (such as earlier thinking blocks, or images for a model that does not take them) or exceed the target context window, Mercury first shows a Model switch preview; confirming a switch that exceeds the window compacts the conversation before the first request on the new model.
- If a server registered through
/llmhostcannot be reached,/modeloffers Retry this server → and Remove this endpoint →. - When a
mercury hostservice is stopped, its row stays in/modelmarked as stopped and directs you to/llmhostto start it.
Limits
- Discovery needs a running server: discovery lists a model only while its server answers. If you set a custom
MERCURY_LOCAL_PROBE_TARGETSlist, include the GGUF server to rediscover it after setup. - Runtime installation:
/localsetupinstalls and starts Ollama and starts an installedllama-server, but does not installllama-server, LM Studio or vLLM. Mercury connects only to an already running LM Studio or local vLLM server. - GGUF headers and memory: a GGUF file without enough header information to calculate memory cannot be started through
/localsetup. If other applications leave too little free memory, Mercury does not start the server; free memory and retry. Models with NextN/MTP tensors need allama.cppbuild that supports--spec-type draft-mtp. - Vision projectors and tool parsers: a
llama.cppserver started without--mmprojcannot take image inputs or run theComputertool until restarted with--mmproj. On custom endpoints where SGLang,llama.cppor Ollama reports tool calling is disabled (tools: false), Mercury stops before sending and asks you to enable the server's tool parser or pick a tool-capable model. - Tool schemas on
llama.cppthrough/llmhost: every shipped Mercury tool passes directly, but a custom or MCP tool carrying a bare$ref: "#"or external reference is refused before dispatch until its schema is updated. - Long prompts: on
llama.cppandSGLangservers connected through/llmhost, Mercury reads server metrics and checks liveness to allow time for long prompts instead of timing out after 30 seconds.