handler() — mcp Function Reference
Architecture documentation for the handler() function in symbol-context.ts from the mcp codebase.
Entity Profile
Dependency Diagram
graph TD f6b4d8d8_12fd_640f_c545_748d0e260bf0["handler()"] ca77ccf4_30df_6b5c_22dc_f7ba42fd0765["symbol-context.ts"] f6b4d8d8_12fd_640f_c545_748d0e260bf0 -->|defined in| ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 cbd676af_ec21_66d2_a9cd_83a383d7bc5b["asErrorResult()"] f6b4d8d8_12fd_640f_c545_748d0e260bf0 -->|calls| cbd676af_ec21_66d2_a9cd_83a383d7bc5b 0c2dbb97_347e_7226_4d31_fbdcb85ac22b["resolveOrFetchGraph()"] f6b4d8d8_12fd_640f_c545_748d0e260bf0 -->|calls| 0c2dbb97_347e_7226_4d31_fbdcb85ac22b 1595e523_decc_c3ce_72e9_f77eb66bef69["classifyApiError()"] f6b4d8d8_12fd_640f_c545_748d0e260bf0 -->|calls| 1595e523_decc_c3ce_72e9_f77eb66bef69 acad5452_c49c_a5b9_12f1_5263dd556260["findSymbol()"] f6b4d8d8_12fd_640f_c545_748d0e260bf0 -->|calls| acad5452_c49c_a5b9_12f1_5263dd556260 4d61d2d9_1e21_bfa3_9ab1_b3a87cf498d7["asTextContentResult()"] f6b4d8d8_12fd_640f_c545_748d0e260bf0 -->|calls| 4d61d2d9_1e21_bfa3_9ab1_b3a87cf498d7 fd98a844_5daf_fa4c_d573_003b6d89b6be["renderSymbolContext()"] f6b4d8d8_12fd_640f_c545_748d0e260bf0 -->|calls| fd98a844_5daf_fa4c_d573_003b6d89b6be style f6b4d8d8_12fd_640f_c545_748d0e260bf0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/tools/symbol-context.ts lines 60–118
export const handler: HandlerFunction = async (client, args, defaultWorkdir) => {
const symbol = typeof args?.symbol === 'string' ? args.symbol.trim() : '';
const rawDir = args?.directory as string | undefined;
const directory = (rawDir && rawDir.trim()) || defaultWorkdir || process.cwd();
if (!symbol) {
return asErrorResult({
type: 'validation_error',
message: 'Missing required "symbol" parameter.',
code: 'MISSING_SYMBOL',
recoverable: false,
suggestion: 'Provide the name of a function, class, or method to look up.',
});
}
if (!directory || typeof directory !== 'string') {
return asErrorResult({
type: 'validation_error',
message: 'No directory provided and no default workdir configured.',
code: 'MISSING_DIRECTORY',
recoverable: false,
suggestion: 'Provide a directory parameter or start the MCP server with a workdir argument.',
});
}
let graph: IndexedGraph;
try {
graph = await resolveOrFetchGraph(client, directory);
} catch (error: any) {
return asErrorResult(classifyApiError(error));
}
// Find the symbol
const matches = findSymbol(graph, symbol);
if (matches.length === 0) {
return asTextContentResult(
`No symbol matching "${symbol}" found in the code graph.\n\n` +
`Try:\n` +
`- A different spelling or casing\n` +
`- Just the function name without the class prefix\n` +
`- Use the \`overview\` tool to see available domains and key functions`
);
}
// Render results for top matches (usually 1, sometimes a few)
const renderedParts = await Promise.all(
matches.slice(0, 3).map(node => renderSymbolContext(graph, node, directory))
);
const rendered = renderedParts.join('\n---\n\n');
if (matches.length > 3) {
return asTextContentResult(
rendered + `\n\n*... and ${matches.length - 3} more matches. Use a more specific name to narrow results.*`
);
}
return asTextContentResult(rendered);
};
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does handler() do?
handler() is a function in the mcp codebase, defined in src/tools/symbol-context.ts.
Where is handler() defined?
handler() is defined in src/tools/symbol-context.ts at line 60.
What does handler() call?
handler() calls 6 function(s): asErrorResult, asTextContentResult, classifyApiError, findSymbol, renderSymbolContext, resolveOrFetchGraph.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free