magpie部署教程

本地magpie接入vps中的magpie服务

搭建magpie

  1. 搭建项目结构
1
2
3
mkdir -p /opt/magpie/config
chown 65532:65532 /opt/magpie/config
chown 700 /opt/magpie/config

目录结构

1
2
3
/opt/magpie/
├── compose.yaml
└── config/
  1. 创建配置文件
  • 生成compose.yaml文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
services:
magpie:
image: ghcr.io/yetone/magpie:latest
container_name: magpie
restart: unless-stopped

ports:
- "127.0.0.1:3425:3425"
- "127.0.0.1:3430:3430"

environment:
MAGPIE_WEB_KEY: ${MAGPIE_WEB_KEY}
magpie_public_url: "https://magpie.codeshot.xyz"
DO_NOT_TRACK: "1"

volumes:
- ./config:/config

command: [web, --addr, 0.0.0.0:3430, --no-open]
  • 生成web key
1
echo "MAGPIE_WEB_KEY=$(openssl rand -hex 24)" > .env
  1. 启动服务
1
docker compose up -d
  1. 配置服务商

ssh tunel访问web管理页面

1
ssh -N -L 3430:127.0.0.1:3430 vps-rn-la-01

浏览器访问127.0.0.1:3430,输入前面生成的web key

  • 添加provider
  • 生成gateway key

验证访问

1
2
curl -fsS https://magpie.codeshot.xyz/v1/models \
-H "Authorization: Bearer ${MAGPIE_GATEWAY_KEY}"

后期升级镜像

1
docker compose pull && docker compose up -d

模型提供方管理

安装magpie cli

1
yay -S magpie-cli-bin

设置软链接

1
ln -s /usr/bin/magpie-cli ~/.local/bin/magpie
  1. 添加远程提供商
1
magpie provider add remote-magpie "${MAGPIE_GATEWAY_KEY}" url=https://magpie.codeshot.xyz id=vps

测试连通性

1
magpie provider test vps
  1. 获取远程模型列表
1
magpie models

新增模型/路由组后,本地刷新

1
magpie provider refresh vps

配置模型

  • 具体模型
1
magpie claude Id/provider/modelId
  • 路由组
1
magpie claude Id/group/groupId

恢复原来的配置

1
magpie claude default

查看本机检测到的agents及当前配置

1
mapgie ls

查看支持的coding agents

1
magpie agents

服务管理

  • 临时启动服务
1
magpie serve
  • 后台daemon运行

安装并启动后台服务

1
magpie daemon install

查看服务状态

1
magpie daemon status

自定义

推荐配置:

  • 关闭统计上传

在~/.config/magpie/settings.json中配置:

1
2
3
{
"noStats": true
}
  • 关闭自动更新
1
magpie update auto off
  • 关闭账号发现
1
magpie accounts discovery off

Tips: 通过命令来控制的开关,可以去掉末尾的on/off来查看配置项的状态

完整配置:

1
2
3
4
5
{
"noStats": true,
"noAutoUpdate": true,
"noAccountDiscovery": true
}