代理IDE-Perforce和Swarm MCP服务器
两台MCP(模型上下文协议)服务器,为您的代理IDE提供完整的Perforce+Swarm超能力:
| 服务器 | 它做什么 |
|---|---|
| 性能-p4 | 官方Perforce MCP服务器--查询/修改文件、更改列表、工具架、工作区、作业、评论 |
| p4工作流 | 自定义一键式工作流程——使用思科模板创建CL,签出文件,搁置,提出Swarm评论,从任何评论中获取差异,添加评论 |
快速入门(需要零依赖)
git clone
cd p4v-swarm-mcp-server
chmod +x setup.sh
./setup.sh就这样 该脚本在裸macOS机器上从头开始安装所有内容:
| 什么 | 如何 |
|---|---|
| Homebrew | 如果缺失,则自动安装 |
| p4 CLI | 从Perforce CDN下载或通过Homebrew安装 |
| Python 3 | brew install python3 |
| Node.js | brew install node (顺序思维MCP所需) |
| p4 mcp服务器 | 引导下载(需要Perforce帐户) |
| Python deps | pip3 install fastmcp httpx |
| 身份验证 | 交互式P4登录+macOS钥匙链存储 |
| MCP配置 | 自动生成 ~/.cursor/mcp.json |
| AI规则+技能 | 将规则和技能安装到 ~/.cursor/ |
安装后,重新启动IDE(Cmd+Q,重新打开)并测试:
List my pending changelists光标AI用户:在Cursor中打开此仓库并询问“设置此仓库”——AI将自动识别并运行设置脚本。
______________________________________________________________________
建筑
脚本直接从这个仓库运行——没有副本,没有占位符,没有部署步骤。
所有配置都以如下方式传递 环境变量 通过 mcp.json.在mcp.json中编辑一次,重新启动IDE,完成。
~/.cursor/mcp.json
│
├── perforce-p4 ──► this-repo/perforce-p4/p4-mcp-start.sh
│ ├── reads P4PORT, P4USER, P4_BIN, P4_MCP_SERVER from env
│ ├── resolves P4CLIENT from `p4 set`
│ ├── auto-login from Keychain if ticket expired
│ └── exec p4-mcp-server
│
└── p4-workflow ──► this-repo/p4-workflow/server.py
├── reads P4PORT, P4USER, P4_BIN, SWARM_URL from env
├── auto-login from Keychain on every p4 command
└── FastMCP server with 10 tools______________________________________________________________________
手动设置(如果您愿意)
步骤1:安装必备组件
# Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# p4 CLI (pick one)
brew install --cask perforce
# OR download from https://www.perforce.com/downloads/helix-command-line-client-p4
# Python 3, Node.js
brew install python3 node
# Python dependencies
pip3 install fastmcp httpx
# p4-mcp-server — download from https://www.perforce.com/downloads (search "Helix MCP Server")步骤2:配置mcp.json
复制 mcp.json.template 到 ~/.cursor/mcp.json 并用实际的路径/值替换所有占位符。
步骤3:重新启动IDE并测试
______________________________________________________________________
环境变量
性能-p4(p4-mcp启动.sh)
| 变量 | 必填 | 描述 |
|---|---|---|
P4PORT | 是 | 执行服务器(例如。 ssl:server:1666) |
P4USER | 是 | 执行用户名 |
P4CLIENT_DEFAULT | 否 | 回退工作区 p4 set P4CLIENT 不返回任何内容 |
P4_BIN | 否 | 路径 p4 CLI(从PATH或 ~/bin/p4) |
P4_MCP_SERVER | 否 | 路径 p4-mcp-server 二进制(自动检测自 ~/bin/p4-mcp-server*) |
p4工作流(server.py)
| 变量 | 必填 | 描述 |
|---|---|---|
P4PORT | 是 | Perforce服务器 |
P4USER | 是 | 执行用户名 |
SWARM_URL | 否 | Swarm基本URL(默认值: https://sp4-fp-swarm.cisco.com) |
P4_BIN | 否 | 路径 p4 CLI(自动检测) |
______________________________________________________________________
可用工具
表演-p4(官方)
| 工具 | 说明 |
|---|---|
query_files | 获取文件信息、内容、历史记录、差异、注释 |
query_changelists | 列出/搜索更改列表 |
modify_changelists | 创建/更新更改列表描述 |
query_shelves | 列出搁置的文件 |
modify_shelves | 搁置/取消搁置文件 |
modify_files | 添加/编辑/删除/还原文件 |
query_workspaces | 列出/搜索工作区 |
modify_workspaces | 创建/更新工作区 |
query_jobs | 列出/搜索职位 |
modify_jobs | 创建/更新作业 |
query_reviews | 列出Swarm评论 |
modify_reviews | 更新Swarm评论 |
query_server | 服务器信息和连接状态 |
p4工作流(自定义思科工作流)
| 工具 | 说明 |
|---|---|
create_changelist | 根据错误ID使用完整的Cisco IMS模板创建CL |
checkout_file | 在CL中打开文件进行编辑(p4 edit) |
update_description | 更新CL描述,不限制字符数 |
update_review | 重新搁置代码更改——Swarm自动版本 |
raise_review | Shelve+创建新的Swarm评论(一次通话) |
get_review_diff | 获取任何Swarm评论的完整差异+元数据 |
get_review_info | 获取任何Swarm评论的元数据+文件列表(无差异正文) |
add_review_comment | 在Swarm评论中添加评论 |
p4_login | 检查/刷新登录状态(从钥匙扣自动续订) |
save_p4_password | 将P4密码存储在Keychain中以自动登录 |
______________________________________________________________________
故障排除
MCP服务器未显示在IDE中?
- 检查
~/.cursor/mcp.json是有效的JSON(没有尾随逗号) - 完全重新启动IDE(Cmd+Q,重新打开)
“连接到服务器失败”?
- 检查VPN连接
- 跑
p4 login在终端刷新您的票
p4工作流“找不到模块”?
- 跑
pip3 install fastmcp httpx - 如果失败:
pip3 install --break-system-packages fastmcp httpx
“必须设置P4PORT”错误?
- 确保
envmcp.json中的块包括P4PORT和P4USER
安装后未找到p4 CLI?
- 检查
~/bin/p4存在并且可执行 - 或重新运行
./setup.sh
______________________________________________________________________
文件结构
p4v-swarm-mcp-server/
README.md <- You are here
setup.sh <- Zero-to-working installer
mcp.json.template <- Template for manual ~/.cursor/mcp.json setup
.gitignore
.cursor/rules/
setup-guide.mdc <- Tells Cursor AI how to set up this repo
rules/
p4-workflow.mdc <- Always-on rule (installed to ~/.cursor/rules/)
skills/
p4-workflow/
SKILL.md <- Agent skill (installed to ~/.cursor/skills/)
perforce-p4/
p4-mcp-start.sh <- Wrapper script for official MCP server
p4-workflow/
server.py <- Custom workflow MCP server
requirements.txt <- Python dependencies