Home / Function/ constructor() — mcp Function Reference

constructor() — mcp Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  fb3524f1_6068_fb0f_15f3_83e2b15a3f3f["constructor()"]
  4646463d_3032_7be4_79ae_2b8f22f309dd["setupHandlers()"]
  fb3524f1_6068_fb0f_15f3_83e2b15a3f3f -->|calls| 4646463d_3032_7be4_79ae_2b8f22f309dd
  fe553e0d_7d2a_65bf_5564_003fcd15f4bd["setupPrompts()"]
  fb3524f1_6068_fb0f_15f3_83e2b15a3f3f -->|calls| fe553e0d_7d2a_65bf_5564_003fcd15f4bd
  10a4252d_3edb_56bd_28db_9c5d6fc94128["setupResources()"]
  fb3524f1_6068_fb0f_15f3_83e2b15a3f3f -->|calls| 10a4252d_3edb_56bd_28db_9c5d6fc94128
  f44288ac_9699_6d30_dcdb_c995d1acd1a5["constructor()"]
  fb3524f1_6068_fb0f_15f3_83e2b15a3f3f -->|calls| f44288ac_9699_6d30_dcdb_c995d1acd1a5
  08ca54b2_22bc_134f_e028_7c18da8dca8a["start()"]
  fb3524f1_6068_fb0f_15f3_83e2b15a3f3f -->|calls| 08ca54b2_22bc_134f_e028_7c18da8dca8a
  b8971bfc_ba3c_23a9_1f17_5d613ac67105["debug()"]
  fb3524f1_6068_fb0f_15f3_83e2b15a3f3f -->|calls| b8971bfc_ba3c_23a9_1f17_5d613ac67105
  style fb3524f1_6068_fb0f_15f3_83e2b15a3f3f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/server.ts lines 60–148

  constructor(defaultWorkdir?: string, options?: ServerOptions) {
    this.defaultWorkdir = defaultWorkdir;
    this.options = options;

    const experiment = process.env.SUPERMODEL_EXPERIMENT;

    // Note: noApiFallback is deferred to start() so startup precaching can use the API
    const experimentInstructions: Record<string, string> = {
      'minimal-instructions': 'Codebase analysis tool. Call symbol_context to look up functions/classes.',
      'search-symbol': 'Codebase search tool. Use `search_symbol` alongside Grep and Read for parallel exploration.',
      'split-tools': 'Codebase tools: `find_definition` locates symbols, `trace_calls` shows caller/callee graphs. Call them alongside Read, Grep, and Glob.',
      'annotate': 'Codebase annotation tool. Fire `annotate` alongside your Read and Grep calls to enrich results with structural metadata.',
      'graphrag': `# Supermodel: Codebase Intelligence

One read-only tool for instant call-graph exploration.

## Tool
- \`explore_function\`: BFS traversal of a function/class call graph. Returns source code, callers, callees, and cross-subsystem boundaries with ← DIFFERENT SUBSYSTEM markers. Supports partial matching and "ClassName.method" syntax.

## Workflow
1. Identify key symbols from the issue, call \`explore_function\` to understand their call-graph context. Issue multiple calls in parallel (read-only, safe).
2. Use file paths and source code from the response to start editing. Max 2 MCP calls total.

## Rules
- Do NOT use TodoWrite. Act directly.
- NEVER create standalone test scripts. Run the repo's existing test suite to verify.
- >2 MCP turns = diminishing returns. Get everything you need in one turn.`,
    };

    const instructions = experiment && experimentInstructions[experiment]
      ? experimentInstructions[experiment]
      : `# Supermodel: Codebase Intelligence

One read-only tool for instant codebase understanding. Pre-computed graphs enable sub-second responses.

The codebase overview is included below in these instructions — you already have the architecture map.

## Recommended workflow
1. Identify symbols from the issue/overview and call \`symbol_context\` to explore them.
   Batch via \`symbols\` array or issue multiple calls in parallel (read-only, safe).
2. Stop calling MCP tools. Start editing by turn 3. Max 3 MCP calls total.

## Rules
- Do NOT use TodoWrite. Act directly.
- Use the Task tool to delegate subtasks (e.g. running tests, exploring tangential code).
- >2 MCP turns = diminishing returns. Explore everything you need in one turn.

## After fixing
Run the full related test suite to catch regressions. Do NOT write standalone test scripts.

## Tool reference
- \`symbol_context\`: Source, callers, callees, domain for any function/class/method.
  Supports "Class.method", partial matching, and batch lookups via \`symbols\` array.
  Use \`brief: true\` for compact output when looking up 3+ symbols.
  Read-only — safe to call in parallel.`;

    this.server = new McpServer(
      {
        name: 'supermodel_api',
        version: '0.0.1',
      },
      {
        capabilities: { tools: {}, logging: {}, prompts: {}, resources: {} },
        instructions,
      },
    );

    const config = new Configuration({
      basePath: process.env.SUPERMODEL_BASE_URL || 'https://api.supermodeltools.com',
      apiKey: process.env.SUPERMODEL_API_KEY,
      fetchApi: fetchWithTimeout,
    });

    logger.debug('Server configuration:');
    logger.debug('Base URL:', config.basePath);
    logger.debug('API Key set:', !!process.env.SUPERMODEL_API_KEY);
    if (this.defaultWorkdir) {
      logger.debug('Default workdir:', this.defaultWorkdir);
    }

    const api = new DefaultApi(config);
    this.client = {
      graphs: new SupermodelClient(api),
    };

    this.setupHandlers();
    this.setupPrompts();
    this.setupResources();
  }

Domain

Subdomains

Frequently Asked Questions

What does constructor() do?
constructor() is a function in the mcp codebase.
What does constructor() call?
constructor() calls 6 function(s): constructor, debug, setupHandlers, setupPrompts, setupResources, start.

Analyze Your Own Codebase

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

Try Supermodel Free