LMStudio-MCP

Integrations

  • Provides access to locally running LLM models via LM Studio's OpenAI-compatible API endpoints, enabling text generation with custom parameters like temperature and token limits.

LMStudio-MCP

模型控制协议 (MCP) 服务器允许 Claude 通过 LM Studio 与本地运行的 LLM 模型进行通信。

概述

LMStudio-MCP 在 Claude(具有 MCP 功能)和您本地运行的 LM Studio 实例之间建立了桥梁。这使得 Claude 能够:

  • 检查 LM Studio API 的健康状况
  • 列出可用模型
  • 获取当前加载的模型
  • 使用本地模型生成完成

这使您能够通过 Claude 的界面利用您自己的本地运行模型,将 Claude 的功能与您的私有模型相结合。

先决条件

  • Python 3.7+
  • LM Studio已安装并在本地运行,并加载了模型
  • 拥有 MCP 访问权限的 Claude
  • 所需的 Python 包(参见安装)

安装

  1. 克隆此存储库:
    git clone https://github.com/infinitimeless/LMStudio-MCP.git cd LMStudio-MCP
  2. 安装所需的软件包:
    pip install requests "mcp[cli]" openai

MCP 配置

要让 Claude 连接到此桥接器,您需要正确配置 MCP 设置。您可以:

  1. 直接从 GitHub 使用
    { "lmstudio-mcp": { "command": "uvx", "args": [ "https://github.com/infinitimeless/LMStudio-MCP" ] } }
  2. 使用本地安装
    { "lmstudio-mcp": { "command": "/bin/bash", "args": [ "-c", "cd /path/to/LMStudio-MCP && source venv/bin/activate && python lmstudio_bridge.py" ] } }

有关详细的 MCP 配置说明,请参阅MCP_CONFIGURATION.md

用法

  1. 启动您的 LM Studio 应用程序并确保它在端口 1234(默认)上运行
  2. 在 LM Studio 中加载模型
  3. 如果在本地运行(不使用uvx ),请运行 LMStudio-MCP 服务器:
    python lmstudio_bridge.py
  4. 在 Claude 中,当出现提示时,选择“lmstudio-mcp”连接到 MCP 服务器

可用函数

该桥提供以下功能:

  • health_check() :验证 LM Studio API 是否可访问
  • list_models() :获取 LM Studio 中所有可用模型的列表
  • get_current_model() :识别当前加载的模型
  • chat_completion(prompt, system_prompt, temperature, max_tokens) :从本地模型生成文本

已知限制

  • 某些型号(例如 phi-3.5-mini-instruct_uncensored)可能存在兼容性问题
  • 该桥目前仅使用 LM Studio 的 OpenAI 兼容 API 端点
  • 模型响应将受到本地加载模型的功能限制

故障排除

API 连接问题

如果 Claude 在尝试连接 LM Studio 时报告 404 错误:

  • 确保 LM Studio 正在运行并已加载模型
  • 检查 LM Studio 的服务器是否在端口 1234 上运行
  • 验证防火墙是否阻止连接
  • 如果问题仍然存在,请尝试在 API URL 中使用“127.0.0.1”而不是“localhost”

模型兼容性

如果某些型号无法正常工作:

  • 某些模型可能不完全支持 OpenAI 聊天完成 API 格式
  • 对于有问题的模型,尝试不同的参数值(温度、max_tokens)
  • 如果问题仍然存在,请考虑切换到更兼容的型号

有关更详细的故障排除帮助,请参阅TROUBLESHOOTING.md

执照

麻省理工学院

致谢

该项目最初开发为“Claude-LMStudio-Bridge_V2”,现已更名并开源为“LMStudio-MCP”。

-
security - not tested
A
license - permissive license
-
quality - not tested

一个桥梁,允许 Claude 通过 LM Studio 与本地运行的 LLM 模型进行通信,使用户能够通过 Claude 的界面利用他们的私有模型。

  1. Overview
    1. Prerequisites
      1. Installation
        1. MCP Configuration
          1. Usage
            1. Available Functions
              1. Known Limitations
                1. Troubleshooting
                  1. API Connection Issues
                  2. Model Compatibility
                2. License
                  1. Acknowledgements
                    ID: 6nm5k0ghlp