Get the FREE Ultimate OpenClaw Setup Guide →

swift

🚀 Enhanced Swift MCP Server with Protocol-Oriented Programming Analysis and Architecture Detection

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio anhptimx-swift-mcp-server swift-mcp-server --transport stdio ${workspaceFolder} \
  --env SWIFT_MCP_MODE="vscode"

How to use

This Swift MCP server provides a production-ready Model Context Protocol (MCP) integration for Swift projects with dual transport (HTTP and STDIO) and a suite of analysis tools. It ships with a rich CLI and VS Code integration, enabling real-time architecture analysis, symbol search, reference tracking, and automated documentation generation. You can run the server in STDIO mode for seamless IDE integration or switch to HTTP to expose a production-grade API for external tooling. Use the available tools to analyze projects, map dependencies, and get guidance on performance and memory usage.

To connect from VS Code, configure the MCP extension to launch the server in STDIO mode and point it at your workspace. For production usage, start the HTTP server with a config file and a port, for example by running the server binary with --transport http and --port. The toolset includes core analyses like list_symbols, find_references, analyze_architecture, and generate_documentation, along with advanced features such as iOS framework analysis, dependency mapping, and performance analysis. These capabilities enable end-to-end project health checks and actionable recommendations right from your Swift projects.

How to install

Prerequisites:

  • Swift 5.9+ (Swift 6 compatible) installed on macOS or Linux
  • Xcode or Swift toolchain with swift build available
  • Basic familiarity with Swift Package Manager projects

Installation steps:

  1. Clone the repository: git clone https://github.com/your-username/swift-mcp-server.git cd swift-mcp-server
  2. Build the production binary: swift build --configuration release
  3. Verify installation and run the server (example for STDIO mode): ./swift-mcp.sh # or run the built binary directly

    Alternatively, run the binary explicitly

    ./.build/release/swift-mcp-server --help
  4. For HTTP API usage, start the server with an HTTP config and port, e.g.: ./.build/release/swift-mcp-server --config http-config.json --transport http --port 9000
  5. Optional: Set up VS Code integration using the provided swift-mcp.sh script or manual configuration as shown in the README.

Additional notes

Tips and common issues:

  • If you encounter Exit Code 64, ensure positional arguments are supported by your MCP extension and pass the workspace path as a positional argument.
  • Use the STDIO transport for tight IDE integration; for production, prefer HTTP transport with a proper config file and secure access.
  • The configuration supports environment variables to tailor behavior per environment (e.g., SWIFT_MCP_MODE for VS Code integration).
  • Regularly run health checks and tests via the included script (swift-mcp.sh) to verify integration points and tool availability.
  • Ensure the Swift toolchain is up-to-date to take advantage of Swift 6 concurrency features and improved performance.

Related MCP Servers

Sponsor this space

Reach thousands of developers ↗