Windsurf에서 MCP 서버 연동해서 프로젝트 컨텍스트 관리하기

배경

회사에서 마이크로서비스 아키텍처로 전환하면서 여러 레포지토리를 동시에 다뤄야 하는 상황이 잦아졌다. Windsurf를 메인 에디터로 쓰고 있는데, AI 어시스턴트가 다른 서비스의 API 스펙이나 공통 라이브러리 구조를 모르는 경우가 많았다.

MCP 서버를 직접 구성해서 해결했다.

MCP 서버 설정

Windsurf 설정 파일(.windsurf/mcp.json)에 커스텀 MCP 서버를 추가했다.

{
  "mcpServers": {
    "project-context": {
      "command": "node",
      "args": ["/path/to/mcp-server/index.js"],
      "env": {
        "PROJECT_ROOT": "/workspace"
      }
    }
  }
}

서버 구현

Node.js로 간단한 MCP 서버를 만들었다. 프로젝트 루트의 특정 디렉토리들을 읽어서 컨텍스트로 제공한다.

import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import fs from 'fs/promises';

const server = new Server({
  name: 'project-context',
  version: '1.0.0'
});

server.setRequestHandler('resources/list', async () => {
  const specs = await fs.readFile('./api-specs/openapi.yaml', 'utf-8');
  const types = await fs.readFile('./shared-types/index.d.ts', 'utf-8');
  
  return {
    resources: [
      { uri: 'project://api-specs', name: 'API Specifications', mimeType: 'text/yaml' },
      { uri: 'project://shared-types', name: 'Shared Types', mimeType: 'text/typescript' }
    ]
  };
});

const transport = new StdioServerTransport();
server.connect(transport);

효과

이제 Windsurf가 다른 서비스의 API 엔드포인트나 공통 타입 정의를 알고 있어서 코드 제안 품질이 확실히 올라갔다. 특히 API 클라이언트 코드 작성할 때 OpenAPI 스펙 기반으로 정확한 타입과 파라미터를 제안해준다.

팀원들과 공유할 수 있게 레포지토리에 설정을 커밋했고, 온보딩 시간도 단축됐다.