Home / File/ symbol-context.ts — mcp Source File

symbol-context.ts — mcp Source File

Architecture documentation for symbol-context.ts, a typescript file in the mcp codebase. 16 imports, 2 dependents.

File typescript AnalysisTools SymbolSearch 16 imports 2 dependents 8 functions

Entity Profile

Dependency Diagram

graph LR
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765["symbol-context.ts"]
  5c6acde2_5ba8_604f_70ae_120f7b72feaa["types.ts"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 5c6acde2_5ba8_604f_70ae_120f7b72feaa
  c4c0fa2d_6600_6cac_6763_168919269bad["Endpoint"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> c4c0fa2d_6600_6cac_6763_168919269bad
  904f44eb_66f1_9575_c86d_de4c934b974c["HandlerFunction"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 904f44eb_66f1_9575_c86d_de4c934b974c
  4d61d2d9_1e21_bfa3_9ab1_b3a87cf498d7["asTextContentResult"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 4d61d2d9_1e21_bfa3_9ab1_b3a87cf498d7
  cbd676af_ec21_66d2_a9cd_83a383d7bc5b["asErrorResult"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> cbd676af_ec21_66d2_a9cd_83a383d7bc5b
  108c9ff4_bdb8_518a_9256_9ff4cd9d39a7["graph-cache.ts"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 108c9ff4_bdb8_518a_9256_9ff4cd9d39a7
  1e5728cd_d35b_2e55_1a1e_fbf2decd1090["IndexedGraph"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 1e5728cd_d35b_2e55_1a1e_fbf2decd1090
  0c2dbb97_347e_7226_4d31_fbdcb85ac22b["resolveOrFetchGraph"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 0c2dbb97_347e_7226_4d31_fbdcb85ac22b
  59a82797_f6a2_36aa_02bd_7b2f22d1bc50["normalizePath"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 59a82797_f6a2_36aa_02bd_7b2f22d1bc50
  3c41e44b_ebb5_f793_8014_42ade5f9b440["graph-types.ts"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 3c41e44b_ebb5_f793_8014_42ade5f9b440
  4bef1572_5a60_651d_3247_2779d2e6bd57["api-helpers.ts"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 4bef1572_5a60_651d_3247_2779d2e6bd57
  1595e523_decc_c3ce_72e9_f77eb66bef69["classifyApiError"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 1595e523_decc_c3ce_72e9_f77eb66bef69
  19f4d048_f875_3a64_f6f5_2d534dca972b["constants.ts"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 19f4d048_f875_3a64_f6f5_2d534dca972b
  222b60e9_a6a9_f11c_deba_8f76f9527fbc["fs"]
  ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 --> 222b60e9_a6a9_f11c_deba_8f76f9527fbc
  style ca77ccf4_30df_6b5c_22dc_f7ba42fd0765 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * `symbol_context` tool -- deep dive on a specific symbol.
 *
 * Given a function, class, or method name, returns (<10KB markdown):
 *  - Definition location (file, line)
 *  - Source code (up to MAX_SOURCE_LINES)
 *  - Callers (who calls this)
 *  - Callees (what this calls)
 *  - Domain membership
 *  - Related symbols in the same file
 *
 * Backed by pre-computed graphs (sub-second) with on-demand API fallback.
 */

import { promises as fs } from 'fs';
import * as path from 'path';
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import {
  Endpoint,
  HandlerFunction,
  asTextContentResult,
  asErrorResult,
} from '../types';
import {
  IndexedGraph,
  resolveOrFetchGraph,
  normalizePath,
} from '../cache/graph-cache';
import { CodeGraphNode } from '../cache/graph-types';
import { classifyApiError } from '../utils/api-helpers';
import {
  MAX_SYMBOL_CALLERS,
  MAX_SYMBOL_CALLEES,
  MAX_SYMBOL_RELATED,
  MAX_SOURCE_LINES,
} from '../constants';

export const tool: Tool = {
  name: 'symbol_context',
  description:
    `Strictly better than grep for understanding a function, class, or method. Given a symbol name, instantly returns its source code, definition location, all callers, all callees, architectural domain, and related symbols in the same file -- structural context that grep cannot reconstruct. Sub-second, zero cost. Supports partial matching ("filter" finds "QuerySet.filter", "filter_queryset", etc.) and "ClassName.method" syntax. Use this whenever you have a symbol name from a stack trace, issue, or search result and need to understand how it connects to the rest of the codebase.`,
  inputSchema: {
    type: 'object',
    properties: {
      symbol: {
        type: 'string',
        description:
          'Name of the function, class, or method to look up. Supports "ClassName.method" syntax.',
      },
      directory: {
        type: 'string',
        description:
          'Path to the repository directory. Omit if the MCP server was started with a default workdir.',
      },
    },
    required: ['symbol'],
  },
};

export const handler: HandlerFunction = async (client, args, defaultWorkdir) => {
// ... (374 more lines)

Domain

Subdomains

Frequently Asked Questions

What does symbol-context.ts do?
symbol-context.ts is a source file in the mcp codebase, written in typescript. It belongs to the AnalysisTools domain, SymbolSearch subdomain.
What functions are defined in symbol-context.ts?
symbol-context.ts defines 8 function(s): callerCount, findDomain, findSymbol, handler, isCodeSymbol, languageFromExtension, renderSymbolContext, symbolPriority.
What does symbol-context.ts depend on?
symbol-context.ts imports 16 module(s): Endpoint, HandlerFunction, IndexedGraph, api-helpers.ts, asErrorResult, asTextContentResult, classifyApiError, constants.ts, and 8 more.
What files import symbol-context.ts?
symbol-context.ts is imported by 2 file(s): server.ts, symbol-context.test.ts.
Where is symbol-context.ts in the architecture?
symbol-context.ts is located at src/tools/symbol-context.ts (domain: AnalysisTools, subdomain: SymbolSearch, directory: src/tools).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free