Home / Function/ annotateHandler() — mcp Function Reference

annotateHandler() — mcp Function Reference

Architecture documentation for the annotateHandler() function in tool-variants.ts from the mcp codebase.

Entity Profile

Dependency Diagram

graph TD
  76db10df_f560_1331_9608_6a46d322e405["annotateHandler()"]
  ac037c5b_e159_85ae_5dd7_8b0efd91626f["asErrorResult()"]
  76db10df_f560_1331_9608_6a46d322e405 -->|calls| ac037c5b_e159_85ae_5dd7_8b0efd91626f
  b9fca090_95d0_4cf7_0bb0_7a7efcc55ccb["resolveOrFetchGraph()"]
  76db10df_f560_1331_9608_6a46d322e405 -->|calls| b9fca090_95d0_4cf7_0bb0_7a7efcc55ccb
  ad473066_969b_8fc8_45fe_f01051030d72["findSymbol()"]
  76db10df_f560_1331_9608_6a46d322e405 -->|calls| ad473066_969b_8fc8_45fe_f01051030d72
  46063d5f_ce29_e424_cd46_c460531d27b6["asTextContentResult()"]
  76db10df_f560_1331_9608_6a46d322e405 -->|calls| 46063d5f_ce29_e424_cd46_c460531d27b6
  f0435cd0_6489_6dfd_b2b4_5d96d9d44fe2["renderBriefSymbolContext()"]
  76db10df_f560_1331_9608_6a46d322e405 -->|calls| f0435cd0_6489_6dfd_b2b4_5d96d9d44fe2
  style 76db10df_f560_1331_9608_6a46d322e405 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/tools/tool-variants.ts lines 266–298

const annotateHandler: HandlerFunction = async (client, args, defaultWorkdir) => {
  const symbol = typeof args?.symbol === 'string' ? args.symbol.trim() : '';
  if (!symbol) {
    return asErrorResult({
      type: 'validation_error',
      message: 'Missing required "symbol" parameter.',
      code: 'MISSING_SYMBOL',
      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, symbol);
  if (matches.length === 0) {
    return asTextContentResult(`No symbol matching "${symbol}" found.`);
  }

  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

Frequently Asked Questions

What does annotateHandler() do?
annotateHandler() is a function in the mcp codebase.
What does annotateHandler() call?
annotateHandler() 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