MCP Catalogs
首页

swiftlens

by swiftlens·124·综合分 44

SwiftLens MCP 服务器通过 SourceKit-LSP 集成,让 AI 模型能以编译器级精度理解 Swift 代码库。

developer-toolsai-llmother
6
Forks
4
活跃 Issue
10 个月前
最近提交
2 天前
收录于

概述

SwiftLens 是一个专为 iOS/Swift 开发设计的专业 MCP 服务器。它通过直接集成 Apple 的 SourceKit-LSP,为 AI 代理和 Swift 代码库提供语义级分析,具有 Xcode 级别的精度。服务器提供 15 种不同的工具用于单文件和跨文件分析、符号导航和代码修改功能。它提供令牌优化的输出,以实现高效的 AI 交互,并能与标准 Swift 项目开箱即用,但需要索引存储进行跨文件分析。

试试问 AI

装完之后,这里有 3 个你可以让 AI 做的事:

:AI 辅助的 Swift 应用代码重构和现代化
:Swift 项目的深度代码分析和文档生成
:代码变更过程中的跨引用和影响分析

什么时候选它

当您使用Swift代码库并需要AI辅助进行代码分析、重构或文档生成,且需要编译器级精度时,选择SwiftLens。

什么时候不要选它

如果不使用Swift或macOS,请避免使用,因为SourceKit-LSP集成完全需要Apple的开发工具。

此 server 暴露的工具

从 README 抽取出 12 个工具
  • swift_analyze_file

    Analyze structure and symbols in a Swift file

  • swift_analyze_multiple_files

    Batch analyze multiple Swift files

  • swift_summarize_file

    Get symbol counts and file summary

  • swift_get_symbols_overview

    Extract top-level type declarations

  • swift_get_declaration_context

    Get fully-qualified symbol paths

  • swift_get_file_imports

    Extract import statements

  • swift_validate_file

    Validate syntax and types with swiftc

  • swift_check_environment

    Verify Swift development setup

  • swift_build_index

    Build index store for current project

  • swift_find_symbol_references

    Find all references to a symbol

  • swift_get_symbol_definition

    Jump to symbol definition

  • swift_get_hover_info

    Get type info and documentation

可对比工具

sourcekit-lsp-mcpswift-analyzer-mcpxcode-mcp

安装

安装

前置条件

  • macOS(SourceKit-LSP 需要)
  • Python 3.10+
  • Xcode(从 App Store 完整安装)

快速开始

为 Claude Code / Gemini CLI 配置

添加到您的 JSON 配置文件的 mcpServers 部分:

{
  "mcpServers": {
    "swiftlens": {
      "command": "uvx",
      "args": ["swiftlens"]
    }
  }
}
构建 SourceKit LSP 索引

SwiftLens 需要索引存储进行跨文件分析。使用以下命令构建:

# 导航到您的 Swift 项目
cd /path/to/your/swift/project

# 使用索引构建
swift build -Xswiftc -index-store-path -Xswiftc .build/index/store

**重要**:当您添加新的 Swift 文件、更改公共接口或发现缺少符号引用时,需要重新构建索引。

swiftlens 对比

GitHub →

最后更新于 · 由 README + GitHub 公开数据自动生成。