Skip to main content
Glama

LM Studio MCP Server

An MCP (Model Context Protocol) server that wraps the official LM Studio Python SDK to provide tools for interacting with LM Studio - a local AI model runner for macOS, Windows, and Linux.

Features

  • Health Check: Verify LM Studio is running and get an overview

  • Model Management: List, load, and unload models

  • Model Search: Search for models in LM Studio Hub

  • Chat: Send chat messages with customizable parameters

  • Completions: Generate text completions

  • Embeddings: Get embeddings for text

Related MCP server: mcp-file-system-lmstudio

Requirements

Installation

From PyPI

pip install lms-mcp

From Source

git clone https://github.com/sweeden-ttu/lms-mcp.git
cd lms-mcp
pip install -e .

Quick Start

  1. Make sure LM Studio is running on your machine

  2. Start the MCP server:

lms-mcp

Or run directly:

python -m src.server

Configuration

Environment Variables

Variable

Description

Default

LM_STUDIO_BASE_URL

Base URL for LM Studio API

http://localhost:1234

LM_API_TOKEN

API token for authentication

None

Available MCP Tools

health_check

Check if the LM Studio server is running and get an overview of models.

Returns: Server status, total models count, loaded models count, and available models count.

list_models

List all available models (both loaded and downloaded).

Returns: Formatted list showing loaded models and available (downloaded but not loaded) models.

search_models

Search for models in LM Studio Hub.

Parameters:

  • query (str): Search term

  • limit (int): Number of results (default: 10)

Returns: List of matching models with descriptions.

load_model

Load a model into memory.

Parameters:

  • model (str): Model identifier (e.g., 'mistralai/Mistral-7B-Instruct-v0.3.Q4_K_M')

  • context_length (int, optional): Context window size

  • gpu_offload (float, optional): GPU offload ratio (0.0 to 1.0)

Returns: Success message.

unload_model

Unload a model from memory.

Parameters:

  • model (str): Model identifier to unload

Returns: Success message.

chat

Send a chat message and get a response.

Parameters:

  • model (str): Model identifier

  • message (str): The user's message

  • system_prompt (str, optional): System prompt override

  • temperature (float, optional): Sampling temperature (default: 0.7)

  • max_tokens (int, optional): Max tokens to generate (default: -1 for unlimited)

  • context_length (int, optional): Context window override

Returns: Model response with optional stats (tokens/sec, TTFT, generation time).

chat_session

Continue a multi-turn chat session.

Parameters:

  • model (str): Model identifier

  • messages (list[dict]): List of message dicts with 'role' and 'content' keys

  • system_prompt (str, optional): System prompt override

  • temperature (float, optional): Sampling temperature

  • max_tokens (int, optional): Max tokens to generate

Returns: Model response.

complete

Generate a text completion.

Parameters:

  • model (str): Model identifier

  • prompt (str): The prompt text

  • temperature (float, optional): Sampling temperature

  • max_tokens (int, optional): Max tokens to generate

  • stop (str, optional): Stop sequence

Returns: Completed text.

get_embeddings

Get embeddings for text.

Parameters:

  • model (str): Embedding model identifier

  • text (str): Text to embed

Returns: Embedding dimension and first 5 values.

Usage with Claude Desktop

Add this to your Claude Desktop config (claude_desktop_config.json):

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

Or for development:

{
  "mcpServers": {
    "lms-mcp": {
      "command": "python",
      "args": ["-m", "src.server"],
      "cwd": "/path/to/lms-mcp"
    }
  }
}

Cursor, OpenCode, and Other Editors

See docs/integrations.md for detailed setup instructions for:

  • Cursor

  • OpenCode

  • VS Code

  • Windsurf

Development

Running Tests

pytest

Run with coverage:

pytest --cov=src --cov-report=term-missing

Linting and Formatting

ruff check . --fix
ruff format .

Type Checking

mypy src/

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • 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
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI clients to interact with models running locally in LM Studio, including listing loaded models, chatting with per-session history, and loading models into memory with user consent.
      46 npm
      MIT