searchSymbolHandler() — mcp Function Reference
Architecture documentation for the searchSymbolHandler() function in tool-variants.ts from the mcp codebase.
Entity Profile
Dependency Diagram
graph TD 9efb304e_755f_f15e_7c58_cd704e785584["searchSymbolHandler()"] ac037c5b_e159_85ae_5dd7_8b0efd91626f["asErrorResult()"] 9efb304e_755f_f15e_7c58_cd704e785584 -->|calls| ac037c5b_e159_85ae_5dd7_8b0efd91626f b9fca090_95d0_4cf7_0bb0_7a7efcc55ccb["resolveOrFetchGraph()"] 9efb304e_755f_f15e_7c58_cd704e785584 -->|calls| b9fca090_95d0_4cf7_0bb0_7a7efcc55ccb ad473066_969b_8fc8_45fe_f01051030d72["findSymbol()"] 9efb304e_755f_f15e_7c58_cd704e785584 -->|calls| ad473066_969b_8fc8_45fe_f01051030d72 46063d5f_ce29_e424_cd46_c460531d27b6["asTextContentResult()"] 9efb304e_755f_f15e_7c58_cd704e785584 -->|calls| 46063d5f_ce29_e424_cd46_c460531d27b6 f0435cd0_6489_6dfd_b2b4_5d96d9d44fe2["renderBriefSymbolContext()"] 9efb304e_755f_f15e_7c58_cd704e785584 -->|calls| f0435cd0_6489_6dfd_b2b4_5d96d9d44fe2 style 9efb304e_755f_f15e_7c58_cd704e785584 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/tools/tool-variants.ts lines 49–83
const searchSymbolHandler: HandlerFunction = async (client, args, defaultWorkdir) => {
const query = typeof args?.query === 'string' ? args.query.trim() : '';
if (!query) {
return asErrorResult({
type: 'validation_error',
message: 'Missing required "query" parameter.',
code: 'MISSING_QUERY',
recoverable: false,
suggestion: 'Provide the name of a function, class, or method to search for.',
});
}
const rawDir = args?.directory as string | undefined;
const directory = (rawDir && rawDir.trim()) || defaultWorkdir || process.cwd();
let graph: IndexedGraph;
try {
graph = await resolveOrFetchGraph(client, directory);
} catch (error: any) {
return asErrorResult({ type: 'internal_error', message: error.message, code: 'GRAPH_ERROR', recoverable: false });
}
const matches = findSymbol(graph, query);
if (matches.length === 0) {
return asTextContentResult(`No symbol matching "${query}" found.`);
}
// Always brief — keep response small so model doesn't "wait for it"
const parts = matches.slice(0, 3).map(node => renderBriefSymbolContext(graph, node));
let result = parts.join('\n---\n\n');
if (matches.length > 3) {
result += `\n\n*... and ${matches.length - 3} more matches.*`;
}
return asTextContentResult(result);
};
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does searchSymbolHandler() do?
searchSymbolHandler() is a function in the mcp codebase.
What does searchSymbolHandler() call?
searchSymbolHandler() calls 5 function(s): asErrorResult, asTextContentResult, findSymbol, renderBriefSymbolContext, resolveOrFetchGraph.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free