MCP服务器,用于执行CLI命令进行系统部署和管理
Project description
CLI Executor MCP
基于MCP的CLI命令执行服务,用于系统部署和管理
概述
CLI Executor MCP是一个基于Model Context Protocol (MCP)的服务,它提供了执行Linux CLI命令的工具,使LLM(如Cursor、Claude)能够执行Linux系统命令、部署应用程序和管理系统。
主要功能:
- 执行单个CLI命令
- 执行多行脚本
- 列出目录内容
- 获取系统信息
- 提供部署应用的提示模板
安装
从源代码安装
# 克隆仓库
git clone https://github.com/yourusername/cli-executor-mcp.git
cd cli-executor-mcp
# 安装
pip install -e .
使用pip安装
pip install cli-executor-mcp
使用方法
作为命令行工具运行
# 使用sse传输(默认)
cli-executor-mcp
# 使用stdio传输
cli-executor-mcp --transport stdio
# 启用调试模式
cli-executor-mcp --debug
# 指定端口号
cli-executor-mcp --port 9000
# 指定主机地址
cli-executor-mcp --host 127.0.0.1
# 同时指定主机地址和端口号
cli-executor-mcp --host 127.0.0.1 --port 9000
环境变量配置
您也可以通过环境变量来配置CLI Executor MCP:
CLI_EXECUTOR_PORT: 设置SSE服务器端口号(默认:8000)CLI_EXECUTOR_HOST: 设置SSE服务器主机地址(默认:0.0.0.0)CLI_EXECUTOR_TRANSPORT: 设置传输类型,可选值为"stdio"或"sse"(默认:"sse")CLI_EXECUTOR_DEBUG: 启用调试模式,可选值为"true"、"1"或"yes"(默认:禁用)
例如:
# 设置环境变量
export CLI_EXECUTOR_PORT=9000
export CLI_EXECUTOR_HOST=127.0.0.1
export CLI_EXECUTOR_DEBUG=true
# 运行服务器(将使用上面设置的环境变量)
cli-executor-mcp
在Claude Desktop中安装
使用MCP CLI工具安装:
mcp install cli-executor-mcp
或者从源代码安装:
cd cli-executor-mcp
mcp install .
工具和资源
工具
CLI Executor MCP提供以下工具:
-
execute_command - 执行单个CLI命令
- 参数:
command: 要执行的命令working_dir: (可选) 执行命令的工作目录
- 参数:
-
execute_script - 执行多行脚本
- 参数:
script: 要执行的脚本内容(多行命令)working_dir: (可选) 执行脚本的工作目录
- 参数:
-
list_directory - 列出指定目录的内容
- 参数:
path: (可选) 要列出内容的目录路径
- 参数:
资源
- system://info - 获取系统信息
提示
- deploy_app - 创建一个部署应用的提示
- 参数:
app_name: 应用名称target_dir: 目标目录
- 参数:
示例
执行命令
# 使用MCP客户端调用工具
result = await session.call_tool("execute_command", {"command": "ls -la"})
print(result)
执行脚本
# 使用MCP客户端调用工具
script = """
mkdir -p test_dir
cd test_dir
echo "Hello, World!" > test.txt
ls -la
"""
result = await session.call_tool("execute_script", {"script": script})
print(result)
获取系统信息
# 使用MCP客户端读取资源
content, mime_type = await session.read_resource("system://info")
print(content)
安全注意事项
CLI Executor MCP允许执行任意系统命令,这可能带来安全风险。在生产环境中使用时,请确保:
- 限制服务器的访问权限
- 在受限环境中运行服务器(如容器或沙箱)
- 实施命令白名单或其他安全措施
许可证
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cli_executor_mcp-0.3.1.tar.gz.
File metadata
- Download URL: cli_executor_mcp-0.3.1.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74bd7244f25c8d3fe76ae48a3a6a36c8dd0dec015aec4e32542228fe5ef62f92
|
|
| MD5 |
dd25caedd7ed5cf14b16c3cdd90d257a
|
|
| BLAKE2b-256 |
d72499669ab08ef66fae61e572dda78fe2b68207fac32b9ce829d4d619114799
|
File details
Details for the file cli_executor_mcp-0.3.1-py3-none-any.whl.
File metadata
- Download URL: cli_executor_mcp-0.3.1-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49459276450732b5b8556cd5ccfba2b6592764ef794f748198ae831dd8d13786
|
|
| MD5 |
673b65450e9d8883b1c57d16da6e7f9e
|
|
| BLAKE2b-256 |
186a65d5a9f7b2027d01cb2bbc34852b66c8e2167c7b34e1d85ceb4f11480624
|