find_symbol
Locate specific functions, classes, or variables in code with fuzzy matching that corrects typos and returns exact file paths and line numbers.
Instructions
⭐ PREFERRED FOR SYMBOLS: Use this INSTEAD OF Grep when looking for specific functions, classes, or variables. Fuzzy matching automatically handles typos ("athenticate" → "authenticate"). Returns exact file path and line number. Much faster than Grep with better accuracy.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | The symbol name to find (e.g., function name, class name, variable name) | |
| type | No | The type of symbol to find. Use "any" to search all types. |
Implementation Reference
- src/index.ts:400-419 (handler)Tool handler logic for `find_symbol` within the `CallToolRequestSchema` switch statement.
case 'find_symbol': { const a = args as any; const symbol: string = a.symbol || a.name || a.symbolName; const type: string | undefined = a.type; if (!symbol) { return { content: [{ type: 'text', text: 'Error: symbol is required. Provide the symbol name to find.' }], isError: true, }; } const results = await retriever.findSymbol(symbol, type); return { content: [ { type: 'text', text: JSON.stringify(results, null, 2), }, ], }; } - src/retriever.ts:16-29 (handler)`retriever.findSymbol` method which orchestrates the symbol lookup and includes fuzzy matching logic if direct lookup fails.
async findSymbol(symbolName: string, type?: string): Promise<any> { const symbols = this.indexer.findSymbols(symbolName, type); if (symbols.length === 0) { // Try fuzzy search const allSymbols = this.getAllSymbols(); const fuzzyMatches = allSymbols.filter(s => { const typeMatch = !type || type === 'any' || s.type === type; return typeMatch && CodeSearchEngine.isFuzzyMatch(symbolName, s.name, 0.65); }); if (fuzzyMatches.length > 0) { return { found: false, - src/indexer.ts:868-874 (helper)`indexer.findSymbols` method that performs the actual symbol retrieval from the `symbolMap`.
findSymbols(name: string, type?: string): Symbol[] { const symbols = this.symbolMap.get(name) || []; if (type && type !== 'any') { return symbols.filter((s) => s.type === type); } return symbols; }