Token导航 LogoToken导航TokenDH.com
Xcode Tools Docs logo
开发工具未说明官方级别未说明来源级核验

Xcode Tools Docs

MCP Server

Xcode工具集是一套用于与Xcode工作空间交互的工具,支持文件管理、项目构建、测试运行、预览渲染等功能。

工具数

20

提示词数

0

GitHub Stars

20

资源数

0
开发工具Claude命令行工具Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

artemnovichkov

提供方

artemnovichkov

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

Xcode工具文档

Xcode MCP服务器(又称Xcode工具)的全面参考。这些工具使AI助手能够与Xcode工作区进行交互——管理文件、构建项目、运行测试、渲染预览等。

苹果文档

先决条件

  • Xcode 26.3+已安装并在开放式工作区中运行
  • 配置了Xcode集成的MCP服务器
注: 大多数工具都需要 tabIdentifier 标识要在哪个Xcode工作区选项卡上操作的参数。

安装

通过以下方式将Xcode MCP服务器添加到您的编码工具中 xcrun mcpbridge:

克劳德代码:

claude mcp add --transport stdio xcode -- xcrun mcpbridge

食品法典:

codex mcp add xcode -- xcrun mcpbridge

证实 claude mcp listcodex mcp list.

模式

tools.json 包含直接从生成的完整MCP工具定义(名称、标题、描述、输入/输出模式) xcrun mcpbridge.

目录

- X代码列表窗口

- Xcodels - Xcodeglow - Xcodegrep - XcodeRead - XcodeWrite - XcodeUpdate - Xcodemakedir - XcodeMV - XcodeRM

- 建筑项目 - GetBuildLog - 执行代码段

- GetTestList - 运行所有测试 - RunSome测试

- XcodeRefreshCodeIssuesInFile - Xcodelistnavigator问题

- 渲染审查

- 文档搜索

______________________________________________________________________

工作区

X代码列表窗口

列出当前Xcode窗口及其工作区信息。使用此项获取 tabIdentifier 所有其他工具所需的值。

参数:

例子:

XcodeListWindows()

______________________________________________________________________

文件操作

Xcodels

列出给定路径下Xcode项目结构中的文件和目录。在项目导航器层次结构上操作,而不是在文件系统上操作。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
pathstring要浏览的项目路径(例如。, ProjectName/Sources/)
recursiveboolean递归列出所有文件(截断为100行)。违约: true
ignorestring\[\]要跳过的模式

例子:

XcodeLS(tabIdentifier: "...", path: "MyApp/Sources/")

Xcodeglow

