LM Studio MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LM Studio MCP Server list downloaded models"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
LM Studio MCP Server
An MCP (Model Context Protocol) server that provides AI assistants with control over LM Studio models. This server enables remote model management including listing, loading, and unloading models through the LM Studio API.
Features
Health Check: Verify connectivity to LM Studio
List Downloaded Models: View all LLM models available in your LM Studio library
List Loaded Models: See which models are currently loaded in memory
Load Models: Load models into memory with configurable parameters
Unload Models: Remove specific model instances from memory
Get Model Info: Retrieve detailed information about loaded models
Related MCP server: ai-model-selector-mcp
Prerequisites
Node.js 18.0.0 or higher
LM Studio running with the local server enabled
Installation
# Clone the repository
git clone <repository-url>
cd lm-studio-mcp-server
# Install dependencies
npm installConfiguration
The server connects to LM Studio using environment variables:
Variable | Default | Description |
| (derived) | Full WebSocket URL for LM Studio |
|
| LM Studio host (used if BASE_URL not set) |
|
| LM Studio port (used if BASE_URL not set) |
Usage
Running Modes
Development (uses tsx for TypeScript execution):
npm start
# or with file watching
npm run devProduction (uses compiled JavaScript):
npm run build
npm run start:prodDocker:
# Pull the published image
docker pull portertech/lm-studio-mcp-server:latest
# Run (connects to LM Studio on host machine)
docker run -i --rm portertech/lm-studio-mcp-server:latest
# Run with custom LM Studio host
docker run -i --rm \
-e LMSTUDIO_HOST=192.168.1.100 \
-e LMSTUDIO_PORT=1234 \
portertech/lm-studio-mcp-server:latestMCP Client Configuration
Claude
Add to your claude_desktop_config.json:
Using npx (recommended for installed packages):
{
"mcpServers": {
"lmstudio": {
"command": "npx",
"args": ["@portertech/lm-studio-mcp-server"],
"env": {
"LMSTUDIO_HOST": "127.0.0.1",
"LMSTUDIO_PORT": "1234"
}
}
}
}Using local development:
{
"mcpServers": {
"lmstudio": {
"command": "npx",
"args": ["tsx", "/path/to/lm-studio-mcp-server/src/index.ts"],
"env": {
"LMSTUDIO_HOST": "127.0.0.1",
"LMSTUDIO_PORT": "1234"
}
}
}
}Using Docker:
{
"mcpServers": {
"lmstudio": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"LMSTUDIO_HOST=127.0.0.1",
"-e",
"LMSTUDIO_PORT=1234",
"portertech/lm-studio-mcp-server:latest"
]
}
}
}Note: For Docker on macOS/Windows connecting to LM Studio on the host machine, use
LMSTUDIO_HOST=host.docker.internal.
Available Tools
All tools return a consistent response envelope:
{
success: boolean;
message: string;
data?: T; // Present on success
error?: { // Present on failure
code: string;
message: string;
};
}Error Codes
Code | Description |
| Requested model does not exist |
| Model is not currently loaded |
| Cannot connect to LM Studio |
| Invalid parameters provided |
| Failed to load model |
| Failed to unload model |
| Unexpected error |
health_check
Check connectivity to LM Studio server.
Parameters: None
Returns: Connection status and base URL
list_models
List all downloaded LLM models available in LM Studio.
Parameters: None
Returns: Array of model info objects with:
modelKey: Model identifier for loadingpath: Relative path to the modeldisplayName: Human-readable model namesizeBytes: Size in bytesarchitecture: Model architecture (if available)quantization: Quantization type (if available)
list_loaded_models
List all currently loaded models in memory.
Parameters: None
Returns: Array of loaded model info with:
identifier: Instance identifiermodelKey: Model keypath: Model pathdisplayName: Human-readable namesizeBytes: Size in bytesvision: Whether model supports visiontrainedForToolUse: Whether model was trained for tool use
load_model
Load a model into memory.
Parameters:
model(required): Model key to load (e.g.,llama-3.2-3b-instruct)identifier(optional): Custom identifier for the loaded instancecontextLength(optional): Context window size in tokens (minimum: 1)evalBatchSize(optional): Batch size for token processing (minimum: 1)
Returns: Success status with loaded model details (identifier, modelKey, path)
unload_model
Unload a model from memory.
Parameters:
identifier(required): Identifier of the loaded model to unload
Returns: Success status
get_model_info
Get detailed information about a loaded model.
Parameters:
identifier(required): Identifier of the loaded model
Returns: Model details including identifier, modelKey, path, displayName, sizeBytes, contextLength
Development
# Build the project
npm run build
# Run in development mode with auto-reload
npm run dev
# Type check without emitting
npm run typecheck
# Run tests
npm test
# Lint
npm run lint
# Format
npm run format:check
npm run formatRelease Process
The project includes a make release command for automated releases:
# Create a new release (runs CI, sets version, commits, tags, publishes to npm and Docker Hub)
make release VERSION=<version>
# Example:
make release VERSION=1.0.5This runs the full release pipeline:
CI checks (lint, typecheck, test)
Sets version in
package.jsonCommits the version bump
Creates an annotated git tag (
v<version>)Publishes to npm
Builds and pushes Docker images to Docker Hub
Project Structure
src/
├── index.ts # MCP server entry point
├── client.ts # LM Studio client wrapper
├── types.ts # Shared types and result helpers
└── tools/
├── index.ts # Tool exports
├── health-check.ts # Health check tool
├── list-models.ts # List downloaded models
├── list-loaded-models.ts
├── load-model.ts
├── unload-model.ts
└── get-model-info.tsArchitecture
Consistent Results: All tools return the same
ToolResult<T>envelopeSafe Wrappers: Tool handlers are wrapped to catch exceptions and return error payloads
Lazy Config: Environment variables are read at runtime, not module load
Singleton Client: Single LM Studio client instance is reused
License
ISC
Available Tools
6 toolsget_model_infoA
Get detailed information about a specific loaded model in LM Studio
Inputs: identifier (required).
health_checkA
Check connectivity to LM Studio server
Inputs: no named parameters.
list_loaded_modelsA
List all currently loaded LLM models in LM Studio
Inputs: no named parameters.
list_modelsA
List all downloaded LLM models available in LM Studio
Inputs: no named parameters.
load_modelB
Load a model into memory in LM Studio
Inputs: model (required), identifier, contextLength, evalBatchSize.
unload_modelB
Unload a model from memory in LM Studio
Inputs: identifier (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose: health_check for connectivity, list_models vs list_loaded_models for different sets, get_model_info for details on a loaded model, and load/unload for lifecycle management. No ambiguity.
Most tools follow a verb_noun pattern (get_model_info, list_choices, load_model, unload_model). health_check deviates as a noun phrase but is conventional and understandable. Overall consistent.
With 6 tools covering connectivity, listing, loading/unloading, and info query, the count is well-scoped for the domain of model management without bloat or deficiency.
The set covers core model lifecycle (load, unload, list, info) and connectivity. Minor gaps like model deletion or parameter configuration are not critical for common agent tasks.
Maintenance
Related MCP Connectors
Remote MCP for RunComfy: ComfyUI deployments, hosted models, LoRA training. 31 tools.
List models, read model details and send chat messages in Cerebras.
Generate AI images and videos from your agent: list models, start jobs, and fetch the results.
Account, billing, team, API key and model discovery tools for agents that use ModelsLab.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with locally running Ollama models through chat, generation, and model management operations. Supports listing, downloading, and deleting models while maintaining conversation history for interactive sessions.MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with structured access to metadata for 76+ AI models across Ollama, Claude, and OpenRouter, enabling capability queries, compatibility checks, model comparisons, and task-based recommendations.12 npmMIT
- AlicenseAqualityDmaintenanceEnables listing, loading, unloading, and configuring models in LM Studio via MCP tools, with support for TTL and draft model settings.57MIT
- AlicenseCqualityDmaintenanceEnables MCP clients to interact with local LLMs via LM Studio, supporting dynamic chat, vision, RAG, file interaction, and model orchestration.28MIT