claude-xcindex

Tools reference

Every tool lives under the mcp__xcindex__* MCP namespace. You won’t usually call them by name — the plugin’s skills trigger them from natural-language questions — but this page documents the surface for anyone building automations, writing their own skills, or debugging.

All tools accept the same projectPath / indexStorePath pair for locating the index; the section below covers those once and the per-tool sections don’t repeat them.

Locating the index

Every tool needs to find the Index.noindex/DataStore directory somehow. Three ways to tell it which:

Use status first if you don’t know the path.


find_symbol

Look up candidate symbols by name. Use this first when multiple symbols might share the name (overloads, types in different modules, methods with the same base name on different types).

Input

Output — array of:

{
  "usr": "s:9MyApp11UserServiceC",
  "name": "UserService",
  "kind": "class",
  "language": "swift",
  "definitionPath": "/Users/me/MyApp/Sources/UserService.swift",
  "definitionLine": 3
}

The usr is the input for every other tool in this list.


find_references

Find every occurrence of a symbol: definitions, declarations, references, calls, reads, writes, and overrides.

Input

Output — array of:

{
  "usr": "s:9MyApp11UserServiceC9fetchUser2idSSSgSS_tF",
  "symbolName": "fetchUser(id:)",
  "path": "/Users/me/MyApp/Sources/AppDelegate.swift",
  "line": 9,
  "column": 22,
  "roles": ["reference", "call"]
}

Results are deduplicated by (path, line, column) and sorted by path, then line, then column.


find_definition

Given a USR, return the single canonical definition site. Falls back to a declaration if no non-system definition exists.

Input

Output — one occurrence (same shape as find_references entries) or null if not found.


find_overrides

Given a method’s USR, find all overriding implementations in subclasses. Essential before changing a method signature.

Input

Output — array of occurrences (same shape as find_references).


find_conformances

Given a Swift protocol’s USR, find all types that conform to it.

Input

Output — array of occurrences, each at the conforming type’s definition site.

Note. Swift’s index does not record a direct class→protocol relation — conformance is stored as per-method .overrideOf relations on each witness. The tool traverses that correctly, but it means conformances added via an extension will appear anchored at the extended type’s original definition, not the extension.


blast_radius

Given a source file, return the minimal set of other files that depend on it:

Use before editing a shared utility to know which tests to run and which files to re-read.

Input

Output

{
  "affectedFiles": ["/.../AppDelegate.swift", "/.../CanaryTests.swift"],
  "directDependents": ["/.../AppDelegate.swift", "/.../CanaryTests.swift"],
  "coveringTests": ["/.../CanaryTests.swift"]
}

Note that affectedFilesdirectDependents and coveringTestsaffectedFiles.


status

Report index freshness. Use as a first call at session start, or when you suspect the index is stale.

Input — only the location fields (projectPath or indexStorePath).

Output

{
  "indexStorePath": "/Users/.../DerivedData/MyApp-.../Index.noindex/DataStore",
  "indexMtime": "2026-04-19T09:22:31Z",
  "staleFileCount": 0,
  "staleFiles": [],
  "summary": "Index store found at … (last modified 2026-04-19T09:22:31Z)."
}

The per-session stale-file tracking lives in the SessionStart and PostToolUse hooks, not in this tool’s return — status reports index health, the hooks report live edits.


plan_rename

Build a semantic rename plan for a symbol identified by USR. Returns every reference site (including overrides) grouped by confidence tier so the caller can decide what to auto-apply versus flag for review. Never mutates files — the JSON plan is an input for subsequent Edit calls.

Input

{
  "usr": "s:7MyApp11UserServiceC",
  "newName": "AccountService",
  "projectPath": "/Users/me/MyApp/MyApp.xcodeproj"
}

indexStorePath also accepted. projectPath is strongly recommended because sourcekit-lsp’s reconciliation pass needs a workspace root.

Output — a pretty-printed JSON plan wrapped in a ```json code fence:

{
  "usr": "s:7MyApp11UserServiceC",
  "oldName": "UserService",
  "newName": "AccountService",
  "generatedAt": "2026-04-20T06:13:12Z",
  "indexFreshness": { "lastBuilt": null, "filesEditedThisSession": 0 },
  "ranges": [
    {
      "path": "/Users/…/UserService.swift",
      "line": 10,
      "column": 7,
      "endColumn": 18,
      "tier": "green-verified",
      "reasons": ["direct_reference"],
      "source": "indexstore"
    }
  ],
  "summary": {
    "green_verified": 5,
    "green_indexstore": 2,
    "yellow_disagreement": 0,
    "yellow_lsp_only": 1,
    "red_stale": 0
  },
  "refusal": null,
  "warnings": [],
  "truncated": false
}

ranges is capped by the maxRanges argument (default 500, max 5000). When capped, truncated is true and summary still reflects the full counts — re-invoke with a larger maxRanges to page through the rest.

Column encoding

For source: "indexstore" ranges, column and endColumn are 1-indexed UTF-8 byte columns (IndexStoreDB native). For source: "sourcekit-lsp" ranges — only emitted at the yellow-lsp-only tier today — they are 1-indexed UTF-16 code units (LSP native). The two coincide for pure-ASCII lines. Lines containing non-ASCII content need manual verification before a byte-oriented edit; yellow-lsp-only already flags that requirement and reasons carries sourcekit_lsp_only so the provenance is discoverable inside the plan itself.

Tiers

Tier Meaning
green-verified Indexstore and sourcekit-lsp agree — safe to auto-apply.
green-indexstore Indexstore-only match; LSP not consulted or returned empty.
yellow-disagreement Indexstore and LSP disagree, or range end unverifiable.
yellow-lsp-only LSP found this range but indexstore didn’t (macro sites).
red-stale File was edited this session — rebuild before trusting.

Refusals

When the request can’t produce a safe plan, refusal is populated with {reason, message, remediation}. Known reasons:

Range reasons

Each range carries one or more reasons tagging how the occurrence was classified. Known codes:

Warnings

warnings collects non-fatal diagnostics that describe degraded reconciliation. Common codes:

Run ./bin/xcindex-doctor --install to install xcode-build-server and wire up compile_commands.json for the current project.


Environment variables

Variable Effect
SOURCEKIT_LSP_PATH Override the auto-detected sourcekit-lsp binary path.
XCINDEX_DISABLE_PLAN_RENAME Set to 1 to make plan_rename refuse every request (kill switch).
CLAUDE_PROJECT_DIR Overrides CWD for session-edited-file tracking across hooks and tool.

Error handling

Every tool returns a plain text error in the MCP response when something goes wrong. Common cases:

See troubleshooting.md for the full list.