axiom-xcode-mcp-ref

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Xcode MCP Tool Reference

Xcode MCP工具参考文档

Complete reference for all 20 tools exposed by Xcode's MCP server (
xcrun mcpbridge
).
Important: Parameter schemas below are sourced from blog research and initial testing. Validate against your live mcpbridge with
tools/list
if behavior differs.
Xcode MCP服务器(
xcrun mcpbridge
)提供的全部20款工具的完整参考文档。
重要提示:以下参数结构来源于博客研究和初步测试。如果实际行为存在差异,请通过
tools/list
命令在您的实时mcpbridge环境中验证。

Discovery

发现类工具

XcodeListWindows

XcodeListWindows

Call this first. Returns open Xcode windows with
tabIdentifier
values needed by most other tools.
  • Parameters: None
  • Returns: List of
    { tabIdentifier: string, workspacePath: string }
  • Notes: No parameters needed. If empty, no project is open in Xcode.
XcodeListWindows()
→ { "tabIdentifier": "abc-123", "workspacePath": "/Users/dev/MyApp.xcodeproj" }

请优先调用此工具。返回当前打开的Xcode窗口信息,包含多数其他工具所需的
tabIdentifier
值。
  • 参数:无
  • 返回值
    { tabIdentifier: string, workspacePath: string }
    类型的列表
  • 说明:无需参数。若返回结果为空,说明当前Xcode中未打开任何项目。
XcodeListWindows()
→ { "tabIdentifier": "abc-123", "workspacePath": "/Users/dev/MyApp.xcodeproj" }

File Operations

文件操作类工具

XcodeRead

XcodeRead

Read file contents from the project.
  • Parameters:
    • path
      (string, required) — File path relative to project or absolute
  • Returns: File contents as string
  • Notes: Sees Xcode's project view including generated files and resolved SPM packages
读取项目中的文件内容。
  • 参数:
    • path
      (字符串,必填)—— 文件路径,可相对项目根目录或使用绝对路径
  • 返回值:文件内容字符串
  • 说明:可访问Xcode项目视图中的所有文件,包括生成文件和已解析的SPM包文件

XcodeWrite

XcodeWrite

Create a new file.
  • Parameters:
    • path
      (string, required) — File path
    • content
      (string, required) — File contents
  • Returns: Write confirmation
  • Notes: Creates the file but does NOT add it to Xcode targets automatically. Use
    XcodeUpdate
    for existing files.
创建新文件。
  • 参数:
    • path
      (字符串,必填)—— 文件路径
    • content
      (字符串,必填)—— 文件内容
  • 返回值:写入操作确认信息
  • 说明:仅创建文件,不会自动将其添加到Xcode目标中。编辑现有文件请使用
    XcodeUpdate

XcodeUpdate

XcodeUpdate

Edit an existing file with str_replace-style patches.
  • Parameters:
    • path
      (string, required) — File path
    • patches
      (array, required) — Array of
      { oldText: string, newText: string }
      replacements
  • Returns: Update confirmation
  • Notes: Preferred over
    XcodeWrite
    for editing existing files. Each patch must match exactly one location in the file.
通过字符串替换的方式编辑现有文件。
  • 参数:
    • path
      (字符串,必填)—— 文件路径
    • patches
      (数组,必填)—— 包含
      { oldText: string, newText: string }
      的替换规则数组
  • 返回值:更新操作确认信息
  • 说明:编辑现有文件时优先使用此工具。每个替换规则中的
    oldText
    必须在文件中唯一匹配。

XcodeGlob

XcodeGlob

