全能MCP(diaMCP)
专为以下目的设计的多功能MCP服务器 呼叫.cpp MCP集成。设置简单-只需启动容器并将您的webui指向URL即可。
为什么选择diaMCP?
使用llama服务器的webui时,您需要没有复杂性的工具。无需管理服务器,也无需写入配置文件。只是:
docker compose up --build -d- 将MCP URL添加到您的webui
- 完成。
安装
选项1:快速安装(推荐)
Linux/macOS
curl -fsSL https://raw.githubusercontent.com/chartrambiz/diaMCP/main/install.sh | sh视窗
irm https://raw.githubusercontent.com/chartrambiz/diaMCP/main/install.ps1 | iex脚本将:
- 检查Docker和Docker Compose是否已安装
- 克隆仓库(如果不存在)
- 构建并启动容器
- 显示下一步
要更新现有安装,请从diaMCP目录中运行相同的命令。
选项2:Git克隆
Linux/macOS
# Clone the repository
git clone https://github.com/chartrambiz/diaMCP.git
cd diaMCP
# Start the container
docker compose up --build -dWindows(PowerShell)
# Clone the repository
git clone https://github.com/chartrambiz/diaMCP.git
cd diaMCP
# Start the container
docker compose up --build -d稍后更新:
git pull origin main 2>/dev/null || git pull origin master
docker compose up --build -dWindows安装要求
如果使用Windows,您需要:
- Windows 版 Docker 桌面应用
- 下载自https://docker.com/products/docker-desktop - 需要Windows 10/11专业版、企业版或教育版 - 在安装过程中启用WSL2后端
- WSL2(Linux的Windows子系统)
- 以管理员身份打开PowerShell并运行:
wsl --install- 出现提示时重新启动计算机 - 建议将Ubuntu作为您的Linux发行版
- WSL2设置后
- 从“开始”菜单打开Ubuntu(或您选择的发行版) - 从WSL2中运行上述安装命令 - 此README中的所有Linux/bash命令都将按原样工作
备注:不支持直接在Windows命令提示符或PowerShell(没有WSL2)中运行diaMCP-安装脚本和容器是为Linux环境设计的。
安装后设置
启动MCP服务器容器后:
- 在启用MCP代理的情况下启动llama服务器:
llama-server --webui-mcp-proxy -m model.gguf -c 32768 --host 0.0.0.0 --port 8080- 在llama.cpp网页界面中:
- 转到MCP设置 - 切换 “启用llama服务器代理” 开 - 添加MCP URL: http://localhost:8000/mcp
MCP工具将在您的聊天中提供。
注: 在中创建的文件 workspace/ 目录由您的用户(UID 1000)拥有。如果需要其他UID,请编辑 docker-compose.yml 并更改 user: 价值。
更新
修改自定义工具或拉取新更改后,重新生成并重新启动:
./restart.sh此脚本重建容器并验证其是否正在运行。
演示
查看diaMCP与llama.cpp webui的操作:
文件操作
网络搜索与研究
特性
- 21+内置工具:文件操作、网络搜索、git、shell、代码执行等
- 危险指令封锁:
run_command阻止危险模式(rm-rf、dd、mkfs等) - 激励支持:风险命令的确认提示(适用于支持它的MCP客户端)
- 动态工具发现:将Python文件放入
./workspace/tools/或使用内置示例 - HTTP传输:没有stdio,没有额外的配置-只有一个URL
- 持久工作区:文件和工具在容器重启后仍然存在
- 与llama服务器webui配合使用:专为内置于llama.cpp webui中的MCP集成而设计
工具
文件操作
| 工具 | 说明 |
|---|---|
read_file | 读取文件内容 |
write_file | 将内容写入文件 |
list_directory | 列出目录内容 |
search_files | 按glob模式查找文件 |
grep | 在文件中搜索模式 |
file_info | 获取文件元数据(大小、日期、权限) |
delete_file | 删除文件(进行安全检查) |
create_directory | 创建目录 |
网络与研究
| 工具 | 说明 |
|---|---|
web_search | 搜索网络(DuckDuckGo) |
web_fetch | 从网页中提取文本 |
download_file | 将文件从URL下载到工作区 |
Git操作
| 工具 | 说明 |
|---|---|
git_clone | 克隆存储库 |
git_pull | 拉取最新更改 |
系统和代码
| 工具 | 说明 |
|---|---|
run_command | 执行shell命令(带有危险的模式阻塞) |
python_eval | 运行Python代码段 |
run_python_script | 执行Python脚本文件 |
get_system_info | 系统信息 |
get_time | 当前日期/时间 |
calculate | 数学表达式 |
count_lines | 按文件类型计算代码行数 |
安全管理
| 工具 | 说明 |
|---|---|
manage_blacklist | 从黑名单中添加/删除命令 |
manage_approved | 列出/清除已批准的命令 |
get_dangerous_patterns | 显示被阻挡的危险图案 |
自定义工具(./workspace/Tools/)
| 工具 | 说明 |
|---|---|
greeting | 生成个性化问候 |
add_numbers | 加两个数字 |
word_reverser | 颠倒句子中的单词 |
元工具
| 工具 | 说明 |
|---|---|
create_tool | 动态创建新工具(用于LLM) |
看 代理商.md 有关创建工具的详细文档。
MCP资源
资源公开了LLM可以按需读取的上下文数据:
| 资源 | 描述 |
|---|---|
diamcp://context/time | 当前日期和时间 |
diamcp://context/system | 系统信息 |
diamcp://workspace/summary | 工作区内容概述 |
diamcp://tools/list | 所有可用工具列表 |
MCP提示
常见工作流的可重用提示模板:
| 提示 | 描述 |
|---|---|
startup_context | 首先调用get_time和get_system_info |
file_search_first | 在读取文件之前使用search_files |
web_research | Web搜索然后获取工作流 |
code_review | 代码审查步骤 |
添加自定义工具
在中创建Python文件 ./workspace/tools/:
from base import tool
@tool(
name="my_tool",
description="What my tool does",
schema={
"type": "object",
"properties": {
"input": {"type": "string", "description": "Input"}
},
"required": ["input"]
}
)
def my_tool(input: str) -> str:
return f"Processed: {input}"重新启动容器以加载新工具:
./restart.sh配置
环境变量
| 变量 | 默认值 | 描述 |
|---|---|---|
MCP_HOST | 0.0.0.0 | 要绑定的主机 |
MCP_PORT | 8000 | 要收听的端口 |
Docker Compose
services:
diamcp:
build: .
ports:
- "8000:8000"
volumes:
- ./workspace:/workspace工作区卷在重新启动时保留您的文件和自定义工具。
建筑
diamcp/
├── server.py # Main MCP server (FastMCP)
├── base.py # Tool decorator & registry (copy to /app/tools/)
├── builtin.py # Built-in tools (copy to /app/tools/)
├── tools/ # Internal diaMCP tools (copied to /app/tools/)
│ ├── examples/ # Reference examples - copy to workspace/tools/ to use
│ │ ├── useful_tools.py
│ │ ├── weather_tool.py
│ │ └── example_tools.py
├── install.sh # One-line install/update script (Linux/macOS)
├── install.ps1 # One-line install/update script (Windows)
├── restart.sh # Rebuild and restart script
├── config/ # Configuration
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── workspace/ # Persistent volume (mounted at /workspace)
└── tools/ # Your custom tools go here工具位置
| 地点 | 目的 | 坚持? |
|---|---|---|
tools/ | 内置diaMCP工具 | 否-容器内部 |
tools/examples/ | 参考示例 | 否-复制到工作区使用 |
workspace/tools/ | 您的自定义工具 | 是-在更新后仍然有效 |
要使用示例工具,请从以下位置复制 tools/examples/ 到 workspace/tools/,然后运行 ./restart.sh.
需求
- 码头工人
- Docker Compose
- 支持MCP的llama.cpp webui(
--webui-mcp-proxyllama服务器上的标志)
许可证
MIT许可证-有关详细信息,请参阅许可证文件。
