swiftlens

作者 swiftlens已验证

SwiftLens is a Model Context Protocol (MCP) server that provides deep, semantic-level analysis of Swift codebases to any AI models. By integrating directly with Apple's SourceKit-LSP, SwiftLens enables AI models to understand Swift code with compiler-grade accuracy.

125
Stars
7
Forks
Python
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/swiftlens/swiftlens

快速入门

使用 swiftlens 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

MseeP.ai Security Assessment Badge

SwiftLens: First MCP Server that provides Semantic-Lelvel Analysis for iOS/Swift Development

SwiftLens is a Model Context Protocol (MCP) server that provides deep, semantic-level analysis of Swift codebases to AI agents. By integrating directly with Apple's SourceKit-LSP, SwiftLens enables AI models to understand Swift code with compiler-grade accuracy.

Features

SwiftLens bridges AI models and Swift development through:

AI Agent (Claude/GPT) → MCP Protocol → SwiftLens → SourceKit-LSP → Swift Code

Core Capabilities

  • LSP-Powered Semantic Analysis: Leverages SourceKit-LSP for Xcode-grade accuracy
  • Token-Optimized Output: Minimizes token usage for AI interactions
  • Real-time Code Understanding: Analyzes Swift files with full language feature support
  • Cross-file Navigation: Symbol references, definitions, and project-wide analysis
  • Code Modification Tools: Safe, atomic file operations for AI-driven refactoring
  • Zero Configuration: Works out-of-the-box with standard Swift projects

Supported Swift Features

  • Modern Swift syntax (actors, async/await, property wrappers, result builders)
  • Generic types and protocols
  • Swift Package Manager and Xcode projects
  • Unicode identifiers and symbols
  • Complex nested types and extensions

Installation

Prerequisites

  • macOS (required for SourceKit-LSP)
  • Python 3.10+
  • Xcode (full installation from App Store, not just Command Line Tools)

Quick Start

Configure for Claude Code / Gemini CLI

Add to your json configuration file mcpServers section:

{
  "mcpServers": {
    "swiftlens": {
      "command": "uvx",
      "args": ["swiftlens"]
    }
  }
}

SourceKit LSP Index

SwiftLens will need proper sourcekit-lsp index in order to work properly you can either

Ask AI to build your index

"hey claude, run swift_build_index tool"

Building Your Project Index Manually

SwiftLens requires an index store for cross-file analysis. Build it with:

# Navigate to your Swift project
cd /path/to/your/swift/project

# Build with index store
swift build -Xswiftc -index-store-path -Xswiftc .build/index/store

Important: Rebuilding of the index is required when you:

  • Add new Swift files
  • Change public interfaces
  • Notice missing symbol references

Available Tools

SwiftLens provides 15 tools for Swift code analysis:

Single-File Analysis (No Index Required)

  • swift_analyze_file - Analyze structure and symbols in a Swift file
  • swift_analyze_multiple_files - Batch analyze multiple 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 db of current project for sourcekit-lsp

Cross-File Analysis (Requires Index)

  • 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

Code Modification

  • swift_replace_symbol_body - Replace function/type body

Utilities

  • swift_search_pattern - Search with regex patterns
  • get_tool_help - Get help for any tool

Example Usage

Ask your AI agent:

"Analyze the UserManager.swift file and find all references to the login() method"

The AI will use SwiftLens tools to:

  1. Analyze the file structure
  2. Locate the login method
  3. Find all project-wide references
  4. Provide insights based on the analysis

Real-time Dashboard (CURRENT NOT WORKING, REWORK IMPLEMENTATION PLANNED)

SwiftLens includes a web dashboard for monitoring AI interactions:

  • URL: http://localhost:53729 (when server is running)
  • Features: Live tool execution logs, usage analytics, session tracking
  • Security: Localhost-only access, no external connections

Troubleshooting

"Symbol not found" or "No references found"

Rebuild your index:

swift build -Xswiftc -index-store-path -Xswiftc .build/index/store

New files not recognized

New files need to be indexed:

swift build -Xswiftc -index-store-path -Xswiftc .build/index/store

SourceKit-LSP not found

Ensure Xcode is properly installed:

xcode-select -p  # Should show Xcode path
xcrun sourcekit-lsp --help  # Should show help text

SourceKit-LSP Limitations

Known SourceKit-LSP Limitations

The SwiftLens MCP Server accurately reflects SourceKit-LSP's capabilities. The following are known limitations of SourceKit-LSP itself, not bugs in this tool:

Hover Information

  • Limited support for local variables: Hover info may not be available for local variables within function bodies
  • Property access issues: Expressions like object.property often don't provide hover information when inside functions
  • Method call limitations: Hover on method calls with parameters may return incorrect or no information
  • Success rate: Hover typically works well for type declarations, method signatures, and top-level symbols, but has approximately 44% success rate for expressions within function bodies

These limitations exist because SourceKit-LSP:

  • Does not perform background indexing
  • May skip function body analysis in certain configurations
  • Is still in early development with acknowledged "rough edges"

For the most up-to-date status, see the SourceKit-LSP repository.

Development

Running Tests

# All tests
make test

# Unit tests only (fast, no LSP required)
make test-unit

# LSP integration tests
make test-lsp

# Check environment
make check-env

Code Quality

# Format code
./format.sh

# Check formatting
./format.sh check

License - FULLY AVAILABLE TO YOU FOR FREE (PERSONAL USE ONLY UNDER LICENSE)

  • ✅ Free for personal use and evaluation
  • ⚠️ Commercial use requires a license

See LICENSE.md for details.

Contributing

We welcome contributions! Areas where you can help:

  • 🐛 Bug reports and fixes
  • 📝 Documentation improvements
  • 🧪 Test coverage expansion
  • 🔧 New analysis capabilities

Support


SwiftLens - Bringing compiler-grade Swift understanding to AI development

常见问题

What is swiftlens?

swiftlens is an open-source mcp servers skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by swiftlens. SwiftLens is a Model Context Protocol (MCP) server that provides deep, semantic-level analysis of Swift codebases to any AI models. By integrating directly with Apple's SourceKit-LSP, SwiftLens enables AI models to understand Swift code with compiler-grade accuracy. It has 125 GitHub stars.

Is swiftlens safe to use?

Yes. swiftlens passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install swiftlens?

Clone the repository with "git clone https://github.com/swiftlens/swiftlens" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is swiftlens written in?

swiftlens is primarily written in Python. It is open-source under swiftlens on GitHub, so you can review or fork the full source.

Are there alternatives to swiftlens?

Yes. SkillsLLM lists many other MCP Servers skills you can browse and compare side by side. Open the MCP Servers category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh swiftlens against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

Scrapling

by D4Vinci

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

75,9137,581Python
MCP 服务器
查看详情

TrendRadar

by sansan0

⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。

61,65224,883Python
MCP 服务器
查看详情

context7

by upstash

Context7 Platform -- Up-to-date code documentation for LLMs and AI code editors

61,0602,938TypeScript
MCP 服务器
查看详情

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

39,9393,219C
MCP 服务器
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情