Home / Function/ start() — mcp Function Reference

start() — mcp Function Reference

Architecture documentation for the start() function in server.ts from the mcp codebase.

Entity Profile

Dependency Diagram

graph TD
  9d72a623_8b26_a485_5797_5f53c18e4294["start()"]
  50dc88e1_e79b_8a97_364b_4502057dd58f["Server"]
  9d72a623_8b26_a485_5797_5f53c18e4294 -->|defined in| 50dc88e1_e79b_8a97_364b_4502057dd58f
  9b0f2e33_56dd_6b97_6fd4_a4a2c45675d5["main()"]
  9b0f2e33_56dd_6b97_6fd4_a4a2c45675d5 -->|calls| 9d72a623_8b26_a485_5797_5f53c18e4294
  65787d30_1025_d531_cde5_ded3572607bd["constructor()"]
  65787d30_1025_d531_cde5_ded3572607bd -->|calls| 9d72a623_8b26_a485_5797_5f53c18e4294
  4ac071e8_cf9e_8aff_e8f4_ae8e57382223["cleanupOldZips()"]
  9d72a623_8b26_a485_5797_5f53c18e4294 -->|calls| 4ac071e8_cf9e_8aff_e8f4_ae8e57382223
  33bb86df_1268_373b_a74a_77412144612c["debug()"]
  9d72a623_8b26_a485_5797_5f53c18e4294 -->|calls| 33bb86df_1268_373b_a74a_77412144612c
  8e2a6102_97e1_76b1_c08e_d7b87f095026["loadCacheFromDisk()"]
  9d72a623_8b26_a485_5797_5f53c18e4294 -->|calls| 8e2a6102_97e1_76b1_c08e_d7b87f095026
  314364e0_fe4a_b7a7_3c8a_3ec3565c6f43["setRepoMap()"]
  9d72a623_8b26_a485_5797_5f53c18e4294 -->|calls| 314364e0_fe4a_b7a7_3c8a_3ec3565c6f43
  f7302a04_558c_423c_2b1f_3cfced56f273["warn()"]
  9d72a623_8b26_a485_5797_5f53c18e4294 -->|calls| f7302a04_558c_423c_2b1f_3cfced56f273
  86e5ab36_fcab_9ac4_8f1d_6573699f3dc9["info()"]
  9d72a623_8b26_a485_5797_5f53c18e4294 -->|calls| 86e5ab36_fcab_9ac4_8f1d_6573699f3dc9
  5f051fd3_b5fd_05fe_3e0b_f20364a0b064["precacheForDirectory()"]
  9d72a623_8b26_a485_5797_5f53c18e4294 -->|calls| 5f051fd3_b5fd_05fe_3e0b_f20364a0b064
  83c802b9_e3aa_19bf_2f08_8c122116d4f8["setNoApiFallback()"]
  9d72a623_8b26_a485_5797_5f53c18e4294 -->|calls| 83c802b9_e3aa_19bf_2f08_8c122116d4f8
  style 9d72a623_8b26_a485_5797_5f53c18e4294 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/server.ts lines 139–178

  async start() {
    // Clean up any stale ZIP files from previous sessions
    await cleanupOldZips(ZIP_CLEANUP_AGE_MS);

    // Load pre-computed graphs from cache directory
    const cacheDir = process.env.SUPERMODEL_CACHE_DIR;
    if (cacheDir) {
      try {
        logger.debug('Loading pre-computed graphs from:', cacheDir);
        const repoMap = await loadCacheFromDisk(cacheDir, graphCache);
        setRepoMap(repoMap);
        logger.debug(`Loaded ${repoMap.size} repo mappings`);
      } catch (err: any) {
        logger.warn('Failed to load cache directory:', err.message || err);
      }
    }

    // Connect transport FIRST so the MCP handshake completes immediately.
    // This prevents Claude Code from timing out the server (MCP_TIMEOUT=60s)
    // when precaching requires a slow API call.
    const transport = new StdioServerTransport();
    await this.server.connect(transport);
    logger.info('Supermodel MCP Server running on stdio');

    // Precache the workdir's repo if --precache flag is set.
    // Runs AFTER connect but BEFORE noApiFallback so the API is available.
    // This is fire-and-forget from the MCP client's perspective — tools
    // that arrive before precaching finishes will use on-demand API calls.
    if (this.options?.precache && this.defaultWorkdir) {
      try {
        await precacheForDirectory(this.client, this.defaultWorkdir, cacheDir);
      } catch (err: any) {
        // Non-fatal: if precaching fails, tools fall back to on-demand API
        logger.warn('Startup precache failed:', err.message || err);
      }
    }

    // NOW enable no-api-fallback (after precaching had its chance)
    setNoApiFallback(!!this.options?.noApiFallback);
  }

Domain

Subdomains

Defined In

Frequently Asked Questions

What does start() do?
start() is a function in the mcp codebase, defined in src/server.ts.
Where is start() defined?
start() is defined in src/server.ts at line 139.
What does start() call?
start() calls 8 function(s): cleanupOldZips, debug, info, loadCacheFromDisk, precacheForDirectory, setNoApiFallback, setRepoMap, warn.
What calls start()?
start() is called by 2 function(s): constructor, main.

Analyze Your Own Codebase

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

Try Supermodel Free