在Xcode项目中查找与通配符模式匹配的文件。支持 *, **, ?, [abc],以及 {swift,m} 语法。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
patternstringNoGlob模式(例如。, **/*.swift).默认为 **/*
pathstring要搜索的目录(默认为项目根目录)

例子:

XcodeGlob(tabIdentifier: "...", pattern: "**/*.swift")

Xcodegrep

在Xcode项目结构中使用正则表达式模式搜索文件内容。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
patternstring要搜索的正则表达式模式
pathstring要搜索的文件或目录(默认为root)
globstring仅搜索与此glob匹配的文件
typestring文件类型快捷方式(swift, js, py等等)
outputModestringcontent, filesWithMatches (默认),或 count
ignoreCaseboolean不区分大小写的匹配
multilineboolean允许图案跨越多行
showLineNumbersboolean显示行号(仅限内容模式)
linesBeforeinteger每次匹配前的上下文行
linesAfterinteger每次匹配后的上下文行
linesContextinteger每次匹配前后的上下文行
headLimitintegerN个结果后停止

例子:

XcodeGrep(
  tabIdentifier: "...",
  pattern: "func viewDidLoad",
  type: "swift",
  outputMode: "content",
  linesAfter: 5
)

XcodeRead

读取带有行号的文件内容(cat -n 格式)。支持大文件的偏移/限制。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
filePathstring项目相对文件路径(例如。, ProjectName/Sources/MyFile.swift)
offsetinteger开始读取的行号
limitinteger要读取的行数(默认值:最多600行)

例子:

XcodeRead(tabIdentifier: "...", filePath: "MyApp/Sources/ContentView.swift")

XcodeWrite

在Xcode项目中创建或覆盖文件。自动将新文件添加到项目结构中。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
filePathstring项目相对文件路径
contentstring要写入的文件内容

例子:

XcodeWrite(
  tabIdentifier: "...",
  filePath: "MyApp/Sources/NewFeature.swift",
  content: "import Foundation\n\nstruct NewFeature {\n}\n"
)

XcodeUpdate

通过查找和替换文本来编辑文件。在项目结构路径上运行。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
filePathstring项目相对文件路径
oldStringstring要查找的文本
newStringstring替换文本(必须与 oldString)
replaceAllboolean替换所有匹配项。违约: false

例子:

XcodeUpdate(
  tabIdentifier: "...",
  filePath: "MyApp/Sources/ContentView.swift",
  oldString: "Hello, World!",
  newString: "Hello, SwiftUI!"
)

Xcodemakedir

在Xcode项目导航器中创建目录和组。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
directoryPathstring新目录的项目相对路径

例子:

XcodeMakeDir(tabIdentifier: "...", directoryPath: "MyApp/Sources/ViewModels")

XcodeMV

在项目导航器中移动、复制或重命名文件和目录。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
sourcePathstring项目导航器中的源路径
destinationPathstring目标路径或新名称
operationstringmovecopy
overwriteExistingboolean覆盖目标位置的文件

例子:

XcodeMV(
  tabIdentifier: "...",
  sourcePath: "MyApp/Sources/OldName.swift",
  destinationPath: "MyApp/Sources/NewName.swift"
)

XcodeRM

从Xcode项目中删除文件和目录。可选择删除底层文件系统文件。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
pathstring要删除的项目路径
recursiveboolean递归删除目录和内容
deleteFilesboolean同时将文件移至回收站。违约: true

例子:

XcodeRM(tabIdentifier: "...", path: "MyApp/Sources/Deprecated.swift")

______________________________________________________________________

构建与运行

建筑项目

使用活动方案构建Xcode项目并等待完成。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符

例子:

BuildProject(tabIdentifier: "...")

GetBuildLog

从当前或最近的生成中检索生成日志条目。按严重性、文件模式或消息正则表达式过滤。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
severitystring最低严重性: error (默认), warning,或 remark
patternstring用于按消息、任务描述、命令行或控制台输出进行筛选的正则表达式
globstring按文件路径或任务位置筛选的Glob

例子:

GetBuildLog(tabIdentifier: "...", severity: "warning")

执行代码段

在特定源文件的上下文中构建并运行代码段。该代码段可以访问该文件中的所有声明,包括 fileprivate 一个。输出来自 print 声明。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
codeSnippetstring要执行的Swift代码
sourceFilePathstring项目到上下文文件的相对路径
timeoutinteger最大等待时间(秒)。默认值:120
注: 仅适用于构建应用程序、框架、库或CLI可执行文件的目标中的源文件。

例子:

ExecuteSnippet(
  tabIdentifier: "...",
  sourceFilePath: "MyApp/Sources/Models/User.swift",
  codeSnippet: "let user = User(name: \"Test\")\nprint(user)"
)

______________________________________________________________________

测试

GetTestList

从活动方案的活动测试计划中获取所有可用测试。结果仅限于100次测试。完整列表已写入 fullTestListPath 以grep友好的格式使用grep,键如下 TEST_TARGET, TEST_IDENTIFIER,或 TEST_FILE_PATH 找到具体的测试。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符

例子:

GetTestList(tabIdentifier: "...")

运行所有测试

运行活动方案的活动测试计划中的每个测试。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符

例子:

RunAllTests(tabIdentifier: "...")

RunSome测试

按目标和标识符运行特定测试。使用 GetTestList 首先发现可用的测试标识符。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
testsarrayYes测试说明符数组(见下文)

每个测试说明符对象:

字段类型必填描述
targetNamestring测试目标名称
testIdentifierstringYesXCTestIdentifier格式的测试标识符

例子:

RunSomeTests(
  tabIdentifier: "...",
  tests: [
    { "targetName": "MyAppTests", "testIdentifier": "MyAppTests/LoginTests/testValidLogin" }
  ]
)

______________________________________________________________________

诊断

XcodeRefreshCodeIssuesInFile

检索特定文件的当前编译器诊断(错误、警告、注释)。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
filePathstring项目相对文件路径

例子:

XcodeRefreshCodeIssuesInFile(
  tabIdentifier: "...",
  filePath: "MyApp/Sources/ContentView.swift"
)

Xcodelistnavigator问题

从Xcode的Issue Navigator中列出问题,包括构建错误、包解析问题和工作区配置问题。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
severitystring最低严重性: error (默认), warning,或 remark
patternstring按消息筛选的正则表达式
globstring按文件路径筛选的Glob

例子:

XcodeListNavigatorIssues(tabIdentifier: "...", severity: "warning")

______________________________________________________________________

预览

渲染审查

构建并渲染SwiftUI预览,返回结果UI的快照。

参数类型必填说明
tabIdentifierstring工作区选项卡标识符
sourceFilePathstring投影包含预览的文件的相对路径
previewDefinitionIndexInFileinteger从零开始的索引 #Preview 宏观或 PreviewProvider 在文件中。违约: 0
timeoutinteger最大等待时间(秒)。默认值:120

例子:

RenderPreview(
  tabIdentifier: "...",
  sourceFilePath: "MyApp/Sources/Views/ProfileView.swift"
)

______________________________________________________________________

文档

文档搜索

使用语义匹配搜索Apple开发者文档。可用于查找API、框架和使用模式。

参数类型必填说明
querystring搜索查询
frameworksstring\[\]将搜索限制到特定框架。如果省略,则搜索全部

作者

阿特姆·诺维奇科夫,https://artemnovichkov.com

目录标签

目录标签

开发工具Claude命令行工具Xcode集成本地部署文件管理项目构建测试运行

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

20

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP