Skip to main content
Glama

LM Studio Control — MCP server

Let Claude (or any MCP app) run LM Studio for you: start the server, load and unload models, tune load settings for your GPU, benchmark, chat, embed, download models and switch runtimes.

The settings optimizer stands out. It doesn't use rules of thumb. It asks LM Studio's own memory estimator about each candidate setup and keeps the fastest one that fits your VRAM.

Unofficial. Not affiliated with LM Studio or Element Labs. Uses the official @lmstudio/sdk.

Real example

27B model (4.4 GB file) on a laptop RTX 4050 with 6 GB VRAM:

Setup

Context

KV cache

Speed

LM Studio defaults

262k

f16

6.1 tok/s

optimize_settings goal balanced

32k

q8_0

7.5 tok/s

optimize_settings goal max_speed

8k

f16

9.9 tok/s

One prompt: "Load bonsai-27b with the best settings for my GPU and benchmark it."

Related MCP server: llmstudio-mcp

Install

Requirements: LM Studio 0.4 or newer, running on the same computer. Node.js 18+ is only needed for the manual setups.

Claude Desktop (one click)

  1. Download lmstudio-mcp.mcpb from the latest release.

  2. Double-click it (or drag it onto Claude Desktop) and press Install.

Claude Code

git clone https://github.com/ZenZeiTen/lmstudio-mcp
claude mcp add lmstudio --scope user -- node /path/to/lmstudio-mcp/bundle/lmstudio-mcp.mjs

Any other MCP app (Cursor, Cline, Windsurf…)

Clone the repo and add this to the app's MCP config:

{
  "mcpServers": {
    "lmstudio": {
      "command": "node",
      "args": ["/path/to/lmstudio-mcp/bundle/lmstudio-mcp.mjs"]
    }
  }
}

bundle/lmstudio-mcp.mjs is a single self-contained file. No npm install needed.

Tools

Area

Tool

What it does

Status

lmstudio_status

App version, HTTP server up/down, loaded models

lmstudio_hardware

GPUs and VRAM, RAM, CPU, runtime engine compatibility

Server

lmstudio_server_start / _stop

OpenAI-compatible server: port, CORS, network interface

Models

lmstudio_list_models

Downloaded models: size, quantization, max context

lmstudio_list_loaded

Loaded models with live load settings and busy state

lmstudio_load_model

Load with any of 22 settings (below)

lmstudio_unload_model

Unload one or all

Tuning

lmstudio_estimate_memory

LM Studio's VRAM/RAM estimate, without loading

lmstudio_optimize_settings

Best context / GPU offload / KV cache for your hardware; apply=true loads it

lmstudio_benchmark

Real tokens per second and time to first token

Inference

lmstudio_chat

Sampling options, JSON-schema output, speculative decoding

lmstudio_embed

Embedding vectors

lmstudio_count_tokens

Token count with the model's own tokenizer

Downloads

lmstudio_search_models

Catalog search with LM Studio's "will it fit" estimate

lmstudio_download_model / _status

Background downloads with progress and cancel

Runtimes

lmstudio_runtime_engines

List engines (CUDA, Vulkan, CPU, MLX…) and pick one per format

Escape hatch

lmstudio_cli

Runs any lms command

Load settings: context_length, gpu_offload, main_gpu, split_strategy, disabled_gpus, cpu_expert_layers_ratio (MoE), offload_kv_cache_to_gpu, flash_attention, k_cache_quant, v_cache_quant, eval_batch_size, physical_batch_size, max_parallel_predictions, unified_kv_cache, keep_model_in_memory, try_mmap, num_experts, seed, rope_frequency_base, rope_frequency_scale, gpu_strict_vram_cap, speculative_draft_model.

LM Studio's REST API rejects several of these (KV-cache quantization, for example). The SDK used here accepts all of them.

How the optimizer decides

Each candidate goes to LM Studio's estimateResourcesUsage. It is accepted only if:

  • estimated VRAM ≤ VRAM × (1 − headroom, default 10 %)

  • the part left in RAM ≤ RAM × (1 − headroom, default 20 %)

  • LM Studio's load guardrails pass

