Home / File/ server.integration.test.ts — mcp Source File

server.integration.test.ts — mcp Source File

Architecture documentation for server.integration.test.ts, a typescript file in the mcp codebase. 5 imports, 0 dependents.

File typescript 5 imports

Entity Profile

Dependency Diagram

graph LR
  1995f7e9_0576_2a27_2f48_3728ae56455d["server.integration.test.ts"]
  9304f204_de38_9fc9_faf0_8f287591dc52["globals"]
  1995f7e9_0576_2a27_2f48_3728ae56455d --> 9304f204_de38_9fc9_faf0_8f287591dc52
  a3686edc_9a68_383f_a650_fcb10e778279["child_process"]
  1995f7e9_0576_2a27_2f48_3728ae56455d --> a3686edc_9a68_383f_a650_fcb10e778279
  222b60e9_a6a9_f11c_deba_8f76f9527fbc["fs"]
  1995f7e9_0576_2a27_2f48_3728ae56455d --> 222b60e9_a6a9_f11c_deba_8f76f9527fbc
  0df9432b_f0c6_9994_a244_750de4314095["readline"]
  1995f7e9_0576_2a27_2f48_3728ae56455d --> 0df9432b_f0c6_9994_a244_750de4314095
  326b2a40_61be_c67e_3a48_e7ce3411f260["path"]
  1995f7e9_0576_2a27_2f48_3728ae56455d --> 326b2a40_61be_c67e_3a48_e7ce3411f260
  style 1995f7e9_0576_2a27_2f48_3728ae56455d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Integration tests for the MCP server.
 * Tests the JSON-RPC protocol, tool listing, and basic operations.
 */

import { describe, it, expect, beforeAll, afterAll } from '@jest/globals';
import { spawn, ChildProcess } from 'child_process';
import { existsSync } from 'fs';
import * as readline from 'readline';
import * as path from 'path';

const SERVER_STARTUP_TIMEOUT_MS = 5000;
const STARTUP_POLL_INTERVAL_MS = 100;

describe('MCP Server Integration', () => {
  let server: ChildProcess;
  let requestId = 0;
  let responseQueue: Map<number, { resolve: (value: any) => void; reject: (err: Error) => void }> = new Map();
  let rl: readline.Interface;

  function sendRequest(method: string, params: Record<string, unknown> = {}): Promise<any> {
    return new Promise((resolve, reject) => {
      const id = ++requestId;
      const request = {
        jsonrpc: '2.0',
        id,
        method,
        params
      };
      responseQueue.set(id, { resolve, reject });
      server.stdin!.write(JSON.stringify(request) + '\n');

      setTimeout(() => {
        if (responseQueue.has(id)) {
          responseQueue.delete(id);
          reject(new Error(`Request ${method} timed out`));
        }
      }, 5000);
    });
  }

  beforeAll(async () => {
    const distPath = path.join(__dirname, '..', 'dist', 'index.js');
    if (!existsSync(distPath)) {
      throw new Error(
        `Server build not found at ${distPath}. Run 'npm run build' first.`
      );
    }

    server = spawn('node', [distPath, '--no-api-fallback'], {
      stdio: ['pipe', 'pipe', 'pipe'],
      env: { ...process.env }
    });

    server.on('error', (err) => {
      throw new Error(`Failed to start MCP server: ${err.message}`);
    });

    rl = readline.createInterface({
      input: server.stdout!,
// ... (135 more lines)

Dependencies

  • child_process
  • fs
  • globals
  • path
  • readline

Frequently Asked Questions

What does server.integration.test.ts do?
server.integration.test.ts is a source file in the mcp codebase, written in typescript.
What does server.integration.test.ts depend on?
server.integration.test.ts imports 5 module(s): child_process, fs, globals, path, readline.
Where is server.integration.test.ts in the architecture?
server.integration.test.ts is located at src/server.integration.test.ts (directory: src).

Analyze Your Own Codebase

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

Try Supermodel Free