findDefinitionHandler() — mcp Function Reference
Architecture documentation for the findDefinitionHandler() function in tool-variants.ts from the mcp codebase.
Entity Profile
Dependency Diagram
graph TD 211e0c66_321b_c05c_6d2c_3b3009df3949["findDefinitionHandler()"] 05b504b7_268e_7c49_d109_73f7c3744be0["asErrorResult()"] 211e0c66_321b_c05c_6d2c_3b3009df3949 -->|calls| 05b504b7_268e_7c49_d109_73f7c3744be0 1721f7fd_bb7b_c8c3_9b4b_5677293ae256["resolveOrFetchGraph()"] 211e0c66_321b_c05c_6d2c_3b3009df3949 -->|calls| 1721f7fd_bb7b_c8c3_9b4b_5677293ae256 2d87a17c_e46f_9198_c263_81d7c3c3054e["findSymbol()"] 211e0c66_321b_c05c_6d2c_3b3009df3949 -->|calls| 2d87a17c_e46f_9198_c263_81d7c3c3054e 67622b0f_6b47_8f68_bac5_409b3145d2f2["asTextContentResult()"] 211e0c66_321b_c05c_6d2c_3b3009df3949 -->|calls| 67622b0f_6b47_8f68_bac5_409b3145d2f2 6666a1f2_0912_ade3_4b0e_42190c41cd97["normalizePath()"] 211e0c66_321b_c05c_6d2c_3b3009df3949 -->|calls| 6666a1f2_0912_ade3_4b0e_42190c41cd97 style 211e0c66_321b_c05c_6d2c_3b3009df3949 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/tools/tool-variants.ts lines 113–150
const findDefinitionHandler: HandlerFunction = async (client, args, defaultWorkdir) => {
const name = typeof args?.name === 'string' ? args.name.trim() : '';
if (!name) {
return asErrorResult({
type: 'validation_error',
message: 'Missing required "name" parameter.',
code: 'MISSING_NAME',
recoverable: false,
});
}
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, name);
if (matches.length === 0) {
return asTextContentResult(`No symbol matching "${name}" found.`);
}
// Ultra-compact: just location lines
const lines = matches.slice(0, 5).map(node => {
const sym = node.properties?.name as string || '(unknown)';
const fp = normalizePath(node.properties?.filePath as string || '');
const start = node.properties?.startLine as number || 0;
const end = node.properties?.endLine as number || 0;
const kind = node.labels?.[0]?.toLowerCase() || 'symbol';
return `${sym} (${kind}) — ${fp}:${start}-${end}`;
});
return asTextContentResult(lines.join('\n'));
};
Domain
Subdomains
Source
Frequently Asked Questions
What does findDefinitionHandler() do?
findDefinitionHandler() is a function in the mcp codebase.
What does findDefinitionHandler() call?
findDefinitionHandler() calls 5 function(s): asErrorResult, asTextContentResult, findSymbol, normalizePath, resolveOrFetchGraph.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free