Home / Function/ main() — mcp Function Reference

main() — mcp Function Reference

Architecture documentation for the main() function in index.ts from the mcp codebase.

Entity Profile

Dependency Diagram

graph TD
  8e8fa8c5_d14a_6dee_35c8_6e4db4d58b20["main()"]
  770f7808_bf5f_3b38_4293_2ee451767b8e["handlePrecache()"]
  8e8fa8c5_d14a_6dee_35c8_6e4db4d58b20 -->|calls| 770f7808_bf5f_3b38_4293_2ee451767b8e
  b8971bfc_ba3c_23a9_1f17_5d613ac67105["debug()"]
  8e8fa8c5_d14a_6dee_35c8_6e4db4d58b20 -->|calls| b8971bfc_ba3c_23a9_1f17_5d613ac67105
  08ca54b2_22bc_134f_e028_7c18da8dca8a["start()"]
  8e8fa8c5_d14a_6dee_35c8_6e4db4d58b20 -->|calls| 08ca54b2_22bc_134f_e028_7c18da8dca8a
  style 8e8fa8c5_d14a_6dee_35c8_6e4db4d58b20 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/index.ts lines 14–50

async function main() {
  const args = process.argv.slice(2);

  // Handle precache subcommand
  if (args[0] === 'precache') {
    await handlePrecache(args.slice(1));
    return;
  }

  // Normal MCP server mode — parse flags
  let defaultWorkdir: string | undefined;
  let noApiFallback = !!process.env.SUPERMODEL_NO_API_FALLBACK;
  let precache = false;

  for (const arg of args) {
    if (arg === '--no-api-fallback') {
      noApiFallback = true;
    } else if (arg === '--precache') {
      precache = true;
    } else if (!arg.startsWith('--')) {
      defaultWorkdir = arg;
    }
  }

  if (defaultWorkdir) {
    logger.debug('Default workdir:', defaultWorkdir);
  }
  if (noApiFallback) {
    logger.debug('API fallback disabled (cache-only mode)');
  }
  if (precache) {
    logger.debug('Startup precaching enabled');
  }

  const server = new Server(defaultWorkdir, { noApiFallback, precache });
  await server.start();
}

Domain

Subdomains

Frequently Asked Questions

What does main() do?
main() is a function in the mcp codebase.
What does main() call?
main() calls 3 function(s): debug, handlePrecache, start.

Analyze Your Own Codebase

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

Try Supermodel Free