Skip to main content
Glama
carloshpdoc

memorydetective

Locate a Swift symbol's source declaration

swiftGetSymbolDefinition

Locate the file and line where a Swift symbol is declared using regex and SourceKit-LSP, returning the position even when LSP fails. Navigate from class names in memory graphs to source files.

Instructions

[mg.code] Find the file:line where a Swift symbol (class, struct, enum, protocol, func, var, etc.) is declared. Pre-scans candidatePaths (or hint.filePath) with a fast regex first, then asks SourceKit-LSP for jump-to-definition. Returns the position even when LSP can't follow through. Use after findRetainers / classifyCycle surface a class name from a memgraph cycle to land in the actual source file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolNameYesName of the Swift symbol to locate (class, struct, enum, protocol, func, var, etc.).
hintNoOptional hint to speed up the search. `filePath` skips the project scan; `module` is reserved for future multi-module work.
projectRootNoOverride the project root. Default discovers the nearest Package.swift / .xcodeproj / .xcworkspace from the cwd.
candidatePathsNoIf provided, search these files for the symbol declaration before asking SourceKit-LSP. Speeds up location when the agent already has a guess (e.g. from `findSymbolReferences` or `swift_search_pattern`).
Behavior5/5

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

Without annotations, the description fully discloses behavior: pre-scans with regex, uses SourceKit-LSP, returns position even if LSP fails. This gives the agent a clear model of how the tool operates.

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 concise sentences plus a usage note. Every sentence earns its place: first states purpose and algorithm, second provides workflow context. No redundant information.

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 4 params, nested object, and no output schema, the description covers the algorithm, fallback, and typical use case. Lacks explicit return format (e.g., file path and line number), but 'Returns the position' is adequate. Complete enough for the complexity.

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%, baseline 3. Description adds meaning for all parameters: explains symbolName types, hint usage, projectRoot override, and candidatePaths as a speedup. Exceeds baseline by explaining the two-step search process.

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?

Clearly states it finds the file:line where a Swift symbol is declared, using specific verb-resource pairs. Distinguishes from siblings like swiftFindSymbolReferences by mentioning typical use after findRetainers/classifyCycle.

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?

Explicitly says to use after findRetainers/classifyCycle to land in source file. Provides guidance on candidatePaths and hint to speed up search. Does not list alternative tools for different purposes, but implies context.

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