The search order:

  1. Full GPU offload, KV cache in VRAM, Flash Attention on. Binary search for the largest context, in 256-token steps.

  2. Partial offload: the largest GPU share (5 % steps) that fits VRAM, then checked against RAM. Handles models too big for VRAM or RAM alone, such as a 70B on 24 GB VRAM + 32 GB RAM.

  3. CPU only, as a last resort.

Goal

Context target

KV cache tried

balanced (default)

32k

q8_0, then q4_0

max_context

model maximum

q8_0, then q4_0

max_speed

8k

f16, then q8_0

max_quality

16k

f16, then q8_0

single_user=true (default) sets parallel slots to 1, so one conversation gets the full context. A run takes 2–35 estimator calls.

Settings

Set these in Claude Desktop's extension settings, or as environment variables for manual setups. All are optional.

Variable

Default

Use

LMSTUDIO_HTTP_PORT

1234

Port checked and used by server start

LMSTUDIO_BASE_URL

auto

Control LM Studio on another machine, e.g. ws://192.168.1.20:1234

LMSTUDIO_API_TOKEN

–

Only if "Require authentication" is on in LM Studio

LMS_CLI_PATH

~/.lmstudio/bin/lms

Location of the lms CLI

LMSTUDIO_AUTO_WAKE

true

Run lms daemon up if LM Studio isn't reachable

Safety

  • Server stop, unload and lmstudio_cli are marked destructive, so MCP apps ask before running them.

  • Binding the server to 0.0.0.0 exposes LM Studio to your network. Turn on authentication in LM Studio first.

  • lmstudio_cli runs only the lms program, without a shell. Arguments are passed as a list, so shell injection isn't possible.

Build from source

npm install
npm run build       # TypeScript → dist/
npm test            # optimizer unit tests
npm run bundle      # single-file bundle → bundle/lmstudio-mcp.mjs
npm run pack:mcpb   # Claude Desktop extension → lmstudio-mcp.mcpb

License

MIT © 2026 Ricardo Sandy Aries

Available Tools

19 tools
lmstudio_benchmarkA
Read-only

Measure real speed of a loaded model: tokens per second, time to first token, prompt size. Runs fixed prompts at temperature 0. Use to compare settings.

Inputs: identifier (required), runs, prompt, max_tokens.

lmstudio_chatB

Send a chat to a local model and get the reply with speed stats. If the model is not loaded, LM Studio loads it with its saved defaults.

Inputs: stop, min_p, model, top_k, +10 more.

lmstudio_cliA
Destructive

Run any lms command for anything the other tools do not cover (e.g. runtime update, import, link, daemon). Pass arguments without the leading 'lms'. Avoid streaming commands like 'log stream'.

Inputs: args (required), timeout_seconds.

lmstudio_count_tokensA
Read-only

Count tokens in a text using a loaded model's own tokenizer, and compare with its context length.

Inputs: text (required), model.

lmstudio_download_modelA

Download a model from the catalog in the background. Picks the file LM Studio recommends for this machine unless you name a quantization. Check progress with lmstudio_download_status.

Inputs: query (required), quantization.

lmstudio_download_statusB

Progress of downloads started in this session. Can also cancel one.

Inputs: cancel, job_id.

lmstudio_embedB
Read-only

Turn text into embedding vectors with a local embedding model. Returns vectors, or only their dimensions if vectors are not needed.

Inputs: texts (required), model, include_vectors.

lmstudio_estimate_memoryA
Read-only

Ask LM Studio how much VRAM and RAM a model would use with given load settings, without loading it. Shows whether it passes LM Studio's safety guardrails.

Inputs: model (required), config.

lmstudio_hardwareA
Read-only

Hardware LM Studio sees: GPUs with VRAM, system RAM, CPU and instruction sets, plus the runtime engines and whether each is compatible. Use before tuning load settings.

Inputs: all_engines.

lmstudio_list_loadedA
Read-only

List models currently loaded in memory, with their live load settings (context, GPU offload, KV cache, etc.), idle timeout and whether they are busy.

Inputs: no named parameters.

lmstudio_list_modelsA
Read-only

List models downloaded on this machine, with size, quantization, architecture and maximum context.

Inputs: type, filter.

lmstudio_load_modelA

Load a downloaded model into memory with explicit settings. Omitted settings use LM Studio's saved defaults for that model. For automatic tuning use lmstudio_optimize_settings instead.

Inputs: model (required), config, identifier, ttl_seconds.

lmstudio_optimize_settingsA

Find the best load settings for a model on this hardware, using LM Studio's own memory estimator (no guessing). Searches context length, GPU offload and KV-cache precision so the model fits VRAM/RAM with headroom. Goals: balanced (32k context, full GPU if possible), max_context (largest context that fits), max_speed (everything on GPU, 8k context), max_quality (unquantized KV cache). Set apply=true to load it.

Inputs: model (required), goal, apply, identifier, +7 more.

lmstudio_runtime_enginesB

List installed inference engines (llama.cpp CUDA/Vulkan/CPU, MLX…) and which one is selected per model format, or select a different engine.

Inputs: name, action, version, model_format.

lmstudio_search_modelsA
Read-only

Search the LM Studio catalog / Hugging Face for models to download. Shows each file option with size and LM Studio's fit estimate for this machine (full GPU, partial GPU, CPU, or won't fit).

Inputs: query (required), limit, format.

lmstudio_server_startA
Idempotent

Start LM Studio's OpenAI-compatible HTTP server (what other apps and curl talk to). Wakes the LM Studio service first if needed.

Inputs: cors, port, network_interface.

lmstudio_server_stopA
DestructiveIdempotent

Stop LM Studio's HTTP server. Loaded models stay loaded; apps using the API will lose their connection.

Inputs: no named parameters.

lmstudio_statusB
Read-only

Overview of LM Studio: app version, whether the OpenAI-compatible HTTP server is running, and which models are loaded right now.

Inputs: http_port.

lmstudio_unload_modelA
DestructiveIdempotent

Unload a loaded model (frees its RAM/VRAM), or all loaded models.

Inputs: all, identifier.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 19 tools

    Disambiguation4/5

    Most tools target a clearly distinct operation (load vs unload vs estimate vs benchmark vs chat). The only fuzzy pairs are lmstudio_status vs lmstudio_list_loaded (both report what's loaded) and lmstudio_load_model vs lmstudio_optimize_settings, but the descriptions explicitly cross-reference and differentiate them.

    Naming Consistency4/5

    All tools share the lmstudio_ prefix and are mostly verb_noun (load_model, list_models, download_status). A few are bare nouns (status, hardware, benchmark, chat, cli) which slightly breaks the verb_noun pattern but stays readable and predictable.

    Tool Count4/5

    19 tools is on the heavy side but each covers a real facet of the domain: server control, hardware, model catalog/downloads, load/unload lifecycle, memory estimation, optimization, benchmarking, and inference. The lmstudio_cli escape hatch keeps the surface from bloating further.

    Completeness4/5

    Load/unload/list/download/search/benchmark/chat/embed plus server lifecycle and runtime engine selection cover the full model-management lifecycle. Minor gaps like deleting a downloaded model or configuring server settings (port, API key) are largely workable around via lmstudio_cli.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      MCP server that connects LLM agents to a local LM Studio instance, enabling model management, OpenAI-compatible chat completions, text completions, and embeddings through a set of tools.
      9
      1
      -
    • F
      license
      B
      quality
      C
      maintenance
      Enables MCP clients to administer a local LM Studio instance: loading, estimating, downloading, configuring and unloading models, running chat and embedding inference, diagnosing the server, engines and hardware, and managing MCP connectors with conflict-safe configuration. It also builds a local document index supporting citation-checked search and answers grounded in TXT, Markdown, PDF and DOCX files.
      28
      -