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
  08ca54b2_22bc_134f_e028_7c18da8dca8a["start()"]
  8e8fa8c5_d14a_6dee_35c8_6e4db4d58b20["main()"]
  8e8fa8c5_d14a_6dee_35c8_6e4db4d58b20 -->|calls| 08ca54b2_22bc_134f_e028_7c18da8dca8a
  fb3524f1_6068_fb0f_15f3_83e2b15a3f3f["constructor()"]
  fb3524f1_6068_fb0f_15f3_83e2b15a3f3f -->|calls| 08ca54b2_22bc_134f_e028_7c18da8dca8a
  6cc13fa0_0ce9_926f_417f_6b3f50082f67["injectOverviewInstructions()"]
  08ca54b2_22bc_134f_e028_7c18da8dca8a -->|calls| 6cc13fa0_0ce9_926f_417f_6b3f50082f67
  8b9027cb_22ba_2e2c_2393_3368aa90048f["cleanupOldZips()"]
  08ca54b2_22bc_134f_e028_7c18da8dca8a -->|calls| 8b9027cb_22ba_2e2c_2393_3368aa90048f
  b8971bfc_ba3c_23a9_1f17_5d613ac67105["debug()"]
  08ca54b2_22bc_134f_e028_7c18da8dca8a -->|calls| b8971bfc_ba3c_23a9_1f17_5d613ac67105
  f528cae6_71d3_4b84_026d_d4778648e9c8["loadCacheFromDisk()"]
  08ca54b2_22bc_134f_e028_7c18da8dca8a -->|calls| f528cae6_71d3_4b84_026d_d4778648e9c8
  6286dfdc_363a_e066_94f6_eed64cb90922["setRepoMap()"]
  08ca54b2_22bc_134f_e028_7c18da8dca8a -->|calls| 6286dfdc_363a_e066_94f6_eed64cb90922
  dfe11f52_4dd3_db89_9717_941d05bae091["warn()"]
  08ca54b2_22bc_134f_e028_7c18da8dca8a -->|calls| dfe11f52_4dd3_db89_9717_941d05bae091
  22da2ab2_e145_3482_5780_396d4475bdc6["info()"]
  08ca54b2_22bc_134f_e028_7c18da8dca8a -->|calls| 22da2ab2_e145_3482_5780_396d4475bdc6
  966fdd0a_509a_01b0_865e_32cfde84f964["precacheForDirectory()"]
  08ca54b2_22bc_134f_e028_7c18da8dca8a -->|calls| 966fdd0a_509a_01b0_865e_32cfde84f964
  1cc29fb0_a9fe_6553_f392_e25cc3a07001["setNoApiFallback()"]
  08ca54b2_22bc_134f_e028_7c18da8dca8a -->|calls| 1cc29fb0_a9fe_6553_f392_e25cc3a07001
  style 08ca54b2_22bc_134f_e028_7c18da8dca8a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/server.ts lines 310–350

  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`);
        this.injectOverviewInstructions(repoMap);
      } 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

Frequently Asked Questions

What does start() do?
start() is a function in the mcp codebase.
What does start() call?
start() calls 9 function(s): cleanupOldZips, debug, info, injectOverviewInstructions, loadCacheFromDisk, precacheForDirectory, setNoApiFallback, setRepoMap, and 1 more.
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