SL

seajhawk/lmstudio-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

6 stars 4 forks 质量 69 趋势 14MIT

MCP server to help with managing models in local LM Studio

概览

A Model Context Protocol (MCP) server for LM Studio that enables model management through standardized tools. - 📋 - View all available models and their current state - 🚀 - Load models into memory with configurable TTL - 🛑 - Immediately unload models from memory - ⚙️ - Adjust model settings like TTL and draft models - 📊 - Get detailed information about specific models - Node.js >= 18.0.0 - LM Studio running with local server enabled - LM Studio local server running on port 1234 (default) or custom port Follow these steps to build and run the MCP server locally. 1. Install dependencies and build the project: 2. Start the server (uses the compiled files in dist): 3. The server writes MCP communication to stdout and logs to stderr. - Default LM Studio URL: http://localhost:1234. - To use a custom LM Studio URL, set LM_STUDIO_BASE_URL before starting.

README

以下为原文 README 节选,完整内容请查看原文。

LM Studio MCP Server

A Model Context Protocol (MCP) server for LM Studio that enables model management through standardized tools.

Features

  • 📋 List Models - View all available models and their current state
  • 🚀 Load Models - Load models into memory with configurable TTL
  • 🛑 Unload Models - Immediately unload models from memory
  • ⚙️ Configure Models - Adjust model settings like TTL and draft models
  • 📊 Model Details - Get detailed information about specific models

Prerequisites

  • Node.js >= 18.0.0
  • LM Studio running with local server enabled
  • LM Studio local server running on port 1234 (default) or custom port

Installation

npm install
npm run build

Quickstart (Build & Run)

Follow these steps to build and run the MCP server locally.

  1. Install dependencies and build the project:
npm install
npm run build
  1. Start the server (uses the compiled files in dist):
npm start
  1. The server writes MCP communication to stdout and logs to stderr.

Environment variable tips:

  • Default LM Studio URL: http://localhost:1234.
  • To use a custom LM Studio URL, set LM_STUDIO_BASE_URL before starting.

PowerShell (Windows) example:

$env:LM_STUDIO_BASE_URL = "http://localhost:1234"
npm start

Command Prompt (Windows) example:

set LM_STUDIO_BASE_URL=http://localhost:1234 && npm start

macOS / Linux example:

LM_STUDIO_BASE_URL="http://localhost:1234" npm start

Development workflow:

  • Rebuild on change (in one terminal): npm run watch
  • Run the server (in another terminal): npm run dev (starts Node with the inspector)

You can also run the compiled script directly with node dist/index.js if preferred.

Configuration

LM Studio Setup

  1. Open LM Studio
  2. Go to the Developer tab
  3. Enable the local server (default port: 1234)
  4. Optionally enable “Serve on Local Network” if accessing remotely

Environment Variables

  • LM_STUDIO_BASE_URL - Base URL for LM Studio API (default: http://localhost:1234)

Usage

With Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "lmstudio": {
      "command": "node",
      "args": ["/path/to/lmstudio-mcp/dist/index.js"],
      "env": {
        "LM_STUDIO_BASE_URL": "http://localhost:1234"
      }
    }
  }
}

With Other MCP Clients

Run the server directly:

node dist/index.js

The server communicates over stdio following the MCP protocol.

Available Tools

list_models

List all available models with their current state (loaded/not-loaded).

Parameters: None

Example Response:

[
  {
    "id": "lmstudio-community/Meta-Llama-3-8B-Instruct-GGUF",
    "type": "llm",
    "publisher": "Meta",
    "architecture": "llama",
    "state": "loaded",
    "max_context_length": 8192
  }
]

get_model_details

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "lmstudio": { "command": "node", "args": ["/path/to/lmstudio-mcp/dist/index.js"], "env": { "LM_STUDIO_BASE_URL": "http://localhost:1234" } } } }