lmstudio-mcp
The lmstudio-mcp server is a production-oriented, local-only MCP server for diagnosing, testing, benchmarking, and controlling LM Studio instances, without cloud fallback or telemetry. It provides a consistent set of 18 tools:
Read-Only / Diagnostic Tools
lmstudio_status: Check API reachability, version, model counts, auth status
lmstudio_diagnose: Run a full diagnostic suite with findings and suggestions
lmstudio_validate_mcp: Validate LM Studio's MCP config (redacted, no changes)
lmstudio_security_audit: Audit binding, LAN exposure, CORS, auth, logging, remote destinations
lmstudio_capture_logs: Capture redacted log stream from
lmsCLI (up to 120s)
Model Discovery Tools
lmstudio_list_models: List downloaded models with metadata
lmstudio_list_loaded_models: List currently loaded model instances
lmstudio_inspect_model: Get detailed static and runtime info for a model
Inference & Testing Tools
lmstudio_test_inference: Run bounded inference against various endpoints
lmstudio_test_endpoints: Classify native, Chat Completions, and Responses endpoint families
lmstudio_test_tool_calling: Verify non-streaming tool-call round trip
lmstudio_test_streaming_tool_calling: Verify streaming tool-call round trip
lmstudio_test_structured_output: Validate JSON Schema enforcement
lmstudio_benchmark: Run small streaming benchmarks (up to 5 requests)
Capability Tracking Tools
lmstudio_capabilities: Summarize DECLARED, DETECTED, and VERIFIED capabilities
lmstudio_export_capability_snapshot: Export secret-free capability snapshot with SHA-256 digest
Mutating Tools (disabled by default; require LMSTUDIO_MCP_ALLOW_MUTATIONS=true)
lmstudio_load_model: Load a downloaded model into memory (never downloads)
lmstudio_unload_model: Unload a specific loaded model by identifier (never unloads all)
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., "@lmstudio-mcp what models are currently loaded?"
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.
lmstudio-mcp
A production-oriented, local-only Model Context Protocol (MCP) stdio server for diagnosing, testing, benchmarking, and deliberately controlling LM Studio.
It talks only to a loopback LM Studio server, has no cloud fallback or telemetry, never downloads a model, and disables all mutations by default.
Why this exists
LM Studio exposes several API families and model metadata does not prove runtime behavior. This server gives MCP clients one consistent interface and keeps three kinds of evidence separate:
DECLARED — model metadata claims.
DETECTED — passive endpoint or runtime observations.
VERIFIED — a completed live test, such as a real tool-call round trip.
Related MCP server: tool-mcp-bridge
Architecture
flowchart LR
Client["MCP client<br/>Codex or another SDK client"] -->|"stdio"| Server["lmstudio-mcp"]
Server -->|"HTTP on loopback only"| Native["LM Studio native API"]
Server -->|"HTTP on loopback only"| OpenAI["OpenAI-compatible APIs"]
Server -->|"spawn with argument arrays"| CLI["lms CLI"]
Server --> Evidence["In-process capability evidence"]
Evidence --> Snapshot["Canonical JSON + SHA-256 snapshot"]Requirements
Node.js 20, 22, or 24
LM Studio with its local server enabled
Optional:
lmsonPATH, orLMSTUDIO_LMS_PATHset to the executable
The implementation is cross-platform TypeScript. macOS is live-verified; Linux and Windows are exercised by the CI matrix for build, unit, and MCP protocol behavior. Live LM Studio integration on those platforms remains environment-dependent and is not claimed by CI.
Install and build
git clone https://github.com/Ka1y0/Tool_MCP_LMStudio.git
cd Tool_MCP_LMStudio
corepack enable
pnpm install --frozen-lockfile
pnpm build
pnpm testnpm install, npm run build, and npm test are also supported. Live integration tests skip when LM Studio is unavailable and never load, unload, or download models.
Configuration
Variable | Default | Meaning |
|
| Must use |
| empty | Optional local bearer token; never persisted by this project. |
|
| Enables the two explicit load/unload tools. |
| empty | Default model identifier for tests. |
|
| HTTP/CLI timeout, bounded to 250–300000 ms. |
|
| Log stream duration, bounded to 1–120 seconds. |
|
|
|
The server intentionally has no dotenv dependency. Pass variables from the MCP launcher; .env.example is only a reference.
Register with Codex
Build first, then use absolute paths appropriate to your machine:
codex mcp add lmstudio-mcp \
--env LMSTUDIO_BASE_URL=http://127.0.0.1:1234 \
--env LMSTUDIO_MCP_ALLOW_MUTATIONS=false \
--env LMSTUDIO_LMS_PATH=/absolute/path/to/lms \
-- node /absolute/path/to/lmstudio-mcp/dist/index.jsCheck registration with codex mcp get lmstudio-mcp and codex mcp list. A client session opened before registration may need to be restarted.
Tools
The server exposes 18 tools:
Tool | Class | Purpose |
| read-only | Health, versions, reachability, and model counts. |
| read-only | Downloaded model metadata. |
| read-only | Loaded runtime instances. |
| read-only | Static and runtime model information. |
| inference | One bounded native, Chat Completions, or Responses request. |
| inference | Classify the three API families. |
| inference | Deterministic non-streaming tool-call round trip. |
| inference | Streamed call reassembly, execution, continuation, progress, and cancellation. |
| inference | Schema enforcement versus JSON/prompt-only output. |
| read-only | DECLARED/DETECTED/VERIFIED summary. |
| read-only | Secret-free canonical snapshot and SHA-256. |
| read-only | Bind, CORS, auth, logging, and destination checks. |
| inference | Small bounded streaming benchmark. |
| read-only | Bounded, redacted log capture with child cleanup. |
| read-only | Findings, probable causes, and actions. |
| read-only | Read-only validation of LM Studio's MCP config. |
| mutating | Load an already-downloaded model; disabled by default. |
| mutating | Unload one explicit identifier; disabled by default. |
For LLMs and Agents
Machine-oriented documentation is intentionally separate from this human overview:
llms.txtis the concise routing and safety index.docs/LLM_USAGE.mdis the canonical agent operating manual.docs/mcp-tools.jsonis generated from the actual MCP registry and contains every current tool schema plus operational metadata.
Run pnpm docs:tools after tool changes and pnpm docs:check to detect drift.
All tools with output schemas return both human-readable content and machine-readable structuredContent.
Streaming verification
lmstudio_test_streaming_tool_calling uses one inert fixture, lookup_test_record(742). It reconstructs fragmented call IDs, function names, and JSON arguments; rejects missing, malformed, duplicate, multiple, or schema-invalid calls; executes no shell/filesystem/network action; returns {project, status, value} to the model; and validates labeled fixture values in the streamed continuation. Final-answer comparison ignores punctuation delimiters but never missing labels, altered letters, or altered digits.
The tool emits MCP progress notifications only when the caller supplies a progress token. MCP cancellation aborts the underlying LM Studio fetch and is classified as CANCELLED. Only Chat Completions streaming is currently claimed as verified; other streaming API families remain unverified.
Capability snapshots
lmstudio_export_capability_snapshot returns a versioned snapshot, its recursively key-sorted canonical JSON, and a lowercase SHA-256 digest. The hash covers the UTF-8 canonical snapshot only. Tokens, environment contents, home paths, model filesystem paths, and arbitrary raw API payloads are excluded. See the schema contract.
Mutation and privacy guarantees
Non-loopback URLs and credential-bearing URLs are rejected at startup.
Mutations require
LMSTUDIO_MCP_ALLOW_MUTATIONS=truein the server process.Loading never downloads; unloading requires one identifier and never uses
--all.CLI calls use
spawn(executable, args)without a shell.Errors and logs redact tokens, authorization values, API keys, passwords, and secrets.
No analytics, telemetry SDK, cloud inference, or remote destination is present.
Development
pnpm build
pnpm test:unit
pnpm test:mcp
pnpm test:integration # live tests skip if LM Studio is unavailable
pnpm checkTests cover configuration boundaries, redaction, mutation guards, protocol structured content, tool-call adversaries, streamed delta reconstruction, cancellation, snapshot canonicalization, and live endpoints. CI deliberately excludes environment-dependent live LM Studio assertions.
Troubleshooting
serverRunning: false: start LM Studio's local server and retain its loopback bind.MODEL_REQUIRED: passmodelor configureLMSTUDIO_DEFAULT_MODEL.AUTH_REQUIRED: pass the local token throughLMSTUDIO_API_TOKEN; do not put it in source or URLs.CANCELLED: the MCP caller cancelled a long operation; the underlying request was aborted.lmsunavailable: setLMSTUDIO_LMS_PATH; API-only functions can still work.A reasoning model may consume a small output budget before producing visible content; bounded tools report reasoning-only output separately.
Historical local verification reports are in docs/DIAGNOSTIC_REPORT.md and docs/V0.2_CAPABILITY_REPORT.md. They are evidence from one environment, not universal compatibility claims.
Contributing and security
See CONTRIBUTING.md, SECURITY.md, and CODE_OF_CONDUCT.md. The project is licensed under the MIT License.
Available Tools
18 toolslmstudio_benchmarkBenchmark local LM StudioB
Run at most five small streaming requests and report only measurements actually available.
Inputs: runs, model, prompt.
lmstudio_capabilitiesSummarize LM Studio capabilitiesD
Separate DECLARED metadata, passively DETECTED support, and live VERIFIED capability evidence recorded in this MCP process.
Inputs: model. Returns: model, success, declared, detected, +2 more
lmstudio_capture_logsCapture LM Studio logsC
Capture a bounded lms log stream, redact secrets, and always terminate the child process.
Inputs: seconds.
lmstudio_diagnoseDiagnose LM StudioB
Run a high-level, non-mutating diagnostic suite against local LM Studio.
Inputs: no named parameters. Returns: checks, health, failures, warnings, +3 more
lmstudio_export_capability_snapshotExport LM Studio capability snapshotB
Return a deterministic-schema, secret-free capability snapshot plus canonical JSON and its SHA-256 digest. This tool does not write files or rerun capability tests.
Inputs: model. Returns: sha256, success, snapshot, hashScope, +1 more
lmstudio_inspect_modelInspect an LM Studio modelA
Return all discoverable local metadata and distinguish static capability from runtime configuration.
Inputs: model (required). Returns: found, model, warnings, capability, +2 more
lmstudio_list_loaded_modelsList loaded LM Studio modelsA
List model instances currently loaded in memory. Read-only.
Inputs: no named parameters. Returns: error, models, source
lmstudio_list_modelsList downloaded LM Studio modelsA
List locally downloaded models and discoverable metadata. Read-only.
Inputs: no named parameters. Returns: models, source, warnings
lmstudio_load_modelLoad an LM Studio modelA
MUTATING and disabled by default. Validates a downloaded model and context before invoking lms load; never downloads.
Inputs: model (required), identifier, estimate_only, context_length.
lmstudio_security_auditAudit local LM Studio securityA
Read-only audit of loopback binding, LAN exposure, CORS, authentication, sensitive logging, and remote destinations.
Inputs: no named parameters. Returns: success, findings, readOnly, corsEnabled, +6 more
lmstudio_statusLM Studio statusA
Return a read-only local LM Studio health summary, including API and model counts.
Inputs: no named parameters. Returns: host, port, warnings, cliStatus, +9 more
lmstudio_test_endpointsTest LM Studio API endpointsC
Classify native chat, OpenAI chat completions, and Responses API as passed, unsupported, or failed.
Inputs: model. Returns: model, results
lmstudio_test_inferenceTest local LM Studio inferenceA
Run one tiny deterministic inference against an explicitly selected local endpoint. Never falls back to cloud.
Inputs: model, prompt, endpoint, max_tokens. Returns: error, model, success, endpoint, +8 more
lmstudio_test_streaming_tool_callingTest streaming LM Studio tool callingA
Verify a real streamed Chat Completions tool-call round trip, including fragmented delta reassembly, strict argument validation, fixture execution, streamed continuation, progress, and cancellation.
Inputs: model. Returns: model, steps, errors, success, +12 more
lmstudio_test_structured_outputTest LM Studio structured outputA
Test JSON Schema enforcement independently from JSON mode and prompt-only JSON, then validate output with Ajv.
Inputs: model, endpoint. Returns: model, results, success, selectedEndpoint, +1 more
lmstudio_test_tool_callingTest LM Studio tool callingB
Run a real deterministic local tool-call round trip with argument validation, fixture execution, result delivery, and continuation verification.
Inputs: model, endpoint. Returns: model, results, success, selectedEndpoint, +1 more
lmstudio_unload_modelUnload an LM Studio modelA
MUTATING and disabled by default. Requires one explicit loaded identifier and never unloads all models.
Inputs: identifier (required).
lmstudio_validate_mcpValidate LM Studio MCP configurationA
Read and validate LM Studio's MCP JSON without changing it; secret-like values are redacted.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Each tool has a clearly distinct purpose: status, diagnostics, validation, model listing, inspection, various tests, security audit, snapshot export, log capture, and load/unload actions. Even the testing tools are separated by specific API features (inference, endpoints, tool calling, streaming, structured output), leaving no real ambiguity.
All tools share the lmstudio_ prefix and use snake_case, but there is a mix of bare nouns (status, capabilities, benchmark) and verb_noun compounds (list_models, load_model, test_inference). This is mostly consistent and readable, but not perfectly uniform.
With 18 tools, the server is slightly above the typical well-scoped range, but the breadth is justified by its comprehensive diagnostic and testing mission. The tools cover distinct aspects of local LM Studio management and verification, so the count feels reasonable rather than bloated.
The toolset covers the full lifecycle of interacting with a local LM Studio: listing and inspecting models, loading/unloading, testing core API paths (inference, tool calling, structured output, streaming), health/diagnostics, security auditing, configuration validation, and log capture. No critical dead ends or missing operations are apparent for the stated purpose.
Maintenance
Related MCP Connectors
Ovanek MCP: Model Context Protocol server for Ovanek platform tools; writes are dry-run by default.
MCP server for building and testing AI agents with multi-model experimentation and insights.
Guarded MCP server for agent-readable business truth, provenance, readiness, and discovery.
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Related MCP Servers
- FlicenseBqualityCmaintenanceEnables 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-
- AlicenseNot gradedqualityCmaintenanceEnables locally configured MCP servers to be called over stdio and mixed with xAI server-side tools, without relying on hosted xAI MCP.MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP-compatible AI clients to inspect Godot project and editor state, observe opted-in running scenes, manage processes, and apply permission-scoped guarded edits. It starts read-only and exposes additional capabilities only through explicit command-line flags.Apache 2.0
- AlicenseCqualityFmaintenanceThis MCP server gives an AI coding host controlled, client-agnostic access to a local machine's developer capabilities: transactional file edits, shell and PTY execution, Git and project inspection, language-server operations, isolated browser automation, Windows UI automation, VS Code state, durable jobs, and checkpoints, all bounded by filesystem root allowlisting and resource admission controls. It speaks standard MCP over stdio, Streamable HTTP, and legacy HTTP+SSE, and can also run headless as a long-lived job runner without any hosted model vendor.114ISC