Mcp Server Commands

Mcp Server Commands

用于运行命令的模型上下文协议服务器

概述

MCP Server Commands 是一个为大型语言模型(如Claude)设计的工具,允许模型执行系统命令和脚本。

功能

  • run_command - 执行系统命令并返回结果
  • run_script - 执行模型编写的脚本代码

安装

通过 npm 安装

npm install mcp-server-commands

配置 Claude 桌面应用

根据您的系统在以下位置添加服务器配置:

  • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json

配置内容:

{
  "mcpServers": {
    "mcp-server-commands": {
      "command": "npx",
      "args": ["mcp-server-commands"]
    }
  }
}

使用方法

使用 Claude 时,您可以要求它执行命令或脚本。例如:

  • 查看当前目录文件: ls -la
  • 创建并运行 Python 脚本
  • 查询系统信息: hostname

安全注意事项

⚠️ 警告:

  • 使用 Approve Once 而不是 Allow for This Chat 来审查每个命令
  • 不要使用 sudo 运行此服务
  • 谨慎审核每个命令后再执行

开发

# 安装依赖
npm install

# 构建服务器
npm run build

# 开发模式
npm run watch

# 调试
npm run inspector

日志

日志位置: ~/Library/Logs/Claude/mcp-server-mcp-server-commands.log

需要更详细日志时,在配置中添加 --verbose 参数。


更多信息请参考视频教程