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 包(参见安装)
安装
- 克隆此存储库:
- 安装所需的软件包:
MCP 配置
要让 Claude 连接到此桥接器,您需要正确配置 MCP 设置。您可以:
- 直接从 GitHub 使用:
- 使用本地安装:
有关详细的 MCP 配置说明,请参阅MCP_CONFIGURATION.md 。
用法
- 启动您的 LM Studio 应用程序并确保它在端口 1234(默认)上运行
- 在 LM Studio 中加载模型
- 如果在本地运行(不使用
uvx
),请运行 LMStudio-MCP 服务器: - 在 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”。
Related MCP Servers
- -securityAlicense-qualityEnables seamless integration between Ollama's local LLM models and MCP-compatible applications, supporting model management and chat interactions.Last updated -16547TypeScriptAGPL 3.0
- -securityAlicense-qualityA comprehensive toolkit that enhances LLM capabilities through the Model Context Protocol, allowing LLMs to interact with external services including command-line operations, file management, Figma integration, and audio processing.Last updated -17PythonApache 2.0
- -securityAlicense-qualityA FreeCAD addon that implements the Model Context Protocol (MCP) to enable communication between FreeCAD and Claude AI through Claude Desktop.Last updated -17PythonMIT License
Fused MCP Agentsofficial
-securityAlicense-qualityA Python-based MCP server that allows Claude and other LLMs to execute arbitrary Python code directly through your desktop Claude app, enabling data scientists to connect LLMs to APIs and executable code.Last updated -23MIT License