Skip to main content
Glama
carloshpdoc

memorydetective

Find every reference to a Swift symbol

swiftFindSymbolReferences

Locates a Swift symbol's declaration in a file and uses SourceKit-LSP to find all references across the project, returning code snippets for each call site and capture.

Instructions

[mg.code] Locates the symbol's declaration in filePath, then asks SourceKit-LSP for textDocument/references. Returns every callsite + capture across the project, with a snippet of each line. Requires an IndexStoreDB at <projectRoot>/.build/index/store for cross-file references — build it with swift build -Xswiftc -index-store-path -Xswiftc <projectRoot>/.build/index/store. The result includes a needsIndex: true hint when the index is missing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolNameYesName of the Swift symbol to find references for.
filePathYesPath to a Swift file where the symbol is declared. The LSP query needs a position; we locate it in this file via a regex pre-scan.
projectRootNoOverride the project root. Default discovers the nearest Package.swift / .xcodeproj / .xcworkspace.
includeDeclarationNoInclude the declaration site itself in the result set.
Behavior5/5

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

With no annotations, the description fully discloses the mechanism (SourceKit-LSP, regex pre-scan), the requirement for an index store, and the output behavior including the 'needsIndex' hint. It is complete and transparent.

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

Conciseness4/5

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

The description is front-loaded with the purpose and uses a clear structure, but it is slightly verbose with code blocks and extra detail. Still efficient for the information conveyed.

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

Completeness4/5

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

Given the complexity (4 params, no output schema), the description covers the output format (snippet per line, hint) and requirements. Could be more explicit about the exact output structure, but sufficient for an agent.

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

Parameters4/5

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

Schema coverage is 100%, so baseline is 3. The description adds value by explaining how filePath is used for locating the declaration and the default discovery for projectRoot, going beyond the schema descriptions.

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

Purpose5/5

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

The description clearly states it finds every reference to a Swift symbol, using the verb 'find' and resource 'Swift symbol references'. It distinguishes from sibling tools like swiftGetSymbolDefinition by focusing on all references across the project.

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

Usage Guidelines4/5

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

It explains the prerequisite of an IndexStoreDB and how to build it, but does not explicitly exclude alternatives or specify when not to use it compared to sibling tools. The context is clear for typical usage.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/carloshpdoc/memorydetective'

If you have feedback or need assistance with the MCP directory API, please join our Discord server