vram-mcp

vram-mcp

Enables AI agents to inspect and free NVIDIA GPU VRAM by managing Ollama models, helping make room for loading new models.

Category
Visit Server

README

vram-mcp

An MCP server that lets AI agents inspect and free NVIDIA GPU VRAM by managing Ollama models. Handy when you juggle several local models across projects on a single GPU and an agent needs to make room before loading the next one.

  • NVIDIA + Ollama only for v1.
  • Degrades gracefully when nvidia-smi is absent: VRAM readings become unknown, but model list / unload / warm still work.

Tools

Tool Behavior
vram_status() Per-GPU VRAM (total/used/free) + loaded Ollama models (with claims, busy signal, CPU-offload) + every other VRAM-holding process + best free MB.
list_loaded() The models currently resident in VRAM (name, VRAM MB, expiry, claims, busy).
unload(model, force=False) Evict one model from VRAM now (keep_alive=0). Refuses if claimed/busy unless force=True.
ensure_free(gb, force=False) Unload models largest-first until at least gb GB is free, skipping claimed/busy models unless force=True.
warm(model, keep_alive="5m") Load/pin a model into VRAM for a duration.
advise() Heuristic suggestions (e.g. OLLAMA_MAX_LOADED_MODELS=1, finite OLLAMA_KEEP_ALIVE).
claim(model, owner, purpose, ttl_seconds=3600) Declare you're using a model, so others see who/why before evicting it.
renew(claim_id, ttl_seconds=None) Extend a claim before it expires.
release(claim_id) Release a claim early.
list_claims(model=None) See active claims (all models, or one).

Requirements

  • Ollama running locally (or reachable via OLLAMA_BASE_URL).
  • NVIDIA GPU + drivers for VRAM numbers. nvidia-smi is optional — without it, VRAM is reported as unknown and model operations still function.
  • Python 3.10+.

Install

Run directly with uv (no install needed):

uvx vram-mcp

Or install from source for development:

git clone https://github.com/sushiHex/vram-mcp
cd vram-mcp
pip install -e .

Run

vram-mcp

The server speaks MCP over stdio, so it is normally launched by an MCP client rather than by hand.

MCP client config

Add this to your MCP client's mcpServers config (e.g. Claude Code / Claude Desktop):

{
  "mcpServers": {
    "vram": {
      "command": "uvx",
      "args": ["vram-mcp"]
    }
  }
}

Configuration

  • OLLAMA_BASE_URL — Ollama endpoint. Defaults to http://127.0.0.1:11434.

Multi-session coordination

Since every session runs its own vram-mcp process, coordination happens via:

  • Claims — a shared, file-based ledger (~/.cache/vram-mcp/claims.json) recording who's using a model and why. Call claim() when you start relying on a model; renew() periodically if still in use. An un-renewed claim simply expires — no cleanup needed if your session ends unexpectedly.
  • Busy detection — best-effort, via NVML's per-process GPU utilization (not point-in-time; reads a short recent window so brief gaps between tokens don't misread as idle). Requires no changes to how you call Ollama — it's entirely on vram-mcp's side.
  • Protection — unload()/ensure_free() refuse to evict a model that's claimed OR busy, by default. Pass force=True when you've already decided it's worth it.

Requires the nvidia-ml-py dependency (installed automatically). Falls back gracefully — claims/busy report as empty/null — on non-NVIDIA GPUs or if NVML is unavailable.

Development

pip install -e .
python -m pytest -q

The logic modules (gpu.py, ollama.py, core.py) are free of any mcp import and are fully unit-tested with mocks — no real GPU, Ollama daemon, or mcp package required to run the test suite.

Roadmap

  • Other backends: AMD (ROCm/rocm-smi), Intel (xpu-smi).
  • Other runtimes: vLLM, llama.cpp.

License

MIT © 2026 sushiHex

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured