Skip to main content
Glama

llmstudio-mcp

Polski

MCP server exposing a local LM Studio instance to LLM agents — list / load / unload models, run chat and text completions, generate embeddings, and reach any other LM Studio REST endpoint via a raw escape hatch.

Table of contents

Related MCP server: mcp-file-system-lmstudio

Tools

Tool

Parameters

Description

list_models

type: "all" | "llm" | "embedding" | "vlm" = "all"

Lists downloaded models with metadata (type, state, context length, quant)

get_model

model_key: str

Info about a single model

get_loaded_models

—

Models currently resident in memory

load_model

model_key, context_length?, flash_attention?, offload_kv_cache_to_gpu?, num_experts?, eval_batch_size?

Loads a model into memory

unload_model

instance_id: str

Frees a model from memory

chat

model, messages, temperature?, max_tokens?, top_p?, top_k?, stop?, stream?, tools?

OpenAI-compatible chat completion (/v1/chat/completions)

complete

model, prompt, temperature?, max_tokens?, top_p?, top_k?, stop?, stream?

OpenAI-compatible text completion (/v1/completions)

embed

model, input, normalize=false

OpenAI-compatible embeddings (/v1/embeddings)

raw_request

method, path, json_body?

Escape hatch for any LM Studio REST endpoint

Environment variables

Variable

Required

Default

Description

LMSTUDIO_MCP_BASE_URL

no

http://localhost:1234

LM Studio server URL

LMSTUDIO_MCP_API_KEY

no

empty

API token (only if you enabled token auth in LM Studio's Developer tab)

LMSTUDIO_MCP_TIMEOUT

no

60.0

HTTP timeout in seconds; raise for slow models or large generations

Prerequisites

LM Studio running with its API server enabled — either the desktop app with the Developer tab toggle on, or lms server start from the CLI. At least one model downloaded (lms get <model>).

Wiring it up

Only requirement: uv (https://docs.astral.sh/uv/). Nothing else to install.

Claude Code

claude mcp add llmstudio-mcp -- uvx --from git+https://github.com/dam2452/llmstudio-mcp.git llmstudio-mcp

If you enabled API token auth in LM Studio:

claude mcp add llmstudio-mcp -e LMSTUDIO_MCP_API_KEY=<token> -- uvx --from git+https://github.com/dam2452/llmstudio-mcp.git llmstudio-mcp

Claude Desktop / other MCP client

{
  "mcpServers": {
    "llmstudio-mcp": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/dam2452/llmstudio-mcp.git", "llmstudio-mcp"]
    }
  }
}

After pushing a new version: uv cache clean and restart the client.

Local run

uv run --directory . llmstudio-mcp

Tests (manual):

uv run --directory . --with pytest pytest test/

Available Tools

9 tools
chatA

Send a chat completion request to a model (OpenAI-compatible /v1/chat/completions).

The model is auto-loaded if not already in memory (JIT loading enabled by default in LM Studio). Set stream=True only when the MCP client supports streamed responses; most do not.

Examples: chat(model="qwen/qwen3-4b-2507", messages=[{"role":"user","content":"Hello"}]) chat(model="qwen/qwen3-4b-2507", messages=[{"role":"system","content":"Be terse."},{"role":"user","content":"Hi"}], temperature=0.2, max_tokens=64)

Inputs: model (required), messages (required), stop, tools, +5 more. Returns: object

completeA

Send a raw text-completion request to a model (OpenAI-compatible /v1/completions).

Prefer chat() for instruction-tuned conversational models. complete() is useful for base / completion models or for prompt-template experimentation.

Examples: complete(model="qwen/qwen3-4b-2507", prompt="The meaning of life is", max_tokens=20)

Inputs: model (required), prompt (required), stop, top_k, +4 more. Returns: object

embedA

Generate an embedding vector for the given text (OpenAI-compatible /v1/embeddings).

input can be a single string or a list of strings for batch embedding.

Examples: embed(model="text-embedding-nomic-embed-text-v1.5", input="hello world") embed(model="text-embedding-nomic-embed-text-v1.5", input=["hello", "world"], normalize=True)

Inputs: input (required), model (required), normalize. Returns: object

get_loaded_modelsA

List models currently loaded into memory (ready for inference).

Examples: get_loaded_models()

Inputs: no named parameters. Returns: object

get_modelB

Get detailed info about a single model.

Examples: get_model(model_key="qwen/qwen3-4b-2507") get_model(model_key="text-embedding-nomic-embed-text-v1.5")

Inputs: model_key (required). Returns: object

list_modelsA

List models available in the local LM Studio instance.

Queries /api/v0/models which returns every downloaded model with rich metadata: type (llm / vlm / embeddings), publisher, arch, quantization, state (loaded / not-loaded), and max_context_length.

Examples: list_models() list_models(type="llm") list_models(type="embeddings")

Inputs: type. Returns: object

load_modelA

Load a model into memory so it is ready for inference.

If context_length is omitted, the model's configured default is used. Only LLMs loaded via LM Studio's llama.cpp engine honor flash_attention, num_experts, eval_batch_size and offload_kv_cache_to_gpu.

Examples: load_model(model_key="qwen/qwen3-4b-2507") load_model(model_key="openai/gpt-oss-20b", context_length=16384, flash_attention=True)

Inputs: model_key (required), num_experts, context_length, eval_batch_size, +2 more. Returns: object

raw_requestA

Escape hatch: send an arbitrary request to the LM Studio REST API.

Use this when you need an endpoint not covered by a dedicated tool (e.g. /api/v1/chat stateful chats, /api/v1/models/download, /v1/responses, the Anthropic-compatible /v1/messages, etc.). path must start with a slash and is appended to the configured base URL.

Examples: raw_request(method="GET", path="/api/v0/models") raw_request(method="POST", path="/api/v1/chat", json_body={"model":"qwen/qwen3-4b-2507","messages":[{"role":"user","content":"hi"}]})

Inputs: path (required), method (required), json_body. Returns: object

unload_modelA

Unload a model instance from memory, freeing RAM / VRAM.

The instance_id is the identifier returned by load_model (usually equal to the model key, but may differ when multiple instances of the same model are loaded). Use get_loaded_models to discover currently loaded instance_ids.

Examples: unload_model(instance_id="qwen/qwen3-4b-2507")

Inputs: instance_id (required). Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 9 tools

    Disambiguation5/5

    Each tool has a distinct purpose: chat, complete, and embed for inference; list_models, get_model, load_model, unload_model for model management; raw_request as an escape hatch. No functional overlap.

    Naming Consistency5/5

    Consistent verb_noun pattern (e.g., get_loaded_models, list_models, load_model) with simple action verbs for inference (chat, complete, embed). All lowercase with underscores; clear and predictable.

    Tool Count5/5

    9 tools cover the core server management lifecycle: model discovery, loading/unloading, inference, and a raw_request for extensibility. Neither too few nor too many for the domain.

    Completeness4/5

    Covers all essential operations: model listing, loading, inference (chat/complete/embed), and unloading. Missing model download/delete is a minor gap, but raw_request can handle edge cases.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      B
      maintenance
      Enables MCP-compatible clients to use locally running LM Studio models as tools for sending prompts, listing available models, and checking server status. It automatically handles WSL2 networking and follows the currently loaded model without reconfiguration.
      3
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables MCP-compatible applications to manage and use local or cloud-hosted models, including listing, pulling, generating, chatting, embeddings, and web search/fetch through a unified tool interface.
      923 npm
      AGPL 3.0