MCP Shell Server 是一个安全的服务器,用于执行授权的 shell 命令,并支持通过 stdin 传递输入。它实现了模型上下文协议(MCP),允许远程执行经过验证的 shell 命令,为用户提供了安全、高效的命令执行环境。
pip install -e ".[test]"
uvicorn main:app --reload
运行以下命令检查是否成功安装:
mcp-shell-server --version
请求示例:
{
"command": ["echo", "Hello, World!"],
"stdin": null,
"directory": "/",
"timeout": 30
}
响应示例:
{
"stdout": "Hello, World!\n",
"stderr": "",
"status": 0,
"execution_time": 0.123456
}
请求示例:
{
"command": ["tr", "a-z", "A-Z"],
"stdin": "hello world\n",
"directory": "/tmp",
"timeout": 60
}
code ~/Library/Application\ Support/Claude/claude.yaml
backend:
class: mcp_shell_server.Backend
config:
server_uri: http://localhost:5000
max_timeout: 3600
poetry install
poetry run mcp-shell-server
参数名 | 类型 | 是否必须 | 描述 |
---|---|---|---|
command | string[] | 是 | 命令及其参数,作为数组元素 |
stdin | string | 否 | 提供给命令的标准输入 |
directory | string | 否 | 执行命令的工作目录 |
timeout | integer | 否 | 最大执行时间(秒) |
参数名 | 类型 | 描述 |
---|---|---|
stdout | string | 标准输出 |
stderr | string | 错误输出 |
status | integer | 退出状态码 |
execution_time | float | 执行时间(秒) |
error | string | 错误信息(仅在失败时出现) |
git clone https://github.com/yourusername/mcp-shell-server.git
cd mcp-shell-server
pip install -e ".[test]"
pytest
参数名 | 类型 | 是否必须 | 描述 |
---|---|---|---|
command | string[] | 是 | 命令及其参数,作为数组元素 |
stdin | string | 否 | 提供给命令的标准输入 |
directory | string | 否 | 执行命令的工作目录 |
timeout | integer | 否 | 最大执行时间(秒) |
参数名 | 类型 | 描述 |
---|---|---|
stdout | string | 标准输出 |
stderr | string | 错误输出 |
status | integer | 退出状态码 |
execution_time | float | 执行时间(秒) |
error | string | 错误信息(仅在失败时出现) |
MIT 许可证 - 请参阅 LICENSE 文件以获取详细信息。