!!!在LM Studio 0.3.25的最新更新中,这不再完全有效。!!!
MCP RunCmd(模板)
准备发布 MCP(模型上下文协议) 服务器 LM工作室 运行shell命令和Python代码。 此模板使用 通用、可编辑设置 通过环境变量,用户可以轻松地将其适应他们的系统。
✨ 里面是什么
runCmd.py--MCP服务器(完全工作),配置旋钮清晰。mcp.json--示例LM Studio配置,带有可编辑的占位符。requirements.txt--Python编程。.env.example--环境配置示例。.gitignore--合理的违约。LICENSE--MIT。
⚙️ 快速启动
# 1) Create and activate a virtualenv (optional but recommended)
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
# 2) Install deps
pip install -r requirements.txt
# 3) Copy the example env and edit to your needs
cp .env.example .env
# Edit .env to set WORKING_DIR, timeouts, etc.
# 4) Run
modify or add mcp.json LM Studio🔩 配置(环境变量)
WORKING_DIR--命令/文件操作的基本文件夹(默认:当前目录)。CMD_TIMEOUT--每个命令超时时间(秒)(默认值:30)。CMD_MAX_OUTPUT_BYTES--为stdout/stderr捕获的最大字节数(默认值:65536)。
您可以在shell中或通过 .env (如果你使用类似的东西 python-dotenv 你自己)。此模板 不 自动装载 .env 保持轻度依赖。
🖥️ LM工作室(mcp.json)
地方 mcp.json 旁边 runCmd.py (或在LM Studio配置中指向它)。示例文件包含占位符:
{
"name": "MCP RunCmd",
"description": "MCP server to run shell commands and Python scripts",
"binary": "python", // or absolute path to python
"args": ["runCmd.py"],
"env": {
"WORKING_DIR": "/ABS/PATH/TO/WORKDIR",
"CMD_TIMEOUT": "30",
"CMD_MAX_OUTPUT_BYTES": "65536"
},
"autoStart": true
}编辑 WORKING_DIR 用户应被允许操作的任何文件夹。
📦 发布到GitHub
git init
git add .
git commit -m "Initial release: MCP RunCmd template"
git branch -M main
git remote add origin https://github.com//mcp-run-cmd.git
git push -u origin main🔒 安全注意事项
此服务器可以执行shell命令。保持 WORKING_DIR 将范围限定为安全目录,并考虑在受限用户下运行。
📜 许可证
麻省理工学院
