클로드 코드든 커서든 이거 모르면 토큰 폭탄입니다

물론, 토큰을 줄이는 여러가지 방법이 있기는 합니다. 오늘 살펴볼 것은 Serena MCP Server 입니다.

이걸 사용하면 왜 토큰이 절약되나요?

일반적으로 클로드(Claude)에서 코드를 다룰 때는, 파일 전체를 통째로 불러오거나 검색 도구를 이용해 필요한 부분을 찾습니다. 하지만 이런 방식은 코드의 맥락을 세밀하게 구분하지 못해 불필요한 코드까지 함께 처리하게 됩니다. 결과적으로 토큰이 낭비되고 분석 속도도 느려지는 비효율이 발생합니다.

Serena 는 단순히 텍스트를 검색하는 것이 아니라, 코드의 의미와 구조를 이해한 뒤 필요한 부분만 선택적으로 불러오는 방식을 사용합니다. 이렇게 하면 불필요한 토큰 사용을 최소화할 수 있습니다. 게다가 Serena는 한 번의 정확한 분석으로 재시도를 줄이고, 코드의 의존 관계나 구조를 파악해 더 자연스럽고 의도에 맞는 코드 결과를 만들어냅니다.

에이전트가 Serena를 쓴다면 훨씬 효율적이 되겠죠.

Serena는 “SEmantic Retrieval & Editing Noetic Agent”의 접두어로 구성된 단어입니다. 직역하자면, “의미론적인 추출 및 편집 지성적 에이전트” 정도가 되겠네요.

Serena MCP Server 가 제공하는 툴 들

Serena MCP 서버가 제공하는 툴은 아래 이미지와 같습니다. Agent가 필요할 때 아래 툴을 사용하는 거죠. 이름 보면 느낌이 오시죠?

파일 찾기, 디렉토리 나열, 패턴 찾기 등등 유용한 툴들이 보이네요.

각 툴에 대한 설명은 아래 링크에서 확인 가능합니다.

https://github.com/oraios/serena?tab=readme-ov-file#list-of-tools

이보다 쉬울 순 없는 사용 방법

uvx 만 설치되어 있다면, 아래 설정으로 바로 사용 가능합니다. 설치도 필요없고, 필요할 때 바로 사용이 가능합니다.

{
  "serena": {
    "command": "/opt/homebrew/bin/uvx",
    "args": [
      "--from",
      "git+https://github.com/oraios/serena",
      "serena",
      "start-mcp-server"
    ],
    "env": {},
    "working_directory": null
  }
}

uvx 설치가 안되어 있다면, brew install uv 하면 끝, homebrew 설치되어 있지 않다면? 설마?? 그럼, 여기를 참고하세요.

여튼, uv를 설치하고 uvx –version 으로 제대로 실행이 되면, 각 툴의 MCP 설정에 들어가서, 상기와 같이 설정하면 끝입니다.

사용 화면

뭐.. 직접 사용해 보시면 아시겠지만. 아래와 같이 agent가 tool을 호출합니다.

지원하는 언어

바로 지원되는 언어는 아래와 같습니다. 뭐.. 쓰시는 언어가 정말 특별한 경우가 아니라면, 대부분 지원되는 듯 하네요.

  • Python
  • TypeScript/Javascript
  • PHP (uses Intelephense LSP; set INTELEPHENSE_LICENSE_KEY environment variable for premium features)
  • Go (requires installation of gopls)
  • R (requires installation of the languageserver R package)
  • Rust (requires rustup – uses rust-analyzer from your toolchain)
  • C/C++ (you may experience issues with finding references, we are working on it)
  • Zig (requires installation of ZLS – Zig Language Server)
  • C#
  • Ruby (by default, uses ruby-lsp, specify ruby_solargraph as your language to use the previous solargraph based implementation)
  • Swift
  • Kotlin (uses the pre-alpha official kotlin LS, some issues may appear)
  • Java (Note: startup is slow, initial startup especially so. There may be issues with java on macos and linux, we are working on it.)
  • Clojure
  • Dart
  • Bash
  • Lua (automatically downloads lua-language-server if not installed)
  • Nix (requires nixd installation)
  • Elixir (requires installation of NextLS and Elixir; Windows not supported)
  • Elm (automatically downloads elm-language-server if not installed; requires Elm compiler)
  • Scala (requires some manual setup; uses Metals LSP)
  • Erlang (requires installation of beam and erlang_ls, experimental, might be slow or hang)
  • Perl (requires installation of Perl::LanguageServer)
  • Fortran (requires installation of fortls: pip install fortls)
  • Haskell (automatically locates HLS via ghcup, stack, or system PATH; supports Stack and Cabal projects)
  • Julia
  • AL
  • Markdown (must be explicitly specified via --language markdown when generating project config, primarily useful for documentation-heavy projects)

자세한 내용은 아래 링크에서 확인가능합니다.

https://github.com/oraios/serena?tab=readme-ov-file#programming-language-support–semantic-analysis-capabilities

댓글 남기기