Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created March 17, 2026 21:07
Show Gist options
  • Select an option

  • Save odrobnik/369b34f42f379569d10c5b9f4f37b3f4 to your computer and use it in GitHub Desktop.

Select an option

Save odrobnik/369b34f42f379569d10c5b9f4f37b3f4 to your computer and use it in GitHub Desktop.
Generated Server Proxy for new Xcode Tools MCP Server in Xcode 26.4 beta 3
//
// XcodeTools.swift
// Generated: 2026-03-17T21:57:02+01:00
// Server: xcode-tools (24886.5)
// Source: command /Applications/Xcode-beta.app/Contents/Developer/usr/bin/mcpbridge
//
import Foundation
import SwiftMCP
/// A generated proxy for the xcode-tools MCP server (24886.5).
public enum XcodeTools {
// MARK: - Declarations
public struct BuildProjectResponse: Codable, Sendable {
/// The message indicating the result of the build operation
public let buildResult: String
/// The time it took to finish the build, in seconds
public let elapsedTime: Double?
/// List of build errors
public let errors: [BuildProjectResponseErrorsItem]
}
public struct BuildProjectResponseErrorsItem: Codable, Sendable {
/// The type of error (error, warning, etc.)
public let classification: String
/// The file path where the error occurred
public let filePath: String?
/// The line number where the error occurred
public let lineNumber: Double?
/// The error message
public let message: String
}
public struct ExecuteSnippetResponse: Codable, Sendable {
/// An error that occurred during the snippet execution attempt.
public let error: ExecuteSnippetResponseError?
/// The console output generated by the `print` statements contained in the provided snippet.
public let executionResults: String?
}
/// An error that occurred during the snippet execution attempt.
public struct ExecuteSnippetResponseError: Codable, Sendable {
/// The path of an optional file that contains all the details of the error.
public let detailsPath: String?
/// A very short message describing the error.
public let message: String
/// An optional message providing advice on how to resolve the error.
public let recoveryAdvice: String?
/// A longer summary of the error and (if known) its cause.
public let summary: String
}
public struct GetBuildLogResponse: Codable, Sendable {
/// Indicates whether the build is still running.
public let buildIsRunning: Bool
/// The build log entries describing build commands that emitted issues
public let buildLogEntries: [GetBuildLogResponseBuildLogEntriesItem]
/// The message indicating the result of the build operation
public let buildResult: String
/// Path of the full log in textual format, containing the complete command lines and any output from the build tasks
public let fullLogPath: String
/// Optional message with additional information about the search results
public let message: String?
/// Total number of build log entries before truncation
public let totalFound: Double
/// Whether results were truncated due to exceeding 100 issues
public let truncated: Bool
}
public struct GetBuildLogResponseBuildLogEntriesItem: Codable, Sendable {
/// The build task represented by the log entry
public let buildTask: String?
/// Any issues emitted by the build task represented by the log entry
public let emittedIssues: [GetBuildLogResponseBuildLogEntriesItemEmittedIssuesItem]
}
public struct GetBuildLogResponseBuildLogEntriesItemEmittedIssuesItem: Codable, Sendable {
/// The line number where the issue was detected, if known
public let line: Double
/// The message describing the issue
public let message: String
/// The file path where the issue was detected, if any
public let path: String?
/// The severity of issue (error, warning, remark)
public let severity: String
}
public struct GetTestListResponse: Codable, Sendable {
/// The active test plan name
public let activeTestPlanName: String?
/// Aggregated test counts
public let counts: GetTestListResponseCounts
/// Path to file containing complete test list
public let fullTestListPath: String
/// The active scheme name
public let schemeName: String
/// Human-readable test list summary
public let summary: String
/// List of tests limited to 100
public let tests: [GetTestListResponseTestsItem]
/// Total number of tests before truncation
public let totalTests: Double
/// Whether test list was truncated
public let truncated: Bool
}
/// Aggregated test counts
public struct GetTestListResponseCounts: Codable, Sendable {
/// Number of disabled tests
public let disabled: Double
/// Number of enabled tests
public let enabled: Double
/// Total test count
public let total: Double
}
public struct GetTestListResponseTestsItem: Codable, Sendable {
/// Human readable test name
public let displayName: String
/// Source file path
public let filePath: String?
/// Test identifier in XCTestIdentifier format
public let identifier: String
/// Whether the test is enabled in the test plan
public let isEnabled: Bool
/// Line number in source file
public let lineNumber: Double?
/// Swift Testing tags
public let tags: [String]?
/// The test target name
public let targetName: String
}
public struct RenderPreviewResponse: Codable, Sendable {
/// An error that occurred during the preview attempt.
public let error: RenderPreviewResponseError?
/// The path to the image snapshot of the requested preview.
public let previewSnapshotPath: String?
}
/// An error that occurred during the preview attempt.
public struct RenderPreviewResponseError: Codable, Sendable {
/// The error message with potential underlying errors included.
public let message: String
}
public struct RunAllTestsResponse: Codable, Sendable {
/// Active test plan name
public let activeTestPlanName: String?
/// Test execution counts
public let counts: RunAllTestsResponseCounts
/// A text file path containing all test results and complete issue details in textual form
public let fullSummaryPath: String
/// Additional information about truncation
public let message: String?
/// Results for each test (truncated at 100, failures shown first)
public let results: [RunAllTestsResponseResultsItem]
/// Active scheme name
public let schemeName: String
/// Test execution summary
public let summary: String
/// Total number of test results before truncation
public let totalResults: Double
/// Whether results were truncated due to exceeding 100 results
public let truncated: Bool
}
/// Test execution counts
public struct RunAllTestsResponseCounts: Codable, Sendable {
/// Number of expected failures
public let expectedFailures: Double
/// Number of failed tests
public let failed: Double
/// Number of tests not run
public let notRun: Double
/// Number of passed tests
public let passed: Double
/// Number of skipped tests
public let skipped: Double
/// Total test count
public let total: Double
}
public struct RunAllTestsResponseResultsItem: Codable, Sendable {
/// Human-readable test name
public let displayName: String
/// Error messages
public let errors: [String]
/// Test identifier in XCTestIdentifier format
public let identifier: String
/// Execution state
public let state: String
/// The test target name
public let targetName: String
}
public struct RunSomeTestsResponse: Codable, Sendable {
/// Active test plan name
public let activeTestPlanName: String?
/// Test execution counts
public let counts: RunSomeTestsResponseCounts
/// A text file path containing all test results and complete issue details in textual form
public let fullSummaryPath: String
/// Additional information about truncation
public let message: String?
/// Results for each test (truncated at 100, failures shown first)
public let results: [RunSomeTestsResponseResultsItem]
/// Active scheme name
public let schemeName: String
/// Test execution summary
public let summary: String
/// Total number of test results before truncation
public let totalResults: Double
/// Whether results were truncated due to exceeding 100 results
public let truncated: Bool
}
/// Test execution counts
public struct RunSomeTestsResponseCounts: Codable, Sendable {
/// Number of expected failures
public let expectedFailures: Double
/// Number of failed tests
public let failed: Double
/// Number of tests not run
public let notRun: Double
/// Number of passed tests
public let passed: Double
/// Number of skipped tests
public let skipped: Double
/// Total test count
public let total: Double
}
public struct RunSomeTestsResponseResultsItem: Codable, Sendable {
/// Human-readable test name
public let displayName: String
/// Error messages
public let errors: [String]
/// Test identifier in XCTestIdentifier format
public let identifier: String
/// Execution state
public let state: String
/// The test target name
public let targetName: String
}
public struct XcodeGlobResponse: Codable, Sendable {
/// List of matching file paths in the project structure (truncated at 100), sorted by most recently modified first
public let matches: [String]
/// Optional message with additional information about the search results
public let message: String?
/// The pattern that was searched for
public let pattern: String
/// The project path that was searched
public let searchPath: String
/// Total number of files found before truncation
public let totalFound: Double
/// Whether results were truncated due to exceeding 100 files
public let truncated: Bool
}
public struct XcodeGrepResponse: Codable, Sendable {
/// Total number of matches found
public let matchCount: Double
/// Additional information about the search results
public let message: String?
/// The pattern that was searched for
public let pattern: String
/// Search results based on output mode
public let results: [String]
/// The project path that was searched
public let searchPath: String
/// Whether results were truncated due to limits
public let truncated: Bool
}
public struct XcodeLSResponse: Codable, Sendable {
/// List of files and directories at the specified path
public let items: [String]
/// The resolved project path that was browsed
public let path: String
}
public struct XcodeListNavigatorIssuesResponse: Codable, Sendable {
/// The list of current issues matching the input filters
public let issues: [XcodeListNavigatorIssuesResponseIssuesItem]
/// Optional message with additional information about the search results
public let message: String?
/// Total number of issues before truncation
public let totalFound: Double
/// Whether results were truncated due to exceeding 100 issues
public let truncated: Bool
}
public struct XcodeListNavigatorIssuesResponseIssuesItem: Codable, Sendable {
/// The category of the issue, if known
public let category: String?
/// The line number where the issue was detected, if known
public let line: Double?
/// The message describing the issue
public let message: String
/// The file path where the issue was detected, if any
public let path: String?
/// The severity of issue (error, warning, remark)
public let severity: String
/// Whether an issue from a previous build is known to still be relevant or whether something might have changed since it was emitted (for example if the source file has been edited and it isn't yet known whether that edit fixes the issue). Possible values: (fresh, stale)
public let vitality: XcodeListNavigatorIssuesResponseIssuesItemVitality?
}
/// Whether an issue from a previous build is known to still be relevant or whether something might have changed since it was emitted (for example if the source file has been edited and it isn't yet known whether that edit fixes the issue). Possible values: (fresh, stale)
public enum XcodeListNavigatorIssuesResponseIssuesItemVitality: String, Codable, Sendable, CaseIterable {
case fresh = "fresh"
case stale = "stale"
}
public struct XcodeListWindowsResponse: Codable, Sendable {
/// Description of all open Xcode windows
public let message: String
}
public struct XcodeMVResponse: Codable, Sendable {
/// The final path of the moved/renamed item
public let destinationFinalPath: String?
/// Result message describing the operation
public let message: String
/// The operation that was performed
public let operation: String
/// The original path of the source item
public let sourceOriginalPath: String?
/// Whether the move/rename operation succeeded
public let success: Bool
}
public struct XcodeMakeDirResponse: Codable, Sendable {
/// The path of the created directory
public let createdPath: String?
/// Result message describing the operation
public let message: String
/// Whether the directory creation succeeded
public let success: Bool
}
public struct XcodeRMResponse: Codable, Sendable {
/// Status message about the removal operation
public let message: String
/// The project path that was removed
public let removedPath: String
/// Whether the removal operation was successful
public let success: Bool
}
public struct XcodeReadResponse: Codable, Sendable {
/// The file contents formatted with line numbers (cat -n style)
public let content: String
/// The project path that was read
public let filePath: String
/// Size of the file in bytes
public let fileSize: Double
/// Number of lines actually read
public let linesRead: Double
/// The line number where reading started
public let startLine: Double
/// Total number of lines in the file
public let totalLines: Double
}
public struct XcodeRefreshCodeIssuesInFileResponse: Codable, Sendable {
/// Formatted diagnostic output with severity levels and messages
public let content: String
/// Number of diagnostics found (errors, warnings, notes)
public let diagnosticsCount: Double
/// The project path that was checked for diagnostics
public let filePath: String
/// Whether the diagnostic retrieval completed successfully
public let success: Bool
}
public struct XcodeUpdateResponse: Codable, Sendable {
/// Number of successful text replacements made
public let editsApplied: Double
/// The path of the file that was edited
public let filePath: String
/// Optional message with additional information about the edit results
public let message: String?
/// Length of the file content after editing
public let modifiedContentLength: Double
/// Length of the file content before editing
public let originalContentLength: Double
/// Whether the edit operation completed successfully
public let success: Bool
}
public struct XcodeWriteResponse: Codable, Sendable {
/// The absolute file system path of the written file
public let absolutePath: String?
/// Number of bytes written to the file
public let bytesWritten: Double
/// The project path that was written
public let filePath: String
/// Number of lines written to the file
public let linesWritten: Double
/// Result message describing the write operation
public let message: String
/// Whether the file write operation succeeded
public let success: Bool
/// Whether the file existed before writing
public let wasExistingFile: Bool
}
// MARK: - Metadata
public static let serverName: String? = "xcode-tools"
// MARK: - Client
public actor Client {
public let proxy: MCPServerProxy
public let clientName: String
public let clientVersion: String
public init(proxy: MCPServerProxy, clientName: String = "XcodeTools Client", clientVersion: String = "1.0.0") {
self.proxy = proxy
self.clientName = clientName
self.clientVersion = clientVersion
}
/// Connects to the MCP server, identifying as this client.
public func connect() async throws {
try await proxy.connect(clientName: clientName, clientVersion: clientVersion)
}
// MARK: - Functions
/// Builds an Xcode project and waits until the build completes.
/// - Parameter tabIdentifier: The workspace tab identifier
public func buildProject(tabIdentifier: String) async throws -> BuildProjectResponse {
var arguments: JSONDictionary = [:]
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("BuildProject", arguments: arguments)
return try MCPClientResultDecoder.decode(BuildProjectResponse.self, from: text)
}
/// Builds and runs a snippet of code in the context of a specific file and waits until results are available. This tool is available for source files in targets that build applications, frameworks, libraries, or command line executables. The output consists of the console output generated by the `print` statements contained in the provided snippet.
/// - Parameter codeSnippet: The code snippet that should be executed in the context of the specified file.
/// - Parameter purpose: A short human-readable description of the purpose of running this code snippet. Do NOT use the word 'test' in this string, because that is misleading and could make the user think that this functionality is related to testing.
/// - Parameter sourceFilePath: The path to a Swift source file within the Xcode project organization (e.g., 'ProjectName/Sources/MyFile.swift') whose context the code snippet will have access to (including `fileprivate` declarations).
/// - Parameter tabIdentifier: The workspace tab identifier.
/// - Parameter timeout: The time in seconds to wait for the execution of the snippet to complete. Defaults to 120 seconds.
public func executeSnippet(codeSnippet: String, purpose: String, sourceFilePath: String, tabIdentifier: String, timeout: Double? = nil) async throws -> ExecuteSnippetResponse {
var arguments: JSONDictionary = [:]
arguments["codeSnippet"] = try MCPClientArgumentEncoder.encode(codeSnippet)
arguments["purpose"] = try MCPClientArgumentEncoder.encode(purpose)
arguments["sourceFilePath"] = try MCPClientArgumentEncoder.encode(sourceFilePath)
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
if let timeout { arguments["timeout"] = try MCPClientArgumentEncoder.encode(timeout) }
let text = try await proxy.callTool("ExecuteSnippet", arguments: arguments)
return try MCPClientResultDecoder.decode(ExecuteSnippetResponse.self, from: text)
}
/// Gets the log of the current or most recently finished build. You can choose which build log entries to include by specifying the severity of any issues emitted by the build task represented by the entry. You can also filter by message regex pattern or file glob pattern. The response also indicates whether the build is currently in progress.
/// - Parameter glob: Glob to filter the returned build log entries. Will match against the 'path' field of any emitted issues, as well as against the location of any build task.
/// - Parameter pattern: Regex to filter the returned build log entries. Will match against the 'message' field of any emitted issues, as well as the task description, command line, and console output of any build tasks.
/// - Parameter severity: Limit the output of build log entries to those that emitted issues of the specified severity or higher. Valid values in order of decreasing severity are 'error', 'warning', 'remark'. Defaults to 'error'. Values: remark, warning, error
/// - Parameter tabIdentifier: The workspace tab identifier
public func getBuildLog(glob: String? = nil, pattern: String? = nil, severity: String? = nil, tabIdentifier: String) async throws -> GetBuildLogResponse {
var arguments: JSONDictionary = [:]
if let glob { arguments["glob"] = try MCPClientArgumentEncoder.encode(glob) }
if let pattern { arguments["pattern"] = try MCPClientArgumentEncoder.encode(pattern) }
if let severity { arguments["severity"] = try MCPClientArgumentEncoder.encode(severity) }
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("GetBuildLog", arguments: arguments)
return try MCPClientResultDecoder.decode(GetBuildLogResponse.self, from: text)
}
/// Gets all available tests from the active scheme's active test plan. Results are limited to 100 tests. The complete list is written to fullTestListPath in grep-friendly format. Use grep with keys like TEST_TARGET, TEST_IDENTIFIER, or TEST_FILE_PATH to find specific tests.
/// - Parameter tabIdentifier: The workspace tab identifier
public func getTestList(tabIdentifier: String) async throws -> GetTestListResponse {
var arguments: JSONDictionary = [:]
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("GetTestList", arguments: arguments)
return try MCPClientResultDecoder.decode(GetTestListResponse.self, from: text)
}
/// Builds and renders a Preview and waits until a snapshot of the resulting UI is available.
/// - Parameter previewDefinitionIndexInFile: The zero based index of the #Preview macro or PreviewProvider struct definition in the source file counting from the top. Defaults to 0, i.e. the first one.
/// - Parameter sourceFilePath: The path to the file within the Xcode project organization (e.g., 'ProjectName/Sources/MyFile.swift')
/// - Parameter tabIdentifier: The workspace tab identifier
/// - Parameter timeout: The time in seconds to wait for the rendering of the preview to complete. Defaults to 120 seconds.
public func renderPreview(previewDefinitionIndexInFile: Double? = nil, sourceFilePath: String, tabIdentifier: String, timeout: Double? = nil) async throws -> RenderPreviewResponse {
var arguments: JSONDictionary = [:]
if let previewDefinitionIndexInFile { arguments["previewDefinitionIndexInFile"] = try MCPClientArgumentEncoder.encode(previewDefinitionIndexInFile) }
arguments["sourceFilePath"] = try MCPClientArgumentEncoder.encode(sourceFilePath)
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
if let timeout { arguments["timeout"] = try MCPClientArgumentEncoder.encode(timeout) }
let text = try await proxy.callTool("RenderPreview", arguments: arguments)
return try MCPClientResultDecoder.decode(RenderPreviewResponse.self, from: text)
}
/// Runs all tests from the active scheme's active test plan
/// - Parameter tabIdentifier: The workspace tab identifier
public func runAllTests(tabIdentifier: String) async throws -> RunAllTestsResponse {
var arguments: JSONDictionary = [:]
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("RunAllTests", arguments: arguments)
return try MCPClientResultDecoder.decode(RunAllTestsResponse.self, from: text)
}
/// Runs specific tests using the active scheme's active test plan
/// - Parameter tabIdentifier: The workspace tab identifier
/// - Parameter tests: Array of test specifiers to run. Each specifier contains 'targetName' and 'testIdentifier' fields. Use GetTestList action to discover available tests and their identifiers, then extract the 'targetName' and 'identifier' fields from the TestActionInfo results to construct TestActionSpecifier objects.
public func runSomeTests(tabIdentifier: String, tests: [JSONDictionary]) async throws -> RunSomeTestsResponse {
var arguments: JSONDictionary = [:]
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
arguments["tests"] = try MCPClientArgumentEncoder.encode(tests)
let text = try await proxy.callTool("RunSomeTests", arguments: arguments)
return try MCPClientResultDecoder.decode(RunSomeTestsResponse.self, from: text)
}
/// Finds files in the Xcode project structure matching wildcard patterns. Works on Xcode project organization, not filesystem structure. Example patterns: '*.swift', '**/*.json', 'src/**/*.{swift,m}'. If no pattern is provided, defaults to '**/*' (all files).
/// - Parameter path: Which project directory to search in (optional, defaults to root)
/// - Parameter pattern: File matching pattern using wildcards (* ** ? [abc] {swift,m}). Examples: '*.swift', '**/*.json', 'src/**/*.{swift,m}'. Defaults to '**/*' if not provided.
/// - Parameter tabIdentifier: The workspace tab identifier
public func xcodeGlob(path: String? = nil, pattern: String? = nil, tabIdentifier: String) async throws -> XcodeGlobResponse {
var arguments: JSONDictionary = [:]
if let path { arguments["path"] = try MCPClientArgumentEncoder.encode(path) }
if let pattern { arguments["pattern"] = try MCPClientArgumentEncoder.encode(pattern) }
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("XcodeGlob", arguments: arguments)
return try MCPClientResultDecoder.decode(XcodeGlobResponse.self, from: text)
}
/// Searches for text patterns in files within the Xcode project structure using regex. Works on Xcode project organization, not filesystem structure. CRITICAL: Must include a 'pattern' argument - this tool will fail without it. Input pattern uses standard regex syntax, not JSON escaping. To find \d in source code, use pattern \\d. Output results are JSON-encoded e.g. backslashes, quotes, and newlines appear escaped (\\, \", \n).
/// - Parameter glob: Only search files matching this pattern
/// - Parameter headLimit: Stop after N results
/// - Parameter ignoreCase: Ignore case when matching
/// - Parameter linesAfter: Show N lines after each match for context
/// - Parameter linesBefore: Show N lines before each match for context
/// - Parameter linesContext: Show N lines both before and after each match
/// - Parameter multiline: Allow patterns to span multiple lines
/// - Parameter outputMode: What to return: content, files_with_matches, or count (default: files_with_matches) Values: content, filesWithMatches, count
/// - Parameter path: Where to search - file or directory in project (defaults to root)
/// - Parameter pattern: Text to search for using regex. REQUIRED: Must include a 'pattern' argument - this tool will fail without it.
/// - Parameter showLineNumbers: Show line numbers with results (content mode only)
/// - Parameter tabIdentifier: The workspace tab identifier
/// - Parameter type: Shortcut for common file types (swift, js, py, etc.)
public func xcodeGrep(glob: String? = nil, headLimit: Double? = nil, ignoreCase: Bool? = nil, linesAfter: Double? = nil, linesBefore: Double? = nil, linesContext: Double? = nil, multiline: Bool? = nil, outputMode: String? = nil, path: String? = nil, pattern: String, showLineNumbers: Bool? = nil, tabIdentifier: String, type: String? = nil) async throws -> XcodeGrepResponse {
var arguments: JSONDictionary = [:]
if let glob { arguments["glob"] = try MCPClientArgumentEncoder.encode(glob) }
if let headLimit { arguments["headLimit"] = try MCPClientArgumentEncoder.encode(headLimit) }
if let ignoreCase { arguments["ignoreCase"] = try MCPClientArgumentEncoder.encode(ignoreCase) }
if let linesAfter { arguments["linesAfter"] = try MCPClientArgumentEncoder.encode(linesAfter) }
if let linesBefore { arguments["linesBefore"] = try MCPClientArgumentEncoder.encode(linesBefore) }
if let linesContext { arguments["linesContext"] = try MCPClientArgumentEncoder.encode(linesContext) }
if let multiline { arguments["multiline"] = try MCPClientArgumentEncoder.encode(multiline) }
if let outputMode { arguments["outputMode"] = try MCPClientArgumentEncoder.encode(outputMode) }
if let path { arguments["path"] = try MCPClientArgumentEncoder.encode(path) }
arguments["pattern"] = try MCPClientArgumentEncoder.encode(pattern)
if let showLineNumbers { arguments["showLineNumbers"] = try MCPClientArgumentEncoder.encode(showLineNumbers) }
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
if let type { arguments["type"] = try MCPClientArgumentEncoder.encode(type) }
let text = try await proxy.callTool("XcodeGrep", arguments: arguments)
return try MCPClientResultDecoder.decode(XcodeGrepResponse.self, from: text)
}
/// Lists the currently known issues shown Xcode's Issue Navigator UI in the workspace. These issues include those that have been discovered since the last build, and also issues like package resolution problems and workspace configuration issues. You can filter the issues to include by file name, glob, or severity. Use this tool when you want to list all the users the user can see in the workspace UI.
/// - Parameter glob: Glob to filter the returned issues. Will match against the 'path' field.
/// - Parameter pattern: Regex to filter the returned issues. Will match against the 'message' field.
/// - Parameter severity: Limit the returned issues to those that have the specified severity or higher. Valid values in order of decreasing severity are 'error', 'warning', 'remark'. Defaults to 'error'.
/// - Parameter tabIdentifier: The workspace tab identifier
public func xcodeListNavigatorIssues(glob: String? = nil, pattern: String? = nil, severity: String? = nil, tabIdentifier: String) async throws -> XcodeListNavigatorIssuesResponse {
var arguments: JSONDictionary = [:]
if let glob { arguments["glob"] = try MCPClientArgumentEncoder.encode(glob) }
if let pattern { arguments["pattern"] = try MCPClientArgumentEncoder.encode(pattern) }
if let severity { arguments["severity"] = try MCPClientArgumentEncoder.encode(severity) }
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("XcodeListNavigatorIssues", arguments: arguments)
return try MCPClientResultDecoder.decode(XcodeListNavigatorIssuesResponse.self, from: text)
}
/// Lists the current Xcode windows and their workspace information
public func xcodeListWindows() async throws -> XcodeListWindowsResponse {
let text = try await proxy.callTool("XcodeListWindows")
return try MCPClientResultDecoder.decode(XcodeListWindowsResponse.self, from: text)
}
/// Lists files and directories in the Xcode project structure at the specified path. Works on Xcode project organization, not filesystem structure.
/// - Parameter ignore: Skip files/folders matching these patterns
/// - Parameter path: The project path to browse (e.g., 'ProjectName/Sources/')
/// - Parameter recursive: Recursively list all files (truncated to 100 lines). Default: true
/// - Parameter tabIdentifier: The workspace tab identifier
public func xcodeLs(ignore: [String]? = nil, path: String, recursive: Bool? = nil, tabIdentifier: String) async throws -> XcodeLSResponse {
var arguments: JSONDictionary = [:]
if let ignore { arguments["ignore"] = try MCPClientArgumentEncoder.encode(ignore) }
arguments["path"] = try MCPClientArgumentEncoder.encode(path)
if let recursive { arguments["recursive"] = try MCPClientArgumentEncoder.encode(recursive) }
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("XcodeLS", arguments: arguments)
return try MCPClientResultDecoder.decode(XcodeLSResponse.self, from: text)
}
/// Creates directories and groups in the Xcode project structure.
/// - Parameter directoryPath: Project navigator relative path for the directory to create
/// - Parameter tabIdentifier: The workspace tab identifier
public func xcodeMakeDir(directoryPath: String, tabIdentifier: String) async throws -> XcodeMakeDirResponse {
var arguments: JSONDictionary = [:]
arguments["directoryPath"] = try MCPClientArgumentEncoder.encode(directoryPath)
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("XcodeMakeDir", arguments: arguments)
return try MCPClientResultDecoder.decode(XcodeMakeDirResponse.self, from: text)
}
/// Moves or renames files and directories in the project navigator with support for filesystem operations.
/// - Parameter destinationPath: Project navigator relative path for the destination (for move) or new name (for rename)
/// - Parameter operation: The type of move operation to perform Values: move, copy
/// - Parameter overwriteExisting: Whether to overwrite existing files at the destination
/// - Parameter sourcePath: Project navigator relative path of the source item to move/rename
/// - Parameter tabIdentifier: The workspace tab identifier
public func xcodeMv(destinationPath: String, operation: String? = nil, overwriteExisting: Bool? = nil, sourcePath: String, tabIdentifier: String) async throws -> XcodeMVResponse {
var arguments: JSONDictionary = [:]
arguments["destinationPath"] = try MCPClientArgumentEncoder.encode(destinationPath)
if let operation { arguments["operation"] = try MCPClientArgumentEncoder.encode(operation) }
if let overwriteExisting { arguments["overwriteExisting"] = try MCPClientArgumentEncoder.encode(overwriteExisting) }
arguments["sourcePath"] = try MCPClientArgumentEncoder.encode(sourcePath)
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("XcodeMV", arguments: arguments)
return try MCPClientResultDecoder.decode(XcodeMVResponse.self, from: text)
}
/// Reads the contents of a file within the Xcode project organization. Returns content in cat -n format with line numbers. Supports reading up to 600 lines by default with optional offset and limit parameters for large files. Output is JSON-encoded e.g. backslashes, quotes, and newlines appear escaped (\\, \", \n). Account for this when interpreting file content.
/// - Parameter filePath: The path to the file within the Xcode project organization (e.g., 'ProjectName/Sources/MyFile.swift')
/// - Parameter limit: The number of lines to read (only provide if the file is too large to read at once)
/// - Parameter offset: The line number to start reading from (only provide if the file is too large to read at once)
/// - Parameter tabIdentifier: The workspace tab identifier
public func xcodeRead(filePath: String, limit: Double? = nil, offset: Double? = nil, tabIdentifier: String) async throws -> XcodeReadResponse {
var arguments: JSONDictionary = [:]
arguments["filePath"] = try MCPClientArgumentEncoder.encode(filePath)
if let limit { arguments["limit"] = try MCPClientArgumentEncoder.encode(limit) }
if let offset { arguments["offset"] = try MCPClientArgumentEncoder.encode(offset) }
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("XcodeRead", arguments: arguments)
return try MCPClientResultDecoder.decode(XcodeReadResponse.self, from: text)
}
/// Retrieves current compiler diagnostics (errors, warnings, notes) for a file in the Xcode project. Returns formatted diagnostic information including severity levels and messages.
/// - Parameter filePath: The path to the file within the Xcode project organization (e.g., 'ProjectName/Sources/MyFile.swift')
/// - Parameter tabIdentifier: The workspace tab identifier
public func xcodeRefreshCodeIssuesInFile(filePath: String, tabIdentifier: String) async throws -> XcodeRefreshCodeIssuesInFileResponse {
var arguments: JSONDictionary = [:]
arguments["filePath"] = try MCPClientArgumentEncoder.encode(filePath)
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("XcodeRefreshCodeIssuesInFile", arguments: arguments)
return try MCPClientResultDecoder.decode(XcodeRefreshCodeIssuesInFileResponse.self, from: text)
}
/// Removes files and directories from the Xcode project structure and optionally deletes the underlying files from the filesystem.
/// - Parameter deleteFiles: Also move the underlying files to Trash (defaults to true)
/// - Parameter path: The project path to remove (e.g., 'ProjectName/Sources/MyFile.swift')
/// - Parameter recursive: Remove directories and their contents recursively
/// - Parameter tabIdentifier: The workspace tab identifier
public func xcodeRm(deleteFiles: Bool? = nil, path: String, recursive: Bool? = nil, tabIdentifier: String) async throws -> XcodeRMResponse {
var arguments: JSONDictionary = [:]
if let deleteFiles { arguments["deleteFiles"] = try MCPClientArgumentEncoder.encode(deleteFiles) }
arguments["path"] = try MCPClientArgumentEncoder.encode(path)
if let recursive { arguments["recursive"] = try MCPClientArgumentEncoder.encode(recursive) }
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("XcodeRM", arguments: arguments)
return try MCPClientResultDecoder.decode(XcodeRMResponse.self, from: text)
}
/// Edits files in the Xcode project by replacing text content. Works on Xcode project structure paths, not filesystem paths. IMPORTANT: The tool will fail if filePath, oldString, or newString parameters are missing. Input oldString and newString use literal characters e.g. if XcodeRead shows \\d, use \d in parameters to match it.
/// - Parameter filePath: REQUIRED: The path to the file to modify within the Xcode project organization (e.g., 'ProjectName/Sources/MyFile.swift')
/// - Parameter newString: REQUIRED: The text to replace it with, must be different from oldString
/// - Parameter oldString: REQUIRED: The text to replace
/// - Parameter replaceAll: Replace all occurrences of oldString (default false)
/// - Parameter tabIdentifier: The workspace tab identifier
public func xcodeUpdate(filePath: String, newString: String, oldString: String, replaceAll: Bool? = nil, tabIdentifier: String) async throws -> XcodeUpdateResponse {
var arguments: JSONDictionary = [:]
arguments["filePath"] = try MCPClientArgumentEncoder.encode(filePath)
arguments["newString"] = try MCPClientArgumentEncoder.encode(newString)
arguments["oldString"] = try MCPClientArgumentEncoder.encode(oldString)
if let replaceAll { arguments["replaceAll"] = try MCPClientArgumentEncoder.encode(replaceAll) }
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("XcodeUpdate", arguments: arguments)
return try MCPClientResultDecoder.decode(XcodeUpdateResponse.self, from: text)
}
/// Creates or overwrites files with content in the Xcode project. Works on Xcode project structure paths, not filesystem paths. Automatically adds new files to the project structure. Both filePath and content parameters are required. Input content uses literal characters e.g. if XcodeRead shows \\d, use \d in the content parameter to write it.
/// - Parameter content: REQUIRED: The content to write to the file
/// - Parameter filePath: REQUIRED: The path to the file within the Xcode project organization (e.g., 'ProjectName/Sources/MyFile.swift')
/// - Parameter tabIdentifier: The workspace tab identifier (required)
public func xcodeWrite(content: String, filePath: String, tabIdentifier: String) async throws -> XcodeWriteResponse {
var arguments: JSONDictionary = [:]
arguments["content"] = try MCPClientArgumentEncoder.encode(content)
arguments["filePath"] = try MCPClientArgumentEncoder.encode(filePath)
arguments["tabIdentifier"] = try MCPClientArgumentEncoder.encode(tabIdentifier)
let text = try await proxy.callTool("XcodeWrite", arguments: arguments)
return try MCPClientResultDecoder.decode(XcodeWriteResponse.self, from: text)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment