xcpmcp
用于Xcode项目操作的MCP服务器。允许AI助手(Claude Code等)在中添加、删除和列出文件 .xcodeproj 无需手动编辑的项目 .pbxproj 文件夹。
也可以作为独立的CLI使用。
工具
| 工具 | 说明 |
|---|---|
list_targets | 列出具有产品类型的本地目标 |
list_files | 列出项目中的文件,可选择按目标筛选 |
list_groups | 显示组/文件夹层次结构 |
add_file | 将文件添加到目标(源代码或资源构建阶段) |
remove_file | 从项目中删除文件引用 |
move_file | 将文件移动到其他组(仅限项目导航器,不在磁盘上) |
remove_group | 删除一个组(空的,或带有所有子组的递归) |
rename_group | 在项目导航器中重命名组 |
move_group | 将组移动到其他父组下 |
安装
git clone https://github.com/yonilevy/xcpmcp.git
cd xcpmcp
make install这将构建一个发布二进制文件,并将其复制到 ~/.local/bin/xcpmcp,并可选地将其注册为Claude Code中的MCP服务器。
要安装到其他位置:
make install PREFIX=/opt/bin要卸载,请执行以下操作:
make uninstallCLI使用情况
当使用参数运行时,xcpmcp作为常规命令行工具工作:
# List targets
xcpmcp list-targets MyApp.xcodeproj
# List all files
xcpmcp list-files MyApp.xcodeproj
# List files in a specific target
xcpmcp list-files MyApp.xcodeproj --target MyApp
# Show group hierarchy
xcpmcp list-groups MyApp.xcodeproj
# Add a source file to a target
xcpmcp add-file MyApp.xcodeproj Sources/NewFile.swift --target MyApp
# Add a resource file
xcpmcp add-file MyApp.xcodeproj Assets/image.png --target MyApp --type resource
# Add to a specific group
xcpmcp add-file MyApp.xcodeproj Sources/Models/User.swift --target MyApp --group Sources/Models
# Remove a file from a specific target
xcpmcp remove-file MyApp.xcodeproj Sources/OldFile.swift --target MyApp
# Remove a file from all targets
xcpmcp remove-file MyApp.xcodeproj Sources/OldFile.swift
# Move a file to a different group
xcpmcp move-file MyApp.xcodeproj Sources/Models/User.swift --to-group Sources/NewModels
# Remove an empty group
xcpmcp remove-group MyApp.xcodeproj Sources/OldFolder
# Remove a group and all its children
xcpmcp remove-group MyApp.xcodeproj Sources/OldFolder --recursive
# Rename a group
xcpmcp rename-group MyApp.xcodeproj Sources/OldName --new-name NewName
# Move a group under a different parent
xcpmcp move-group MyApp.xcodeproj Sources/Models --to-group Sources/Core当不带参数运行时,它将通过stdin/stdout作为MCP服务器启动。
需求
- Swift 6.0+(Xcode 16+)
- macOS 13+
