Skip to main content
Glama
xcode-analyzer-mcp

xcode-analyzer-mcp

by sunny-maeng

detect_retain_cycles

Detect potential memory leaks and retain cycles in Swift code by finding missing [weak self], strong delegates, Timer and NotificationCenter leaks, and strong ViewModel–ViewController references.

Instructions

Detect potential memory leaks and retain cycles in Swift code. Finds: missing [weak self] in closures, strong delegates, Timer retain cycles, NotificationCenter leaks, ViewModel↔ViewController strong references, and stored closure properties.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "projectPath": "<projectPath>"
    },
    "name": "detect_retain_cycles"
  }
}

Input Schema

NameRequiredDescriptionDefault
projectPathYesPath to the Xcode project root directory
targetPathsNoSpecific files/directories to analyze (default: entire project)
excludePatternsNoGlob patterns to exclude

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are supplied, so the description carries the full behavioral burden. It usefully discloses the behavioral scope by naming the six specific defect classes it looks for, which is real information beyond the schema. However, it never states that the analysis is read-only and non-mutating, nor what a finding contains or whether false positives are expected.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with zero waste: the purpose is front-loaded and the detail sentence is a tight, scannable list of detectable patterns. Nothing is repeated and no filler appears.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no annotations and no output schema, the description must cover both safety profile and result shape, and it covers only the former partially. An agent knows what is detected but not what comes back or whether the tool only reports versus acts. For a static-analysis tool this is workable but leaves a real gap on return values.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all three parameters (projectPath, targetPaths, excludePatterns) are already documented in the schema. The description adds nothing about path semantics, scoping behavior, or how exclusions interact with targeted paths. Baseline 3 is appropriate when the schema does the work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource ('Detect potential memory leaks and retain cycles in Swift code') and then enumerates the exact patterns it flags, from missing [weak self] to stored closure properties. That enumeration makes the tool's scope unambiguous. It stops short of explicitly distinguishing itself from the sibling fix_retain_cycles, relying on the 'detect' vs 'fix' naming to carry that distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is only implied: an agent can infer it should run this on Swift code to surface leak candidates. There is no statement of when to prefer this over fix_retain_cycles, no prerequisites (e.g., that the path must be an Xcode project root), and no mention of when this analysis is inappropriate or redundant.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.