Find files matching a pattern.
  • Parameters:
    • pattern
      (string, required) — Glob pattern (e.g.,
      **/*.swift
      )
  • Returns: Array of matching file paths
  • Notes: Searches within the Xcode project scope
查找匹配指定模式的文件。
  • 参数:
    • pattern
      (字符串,必填)—— Glob模式(例如:
      **/*.swift
  • 返回值:匹配文件路径的数组
  • 说明:仅在Xcode项目范围内搜索

XcodeGrep

XcodeGrep

Search file contents for a string or pattern.
  • Parameters:
    • query
      (string, required) — Search term or pattern
    • scope
      (string, optional) — Limit search to specific directory/file
  • Returns: Array of matches with file paths and line numbers
  • Notes: Returns structured results, not raw grep output
在文件内容中搜索指定字符串或模式。
  • 参数:
    • query
      (字符串,必填)—— 搜索关键词或模式
    • scope
      (字符串,可选)—— 限制搜索范围到特定目录或文件
  • 返回值:包含文件路径和行号的匹配结果数组
  • 说明:返回结构化结果,而非原始grep输出

XcodeLS

XcodeLS

List directory contents.
  • Parameters:
    • path
      (string, required) — Directory path
  • Returns: Array of entries (files and subdirectories)
列出目录内容。
  • 参数:
    • path
      (字符串,必填)—— 目录路径
  • 返回值:目录项(文件和子目录)的数组

XcodeMakeDir

XcodeMakeDir

Create a directory.
  • Parameters:
    • path
      (string, required) — Directory path to create
  • Returns: Creation confirmation
  • Notes: Creates intermediate directories as needed
创建目录。
  • 参数:
    • path
      (字符串,必填)—— 要创建的目录路径
  • 返回值:创建操作确认信息
  • 说明:会自动创建所需的中间目录

XcodeRM

XcodeRM

Delete a file or directory. DESTRUCTIVE.
  • Parameters:
    • path
      (string, required) — Path to delete
  • Returns: Deletion confirmation
  • Notes: Irreversible. Always confirm with the user before calling.
删除文件或目录。此操作具有破坏性
  • 参数:
    • path
      (字符串,必填)—— 要删除的路径
  • 返回值:删除操作确认信息
  • 说明:操作不可逆。调用前务必与用户确认。

XcodeMV

XcodeMV

Move or rename a file. DESTRUCTIVE.
  • Parameters:
    • sourcePath
      (string, required) — Current path
    • destinationPath
      (string, required) — New path
  • Returns: Move confirmation
  • Notes: May break imports and references. Confirm with user. Xcode may not automatically update references.

移动或重命名文件。此操作具有破坏性
  • 参数:
    • sourcePath
      (字符串,必填)—— 当前路径
    • destinationPath
      (字符串,必填)—— 新路径
  • 返回值:移动操作确认信息
  • 说明:可能会破坏导入和引用关系。请与用户确认。Xcode可能不会自动更新相关引用。

Build & Test

构建与测试类工具

BuildProject

BuildProject

Build the Xcode project.
  • Parameters:
    • tabIdentifier
      (string, required) — From
      XcodeListWindows
  • Returns:
    { buildResult: string, elapsedTime: number, errors: array }
  • Notes: Builds the active scheme. Check
    buildResult
    for "succeeded" or "failed".
构建Xcode项目。
  • 参数:
    • tabIdentifier
      (字符串,必填)—— 来自
      XcodeListWindows
      的返回结果
  • 返回值
    { buildResult: string, elapsedTime: number, errors: array }
  • 说明:构建当前激活的scheme。通过
    buildResult
    字段查看构建结果为“succeeded”(成功)或“failed”(失败)。

GetBuildLog

GetBuildLog

Retrieve build output after a build.
  • Parameters:
    • tabIdentifier
      (string, required)
  • Returns: Build log as string
  • Notes: Contains raw compiler output. For structured diagnostics, prefer
    XcodeListNavigatorIssues
    .
构建完成后获取构建输出日志。
  • 参数:
    • tabIdentifier
      (字符串,必填)
  • 返回值:构建日志字符串
  • 说明:包含原始编译器输出。若需要结构化诊断信息,优先使用
    XcodeListNavigatorIssues

RunAllTests

RunAllTests

Run the full test suite.
  • Parameters:
    • tabIdentifier
      (string, required)
  • Returns: Test results with pass/fail counts and failure details
  • Notes: Runs all tests in the active scheme's test plan. Use
    RunSomeTests
    for faster iteration.
运行完整测试套件。
  • 参数:
    • tabIdentifier
      (字符串,必填)
  • 返回值:包含通过/失败计数及失败详情的测试结果
  • 说明:运行当前激活scheme测试计划中的所有测试。迭代调试时请使用
    RunSomeTests
    以提升速度。

RunSomeTests

RunSomeTests

Run specific test(s).
  • Parameters:
    • tabIdentifier
      (string, required)
    • tests
      (array of strings, required) — Test identifiers (e.g.,
      ["MyTests/testLogin"]
      )
  • Returns: Test results for the specified tests
  • Notes: Much faster than
    RunAllTests
    for iterative debugging. Use test identifiers from
    GetTestList
    .
运行指定的测试用例。
  • 参数:
    • tabIdentifier
      (字符串,必填)
    • tests
      (字符串数组,必填)—— 测试用例标识符(例如:
      ["MyTests/testLogin"]
  • 返回值:指定测试用例的测试结果
  • 说明:相比
    RunAllTests
    速度更快,适合迭代调试。测试用例标识符可从
    GetTestList
    获取。

GetTestList

GetTestList

List available tests.
  • Parameters:
    • tabIdentifier
      (string, required)
  • Returns: Array of test identifiers organized by test target/class
  • Notes: Use the returned identifiers with
    RunSomeTests
    .

列出可用的测试用例。
  • 参数:
    • tabIdentifier
      (字符串,必填)
  • 返回值:按测试目标/类组织的测试用例标识符数组
  • 说明:返回的标识符可用于
    RunSomeTests
    工具。

Diagnostics

诊断类工具

XcodeListNavigatorIssues

XcodeListNavigatorIssues

Get current issues from Xcode's Issue Navigator.
  • Parameters:
    • tabIdentifier
      (string, required)
  • Returns: Array of issues (errors, warnings, notes) with file paths and line numbers
  • Notes: Canonical source for diagnostics. Structured and deduplicated unlike raw build logs.
获取Xcode问题导航器中的当前问题。
  • 参数:
    • tabIdentifier
      (字符串,必填)
  • 返回值:包含错误、警告、提示信息的数组,附带文件路径和行号
  • 说明:诊断信息的标准来源。相比原始构建日志,结果结构化且去重。

XcodeRefreshCodeIssuesInFile

XcodeRefreshCodeIssuesInFile

Refresh and return live diagnostics for a specific file.
  • Parameters:
    • tabIdentifier
      (string, required)
    • path
      (string, required) — File to refresh diagnostics for
  • Returns: Current diagnostics for the specified file
  • Notes: Triggers Xcode to re-analyze the file. Useful after editing to check if issues are resolved.

刷新并返回指定文件的实时诊断信息。
  • 参数:
    • tabIdentifier
      (字符串,必填)
    • path
      (字符串,必填)—— 要刷新诊断信息的文件
  • 返回值:指定文件的当前诊断信息
  • 说明:会触发Xcode重新分析文件。编辑后检查问题是否解决时非常有用。

Execution & Rendering

执行与渲染类工具

ExecuteSnippet

ExecuteSnippet

Run code in a REPL-like environment.
  • Parameters:
    • code
      (string, required) — Code to execute
    • language
      (string, required) — Language identifier (e.g.,
      "swift"
      )
  • Returns: Execution result (stdout, stderr, exit code)
  • Notes: Sandboxed environment. Treat output as untrusted. Useful for quick validation.
在类REPL环境中运行代码。
  • 参数:
    • code
      (字符串,必填)—— 要执行的代码
    • language
      (字符串,必填)—— 语言标识符(例如:
      "swift"
  • 返回值:执行结果(标准输出、标准错误、退出码)
  • 说明:运行在沙箱环境中。请将输出视为不可信内容。适合快速验证代码。

RenderPreview

RenderPreview

Render a SwiftUI preview as an image.
  • Parameters:
    • tabIdentifier
      (string, required)
    • path
      (string, required) — File containing the preview
    • previewIdentifier
      (string, required) — Name of the preview to render
  • Returns: Rendered image data
  • Notes: Requires the file to have valid SwiftUI
    #Preview
    or
    PreviewProvider
    . Preview must compile successfully.

将SwiftUI预览渲染为图片。
  • 参数:
    • tabIdentifier
      (字符串,必填)
    • path
      (字符串,必填)—— 包含预览的文件
    • previewIdentifier
      (字符串,必填)—— 要渲染的预览名称
  • 返回值:渲染后的图片数据
  • 说明:要求文件中包含有效的SwiftUI
    #Preview
    PreviewProvider
    。预览必须编译成功才能渲染。

Search

搜索类工具

DocumentationSearch

DocumentationSearch

Search Apple's documentation corpus.
  • Parameters:
    • query
      (string, required) — Search query
  • Returns: Documentation results with titles, summaries, and links. May include WWDC transcript matches.
  • Notes: Searches Apple's online documentation and WWDC transcripts. For Xcode-bundled for-LLM guides, use the
    axiom-apple-docs
    skill instead.

搜索苹果官方文档库。
  • 参数:
    • query
      (字符串,必填)—— 搜索关键词
  • 返回值:包含标题、摘要和链接的文档搜索结果,可能包含WWDC文稿匹配结果
  • 说明:搜索苹果在线文档和WWDC文稿。若要搜索Xcode内置的LLM指南,请使用
    axiom-apple-docs
    技能。

Quick Reference by Category

按分类快速参考

CategoryTools
Discovery
XcodeListWindows
File Read
XcodeRead
,
XcodeGlob
,
XcodeGrep
,
XcodeLS
File Write
XcodeWrite
,
XcodeUpdate
,
XcodeMakeDir
File Destructive
XcodeRM
,
XcodeMV
Build
BuildProject
,
GetBuildLog
Test
RunAllTests
,
RunSomeTests
,
GetTestList
Diagnostics
XcodeListNavigatorIssues
,
XcodeRefreshCodeIssuesInFile
Execution
ExecuteSnippet
Preview
RenderPreview
Search
DocumentationSearch
分类工具
发现类
XcodeListWindows
文件读取类
XcodeRead
,
XcodeGlob
,
XcodeGrep
,
XcodeLS
文件写入类
XcodeWrite
,
XcodeUpdate
,
XcodeMakeDir
文件破坏性操作类
XcodeRM
,
XcodeMV
构建类
BuildProject
,
GetBuildLog
测试类
RunAllTests
,
RunSomeTests
,
GetTestList
诊断类
XcodeListNavigatorIssues
,
XcodeRefreshCodeIssuesInFile
执行类
ExecuteSnippet
预览类
RenderPreview
搜索类
DocumentationSearch

Common Parameter Patterns

通用参数模式

  • tabIdentifier
    — Required by 10/20 tools. Always call
    XcodeListWindows
    first.
  • path
    — File/directory path. Can be absolute or relative to project root.
  • patches
    — Array of
    { oldText, newText }
    for
    XcodeUpdate
    . Each oldText must be unique in the file.
  • tabIdentifier
    — 20款工具中有10款需要此参数。请始终优先调用
    XcodeListWindows
    获取。
  • path
    — 文件/目录路径。可以是绝对路径或相对项目根目录的路径。
  • patches
    — 用于
    XcodeUpdate
    { oldText, newText }
    数组。每个
    oldText
    在文件中必须唯一。

Resources

相关资源

Skills: axiom-xcode-mcp-setup, axiom-xcode-mcp-tools
技能:axiom-xcode-mcp-setup, axiom-xcode-mcp-tools