Skip to main content
Glama
README.md
# ollama-ssh-mcp

MCP server that gives an MCP client (Claude Code) access to an Ollama instance on another machine, where Ollama listens only on `127.0.0.1`. It reaches it through an SSH local forward that the server manages itself.

- The tunnel opens on the first tool call, on a random free local port, so it never collides with a hand-made `-L 11434` forward.
- If the `ssh` process dies (laptop suspend, Wi-Fi change), the next call reopens it. A connection error mid-request triggers one restart and retry.
- The tunnel closes when the MCP server exits. Nothing runs while the server is unused, and the model unloads on Ollama's normal idle timer.

## Tools

| Tool | Purpose |
| --- | --- |
| `chat` | Prompt the model. Optional `system`, `format` (`"json"` or a JSON schema), `temperature`, `think`, `model`, and `conversation` (a named multi-turn history kept in memory for the server's lifetime). |
| `models` | List installed models and which are loaded on the GPU. |
| `forget_conversation` | Drop one named conversation, or all of them. |

## Config

| Env | Default | |
| --- | --- | --- |
| `OLLAMA_SSH_TARGET` | (required) | e.g. `user@gpu-box.local`; needs key-based, non-interactive SSH |
| `OLLAMA_REMOTE_PORT` | `11434` | Ollama port on the remote host |
| `OLLAMA_MODEL` | `gemma4:e4b` | default model |
| `OLLAMA_NUM_CTX` | `16384` | context window sent on every request; match other clients of the same model, since a different value forces a reload |

## Register with Claude Code

```
claude mcp add -s user ollama -e OLLAMA_SSH_TARGET=user@gpu-box.local \
  -- ~/.local/bin/uv run --project ~/Projects/ollama-ssh-mcp ollama-ssh-mcp
```

Pinned to `mcp<2`. The 2.x SDK renamed FastMCP to MCPServer.

TDQS

B3.4/5.0

Scored across 3 tools

Disambiguation5/5

Each tool maps to a clearly distinct action: chat runs inference, models lists installed/loaded models, and forget_conversation clears history. There is no plausible way to confuse one for another, even though chat and forget_conversation both touch conversation state (one appends, one deletes).

Naming Consistency3/5

Two tools use verb-style names (chat, forget_conversation) while models is a bare noun, and chat is a single generic verb rather than verb_noun. The names remain readable and reasonably predictable, but the convention is mixed rather than uniform.

Tool Count4/5

Three tools is a slim but well-scoped surface for a thin Ollama-over-SSH wrapper, and each tool earns its place: generate, enumerate models, reset context. It sits just below the ideal range but does not feel artificially padded or truncated.

Completeness3/5

Core chat workflow is covered, but there are notable gaps: no model management (pull/delete), no way to inspect or list existing conversations (only drop them), and no stop/stream control. Agents can work around these via the chat tool alone, but the surface is not full lifecycle coverage for the domain.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues