Token导航 LogoToken导航TokenDH.com
Swift Developer MCP Server logo
开发工具未说明官方级别未说明来源级核验

Swift Developer MCP Server

MCP Server

A Local MCP server useful for Cross Platform Swift Development

工具数

0

提示词数

0

GitHub Stars

4

资源数

0
Swift调试工具ClaudeClaude DesktopClaudeCursorWindsurf

安装说明

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

作者 / 组织

edgeengineer

提供方

edgeengineer

最后核验

2026/5/18 04:03

快速接入

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

详细介绍

Swift开发人员MCP服务器

一个全面的模型上下文协议(MCP)服务器,为macOS和Linux环境提供Swift开发工具、调试功能和项目管理功能。该服务器使AI助手能够与Swift项目、构建系统和开发工具进行交互。

特性

🔨 构建和测试工具

  • swift_build -使用配置选项(调试/发布、特定目标、详细输出)构建Swift项目
  • swift_test -使用过滤、并行执行控制和详细输出运行Swift测试
  • run_target -使用自定义参数执行特定的Swift目标

🐛 调试工具

  • debug_start -启动Swift目标的调试会话
  • debug_set_breakpoint -使用可选条件设置断点
  • debug_step -遍历代码(over、into、out)
  • debug_continue -继续执行,直到下一个断点
  • debug_inspect_variable -检查变量并计算表达式

📦 Swift包管理

  • get_package_info -获取全面的Swift包信息和依赖关系
  • print_dependency_public_api -提取并显示任何依赖项的公共API

🔧 快速工具链管理

  • swiftly_install -从不同渠道安装Swift工具链
  • swiftly_list -列出已安装的Swift工具链
  • swiftly_list_available -列出要安装的可用Swift版本
  • swiftly_use -在全球或每个项目之间切换Swift版本
  • swiftly_run -使用特定Swift版本运行命令
  • swiftly_uninstall -删除Swift工具链

📊 资源

  • swift://project/info -当前项目信息和结构
  • swift://build/status -构建状态和历史
  • swift://debug/sessions -活动调试会话和断点

💡 鼓励

  • swift_debug_session -指导调试会话设置,并提供针对特定目标的建议
  • swift_build_analysis -智能构建错误分析和解决方案建议

安装

先决条件

  1. 迅速的:安装Swift 5.9+或使用 迅速地 用于版本管理
  2. macOS或Linux:此服务器支持macOS和Linux环境
  3. 制造:用于使用方便的构建目标

快速设置

  1. 克隆存储库:
   git clone https://github.com/edgeengineer/swift-developer-mcp-server.git
   cd swift-developer-mcp-server
  1. 构建并获取路径 (自动复制到剪贴板):
   make path

这将:

- ✅ 以发布模式构建服务器 - ✅ 显示可执行文件路径 - ✅ 将路径复制到剪贴板 - ✅ 显示流行AI客户端的配置示例

其他目标

make build    # Build the server in release mode
make clean    # Clean build artifacts
make install  # Install to /usr/local/bin
make help     # Show all available targets

AI客户端的配置

光标

添加到光标设置(.cursor-settings/settings.json):

{
  "mcp": {
    "servers": {
      "swift-developer": {
        "command": "PASTE_PATH_FROM_CLIPBOARD_HERE",
        "args": [],
        "env": {}
      }
    }
  }
}

帆板运动

添加到您的Windsurf配置(.windsurf/mcp_servers.json):

{
  "servers": {
    "swift-developer": {
      "command": "PASTE_PATH_FROM_CLIPBOARD_HERE",
      "args": [],
      "env": {}
    }
  }
}

克劳德桌面

添加到您的Claude Desktop配置中:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Linux: ~/.config/claude/claude_desktop_config.json
{
  "mcpServers": {
    "swift-developer": {
      "command": "PASTE_PATH_FROM_CLIPBOARD_HERE",
      "args": [],
      "env": {}
    }
  }
}

克劳德代码(终端应用程序)

添加到您的Claude Code配置中(在终端应用程序中):

claude mcp add swift-developer PASTE_PATH_FROM_CLIPBOARD_HERE

克劳德代码(VS代码扩展)

添加到您的VS代码设置(.vscode/settings.json):

{
  "claude-dev.mcpServers": {
    "swift-developer": {
      "command": "PASTE_PATH_FROM_CLIPBOARD_HERE",
      "args": [],
      "env": {}
    }
  }
}
💡 专业提示:运行 make path 准备为每个客户端复制配置示例!

使用示例

构建Swift项目

Use the swift_build tool to build the current project in release mode with verbose output.

运行测试

Use the swift_test tool to run all tests in parallel with verbose output.

启动调试会话

Use the swift_debug_session prompt to set up debugging for the "MyApp" target, focusing on the "ViewController.swift" file.

管理Swift版本

Use swiftly_list to see installed Swift versions, then swiftly_use to switch to Swift 5.9.

提取依赖API

Use print_dependency_public_api with dependency_name "Alamofire" to see the public API of the Alamofire dependency.

获取项目信息

Access the swift://project/info resource to see the current project structure and Package.swift contents.

发展

项目结构

swift-developer-mcp-server/
├── Package.swift                 # Swift Package Manager configuration
├── Makefile                     # Build automation and convenience targets
├── Sources/
│   ├── main.swift               # Server entry point and MCP handler setup
│   ├── Utilities.swift          # Common types and helper functions
│   ├── BuildTestTools.swift     # Swift build and test tools
│   ├── DebugTools.swift         # Debug session management and tools
│   ├── PackageInfoTools.swift   # Swift package information tools
│   ├── SwiftlyTools.swift       # Swiftly toolchain management
│   ├── Resources.swift          # MCP resources (project info, build status, etc.)
│   └── Prompts.swift            # MCP prompts (debug session, build analysis)
└── README.md                    # This file

添加新工具

  1. 在相应的模块文件中定义工具结构:

- BuildTestTools.swift 用于构建和测试功能 - DebugTools.swift 用于调试功能 - PackageInfoTools.swift 用于包管理 - SwiftlyTools.swift 用于工具链管理 - 如果需要,为其他类别创建一个新模块

  1. 将工具添加到 ListTools 处理程序在 main.swift
  2. 将工具的句柄方法添加到 CallTool switch语句
  3. 重建服务器

测试

您可以通过运行服务器并发送JSON-RPC消息来手动测试服务器:

swift run SwiftDeveloperMCPServer

然后通过stdin发送初始化和工具调用消息。

需求

  • macOS 13.0+Linux (Ubuntu 20.04+,其他支持Swift的发行版)
  • Swift 5.9+
  • 制造 (用于构建目标)
  • Xcode命令行工具 (仅限macOS)

贡献

  1. 分叉存储库
  2. 创建要素分支
  3. 进行更改
  4. 如果适用,添加测试
  5. 提交拉取请求

许可证

此项目根据Apache 2.0许可证获得许可。有关详细信息,请参阅LICENSE文件。

故障排除

常见问题

  1. “找不到命令”:

- 跑 make path 重建并获得正确的路径 - 确保AI客户端配置中的路径与输出匹配

  1. “权限被拒绝”:确保可执行文件具有适当的权限:
   chmod +x .build/release/SwiftDeveloperMCPServer
   # Or simply run 'make path' which handles this automatically
  1. Swift版本冲突:使用 swiftly 如果你有多个安装,可以管理Swift版本。
  1. 构建失败:

- 确保您拥有最新的Xcode命令行工具(macOS):

     xcode-select --install

- 这 make path 命令将显示详细的构建错误(如果发生)

  1. 配置问题:The make path 该命令为所有受支持的AI客户端提供了可复制的配置示例。

调试服务器

要调试服务器本身,您可以将日志记录添加到 main.swift 文件或使用详细的Swift输出运行它:

swift run -v SwiftDeveloperMCPServer

使用ExampleLib进行测试

存储库包括 ExampleLib/,一个完整的Swift包,带有异步斐波那契计算,非常适合测试MCP服务器的调试能力。

构建和运行ExampleLib

导航到ExampleLib目录并使用标准Swift命令:

cd ExampleLib

# Build the library and executable
swift build

# Run the demo application
swift run ExampleApp

# Run tests
swift test

使用MCP服务器调试工具进行测试

ExampleLib项目为MCP服务器的调试功能提供了一个很好的测试平台。以下是如何测试完整的调试工作流程:

1.基本构建和测试

使用MCP服务器工具构建和测试:

Use swift_build tool with:
- target: "ExampleApp" 
- project_path: "/path/to/swift-developer-mcp-server/ExampleLib"
- configuration: "debug"
- verbose: true

Use swift_test tool with:
- project_path: "/path/to/swift-developer-mcp-server/ExampleLib"
- verbose: true

2.调试会话设置

启动ExampleApp的调试会话:

Use debug_start tool with:
- target: "ExampleApp"
- project_path: "/path/to/swift-developer-mcp-server/ExampleLib"
- arguments: [] (optional)

这将:

  • 构建ExampleApp目标
  • 启动LLDB会话
  • 加载可执行文件进行调试

3.设置断点

设置策略断点以检查斐波那契计算:

Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Sources/ExampleApp/main.swift"
- line_number: 89 (in performanceTest function)
- session_id: "your_session_id"

Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Sources/ExampleLib/FibonacciCalculator.swift" 
- line_number: 37 (inside calculate method)
- session_id: "your_session_id"

4.运行和遍历代码

# Start execution
Use debug_continue tool with:
- session_id: "your_session_id"

# Step through code when breakpoint hits
Use debug_step tool with:
- session_id: "your_session_id"
- step_type: "over" (or "into", "out")

5.检查变量和参与者状态

FibonacciCalculator是一个actor,非常适合测试异步调试:

# Inspect the calculator actor
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- variable_name: "calculator"

# Inspect specific values
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- variable_name: "result"

# Evaluate expressions
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- expression: "await calculator.getCalculationCount()"

6.测试并发操作

ExampleLib包含并发斐波那契计算,非常适合测试异步操作的调试:

# Set breakpoint in concurrent calculation method
Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Sources/ExampleLib/FibonacciCalculator.swift"
- line_number: 57 (in calculateMultiple method)
- session_id: "your_session_id"

# Inspect concurrent task state
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- variable_name: "tasks"

7.缓存行为分析

在异步执行器中测试调试缓存行为:

# Set conditional breakpoint for cache hits
Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Sources/ExampleLib/FibonacciCalculator.swift"
- line_number: 19 (cache hit check)
- condition: "cached != nil"
- session_id: "your_session_id"

# Inspect cache state
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- expression: "await calculator.getCacheState()"

8.测试Swift测试框架

ExampleLib使用Swift测试框架。测试调试测试执行:

# Build and run tests with debugging
Use debug_start tool with:
- target: "ExampleLibTests"
- project_path: "/path/to/ExampleLib"

# Set breakpoints in test methods
Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Tests/ExampleLibTests/FibonacciCalculatorTests.swift"
- line_number: 15 (in testBasicCalculations)
- session_id: "your_session_id"

9.调试中的性能测试

通过调试测试性能测试功能:

# Set breakpoint in performance test
Use debug_set_breakpoint tool with:
- file_path: "/path/to/ExampleLib/Sources/ExampleApp/main.swift"
- line_number: 95 (inside performanceTest)
- session_id: "your_session_id"

# Inspect timing variables
Use debug_inspect_variable tool with:
- session_id: "your_session_id"
- variable_name: "totalTime"

10.会话清理

完成后始终清理调试会话:

Use debug_terminate tool with:
- session_id: "your_session_id"

预期的调试场景

ExampleLib提供了以下调试场景:

  1. 演员状态检查:调试异步参与者状态和并发访问
  2. 缓存行为:实时查看缓存命中/未命中
  3. 递归计算:逐步完成递归斐波那契计算
  4. 并行操作:调试多个同时进行的计算
  5. 错误处理:错误条件的测试调试
  6. 性能瓶颈:识别慢速计算路径
  7. 测试执行:调试Swift测试框架测试

调试输出示例

调试ExampleLib时,您应该看到:

Debug session started successfully.
Session ID: debug_12345678-1234-1234-1234-123456789abc
Target: ExampleApp
Executable: /path/to/ExampleLib/.build/debug/ExampleApp

Breakpoint set successfully.
File: /path/to/ExampleLib/Sources/ExampleApp/main.swift
Line: 89

Debug execution continued.
Session: debug_12345678-1234-1234-1234-123456789abc
Command: process launch
Running: true

Variable inspection results.
Session: debug_12345678-1234-1234-1234-123456789abc
Target: calculator

这种全面的测试方法验证了:

  • 真正的LLDB集成
  • Swift actor调试
  • 并发代码调试
  • 断点管理
  • 计量检验
  • 会话生命周期管理

支持

对于问题和功能请求,请在GitHub存储库上打开问题。

目录标签

目录标签

Swift调试工具Claudedeveloper-tools本地部署Swift开发项目管理AI集成构建系统

支持客户端

Claude DesktopClaudeCursorWindsurf

接入字段

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

未说明

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

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

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

0

权限和风险

未说明none部署方式未说明

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

安装前确认

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

仍需确认:installCommand

来源信息

继续浏览同类 MCP