Agent ExecMCP

FastMCP服务器为AI代理提供核心执行功能,打包在Docker中,便于安全和轻松部署。
⚡ 快速开始
在2分钟内起床并跑步:请参阅 QUICKSTART.md.
📋 目录
- 快速启动命令 - 核心命令 - 管理命令 - 维护命令 - 工作流示例
- 使用Make轻松设置 - 手动设置 - 测试集成 - 故障排除
- 手动设置
______________________________________________________________________
🚀 特性
- 壳牌执行:运行带有超时和安全控制的bash命令
- 多语言代码执行:Python、Node.js和Go支持,执行优化
- 包管理:通过pip、npm和go模块安装软件包
- 多个传输:stdio和SSE
- Docker部署:容器化以实现一致的执行环境
- MCP协议:符合标准的模型上下文协议
- 安全控制:非根执行、超时、并发限制
- Claude桌面集成:通过SSE传输与Claude Desktop无缝协作
- Go优化:使用CGO_ENABLED=0执行Go代码以提高兼容性
🛠️ 发出命令
AgentExecMCP包含一个全面的Makefile,使设置和管理变得超级简单。所有命令的设计都是为了方便技术和非技术用户使用。
快速启动命令
make help # Show all available commands with descriptions
make quick-start # Build and run with SSE transport (recommended)核心命令
make build # Build the Docker container
make run # Run with STDIO transport (interactive)
make run-sse # Run with SSE transport (for Claude Desktop)管理命令
make status # Show container status
make logs # Show container logs (follows log output)
make health # Check if server is responding
make stop # Stop all running containers
make shell # Open shell in running container开发命令
make lint # Run ruff linter and formatter维护命令
make test # Test basic functionality
make clean # Remove containers and images
make workspace # Create workspace directory工作流示例
# First time setup
make quick-start # Builds and starts everything
make install-claude-config # Sets up Claude Desktop
# Daily usage
make status # Check if running
make logs # View output
make stop # Stop when done
# Troubleshooting
make clean # Clean everything
make quick-start # Fresh start🖥️ Claude桌面集成
AgentExecMCP使用SSE传输与Claude Desktop无缝协作。这非常适合本地开发和测试。
使用Make轻松设置(推荐)
超级简单的3步设置:
- 启动AgentExecMCP:
make quick-start- 安装Claude桌面配置:
make install-claude-config- 重新启动克劳德桌面 并寻找MCP工具图标! 🎉
手动设置(如果您愿意)
- 启动SSE服务器:
docker run -d --name AgentExecMCP-claude -p 8000:8000 -e MCP_TRANSPORT=sse AgentExecMCP- 配置Claude桌面:
打开您的Claude Desktop配置文件:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json - 视窗: %APPDATA%\Claude\claude_desktop_config.json
添加以下配置:
{
"mcpServers": {
"AgentExecMCP": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:8000/sse"
]
}
}
}- 重新启动克劳德桌面 并查找MCP工具图标
测试集成
在Claude Desktop中尝试以下命令:
- “运行shell命令列出文件”
- “执行一些Python代码来计算2+2”
- “使用pip安装请求包”
故障排除
- 检查服务器状态:
make status - 查看日志:
make logs - 重新启动服务器:
make stop && make quick-start
Claude Desktop的先决条件
- Node.js和npm 安装在您的系统上
- 码头工人 使用AgentExecMCP容器运行
- 克劳德桌面版 最新版本
这 mcp-remote 首次使用时,npx会自动安装该包。
🖥️ 光标集成
AgentExecMCP与 光标 IDE使用与Claude Desktop相同的SSE传输和配置。
手动设置(光标)
- 启动SSE服务器:
make quick-start- 配置光标:
打开Cursor mcp配置文件(例如 ~/.cursor/mcp.json)并添加以下内容:
{
"mcpServers": {
"AgentExecMCP": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:8000/sse"
]
}
}
}🔧 MCP工具
1.外壳工具
执行带有安全控制的shell命令。
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "shell",
"arguments": {
"request": {
"command": "echo 'Hello World!'",
"timeout": 60,
"cwd": "/workspace"
}
}
}
}2.执行代码工具
在Python、Node.js或Go中运行代码片段,并优化执行。
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "execute_code",
"arguments": {
"request": {
"language": "python",
"code": "print('Hello from Python!')\nprint(2 + 2)",
"timeout": 60
}
}
}
}Go代码示例:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "execute_code",
"arguments": {
"request": {
"language": "go",
"code": "package main\nimport \"fmt\"\nfunc main() {\n fmt.Println(\"Hello from Go!\")\n}",
"timeout": 60
}
}
}
}特征:
- python:具有标准库的完整Python 3.x环境
- Node.js:使用npm包的Node.js运行时
- 去:使用CGO_ENABLED=0优化执行,以获得更好的兼容性
- 自动清理:临时文件会自动创建和清理
- 错误处理:正确捕获编译和运行时错误
3.安装软件包工具
使用各种包管理器安装包。
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "install_package",
"arguments": {
"request": {
"package_manager": "pip",
"package": "requests",
"version": "2.32.0"
}
}
}
}🌐 客户端连接示例
FastMCP客户端(Python)
from fastmcp import Client
import asyncio
async def main():
# Connect via stdio to local container
async with Client("docker run -i --rm AgentExecMCP") as client:
result = await client.call_tool("shell", {"request": {"command": "echo 'Hello!'"}})
print(result[0].text)
# Connect via SSE to HTTP server
async with Client("http://localhost:8000/sse") as client:
tools = await client.list_tools()
print(f"Available tools: {[tool.name for tool in tools]}")
asyncio.run(main())🔒 安全特性
- 非根执行:运行方式
agent用户(UID 10001) - 沙盒工作空间:所有操作
/workspace目录 - 超时控制:可配置超时(默认60秒,最大300秒)
- 并发限制:最多4个并发进程
- 输入验证:尺寸限制和参数验证
- 流程清理:自动清理正在运行的进程
🌍 环境
集装箱包括:
- Ubuntu 22.04 基本图像
- Python 3.13.3 使用pip包管理器
- Node.js 20.19.2 使用npm
- 转到1.23.4 带模块
- 开发工具:git、curl、wget、build essential
- 公用事业:jq、ripgrep、fd查找、htop
📡 MCP协议支持
服务器实现了具有多种传输选项的模型上下文协议(MCP)2024-11-05规范:
- 工作室:本地工具和命令行使用的默认传输
- 上海证券交易所:用于HTTP部署和Claude Desktop的服务器发送事件传输
🛠️ 发展
地方发展
# Install dependencies
uv sync
# Run server locally (stdio)
uv run python -m app.main
# Run server with SSE transport
MCP_TRANSPORT=sse uv run python -m app.main测试
服务器已通过以下测试:
- ✅ 所有传输的MCP协议合规性
- ✅ 所有三个工具(shell、execute_code、install_package)
- ✅ 通过包导入执行多语言代码
- ✅ 包装安装和验证
- ✅ Docker容器部署
- ✅ 通过SSE传输集成Claude Desktop
- ✅ 安全和超时控制
📋 需求
- Docker(用于容器化部署)
- Python 3.12+(用于本地开发)
- UV包管理器(用于依赖关系管理)
- Node.js和npm(用于Claude Desktop集成)
🎯 用例
- Claude桌面集成:直接在Claude Desktop中提供执行功能
- AI代理执行:为AI代理提供安全的执行环境
- 代码沙盒:在隔离容器中运行不受信任的代码
- 多语言开发:支持Python、Node.js和Go工作流
- 包管理:跨生态系统安装和测试软件包
- 壳牌自动化:通过适当的控制执行系统命令
- Kubernetes部署:扩展云环境中的执行能力
📄 许可证
此项目根据Apache许可证2.0获得许可-请参阅 许可证 文件以获取详细信息。
该项目遵循快速构建、可复制、默认安全和可扩展的指导原则。
