XCF (Xcode MCP Server) is a powerful Swift-based automation tool designed to streamline Xcode project management for AI assistants. This guide provides comprehensive instructions for integrating XCF into AI-powered development workflows.
Add XCF to your MCP configuration file with the following JSON:
{
"mcpServers": {
"xcf": {
"type": "stdio",
"command": "/Applications/xcf.app/Contents/MacOS/xcf server"
}
}
}- Cursor:
~/.cursor/mcp.json - Claude Desktop:
~/Library/Application Support/Claude/claude_desktop_config.json
For project-specific control, use environment variables:
{
"mcpServers": {
"xcf": {
"type": "stdio",
"command": "/Applications/xcf.app/Contents/MacOS/xcf server",
"env": {
"XCODE_PROJECT_FOLDER": "/path/to/project/",
"XCODE_PROJECT": "/path/to/project/project.xcodeproj"
}
}
}
}XCF provides a rich set of tools for AI assistants:
| Tool | Purpose | Example Usage |
|---|---|---|
mcp_xcf_xcf |
Execute XCF actions | mcp_xcf_xcf(action="build") |
mcp_xcf_snippet |
Extract code snippets | mcp_xcf_snippet(filePath="main.swift", entireFile=true) |
mcp_xcf_analyzer |
Analyze Swift code | mcp_xcf_analyzer(filePath="main.swift", entireFile=true) |
mcp_xcf_read_file |
Read file contents | mcp_xcf_read_file(filePath="main.swift") |
mcp_xcf_write_file |
Write file contents | mcp_xcf_write_file(filePath="test.txt", content="Hello World") |
In addition to the general-purpose tools, XCF now provides dedicated tools for each action:
| Tool | Purpose | Example Usage |
|---|---|---|
mcp_xcf_show_help |
Display help information | mcp_xcf_show_help() |
mcp_xcf_grant_permission |
Grant Xcode permissions | mcp_xcf_grant_permission() |
mcp_xcf_run_project |
Run the current project | mcp_xcf_run_project() |
mcp_xcf_build_project |
Build the current project | mcp_xcf_build_project() |
mcp_xcf_show_current_project |
Show selected project | mcp_xcf_show_current_project() |
mcp_xcf_show_env |
Display environment variables | mcp_xcf_show_env() |
mcp_xcf_show_folder |
Show current directory | mcp_xcf_show_folder() |
mcp_xcf_list_projects |
List all Xcode projects | mcp_xcf_list_projects() |
mcp_xcf_select_project |
Select a project by number | mcp_xcf_select_project(projectNumber=1) |
mcp_xcf_analyze_swift_code |
Analyze Swift code | mcp_xcf_analyze_swift_code(filePath="main.swift") |
# Activate XCF
use_xcf
# List and select project
show
open 1
# Build and run
build
run
# Activate XCF
use_xcf
# Get current project
current
# Extract and analyze code
snippet main.swift
analyzer main.swift
# Implement fixes
edit_file main.swift 10 20 "# Improved implementation"
# Rebuild
build
XCF uses intelligent path resolution for file operations:
- Exact path provided
- Relative path from current directory
- Current project directory
- Workspace folder
- Recursive workspace search
- Fuzzy filename matching
# These are equivalent
mcp_xcf_snippet(filePath="/full/path/to/file.swift")
mcp_xcf_snippet(filePath="file.swift") # Smart resolutionThe Swift code analyzer provides:
- Code style checks
- Complexity analysis
- Unused variable detection
- Magic number identification
- Refactoring suggestions
- Method length evaluation
# Analyze entire file
mcp_xcf_analyzer(filePath="main.swift", entireFile=true)
# Analyze specific line range
mcp_xcf_analyzer(
filePath="main.swift",
startLine=10,
endLine=50
)- Workspace-bound operations
- Automatic access prevention outside workspace
- Environment variable-based security
- Safe redirection of potentially unsafe actions
- Use specific file paths when possible
- Leverage smart path resolution
- Utilize line-range analysis for large files
- Prefer MCP function tools for programmatic interactions
- Always activate XCF before operations
- Use environment variables for project configuration
- Leverage smart path resolution
- Implement error handling
- Use code analysis before major changes
Refer to the User Guide for a complete list of available tools and their detailed usage.
| Action | Description | Example | Purpose |
|---|---|---|---|
grant |
Grant Xcode automation permissions | mcp_xcf_xcf(action="grant") |
Authorize XCF to interact with Xcode |
show |
List open projects | mcp_xcf_xcf(action="show") |
Display available Xcode projects |
open # |
Select project by number | mcp_xcf_xcf(action="open 1") |
Choose a specific project to work on |
current |
Show selected project | mcp_xcf_xcf(action="current") |
Display the currently active project |
build |
Build current project | mcp_xcf_xcf(action="build") |
Compile the selected Xcode project |
run |
Run current project | mcp_xcf_xcf(action="run") |
Execute the current project |
env |
Show environment variables | mcp_xcf_xcf(action="env") |
Display system environment configuration |
pwd |
Show current folder | mcp_xcf_xcf(action="pwd") |
Display current working directory |
analyze |
Analyze Swift code | mcp_xcf_xcf(action="analyze main.swift") |
Perform code analysis on a file |
lz |
Shorthand for analyze | mcp_xcf_xcf(action="lz main.swift") |
Quick code analysis |
# Full project lifecycle management
mcp_xcf_xcf(action="grant") # Authorize XCF
mcp_xcf_xcf(action="show") # List projects
mcp_xcf_xcf(action="open 1") # Select first project
mcp_xcf_xcf(action="current") # Confirm project
mcp_xcf_xcf(action="build") # Build project
mcp_xcf_xcf(action="run") # Run project
# Code analysis workflow
mcp_xcf_xcf(action="analyze main.swift") # Detailed analysis
mcp_xcf_xcf(action="lz main.swift") # Quick analysis
# Check environment and context
mcp_xcf_xcf(action="env") # Show environment variables
mcp_xcf_xcf(action="pwd") # Show current working directorySome commands have convenient aliases:
pwdcan also usedirorpathlzis a quick shorthand foranalyze
XCF intelligently handles actions by:
- Automatically selecting the most recent project
- Providing fallback mechanisms
- Offering clear, actionable feedback
- Supporting relative and absolute paths
Pro Tip: Always use grant first to ensure full XCF functionality!
Created by XCodeFreeze Automation - Empowering AI-driven Swift development!