Labsco
MCP SERVER

CGM MCP Server

by yangweijie

Repository-level code analysis as a graph — structure extraction, related-entity lookup and packaged context — with or without an LLM in the loop.

Code Intelligence & Repository Indexing
Summary
Code structure first, model second.

The half that needs no API key is the half most people will use: point it at a repository and get entities, related code and packaged context that any model or editor can read. The LLM pipeline sits on top for issue-to-patch work, and that is where a provider and a cost enter. Choosing the model-agnostic tools here is a real option, not a degraded mode.

What it is

An MCP implementation of CodeFuse-CGM (Code Graph Model). It runs in two modes: model-agnostic tools that extract code structure with no API key at all, and a full pipeline — rewriter, retriever, reranker, reader — that uses an LLM to turn an issue description into a patch.

What you get
  • Repository structure and code entities for a path and query, with an analysis scope and a cap on files touched — `cgm_analyze_repository`
  • Detailed content and analysis for a specific list of files — `cgm_get_file_content`
  • Entities related to one named entity, optionally narrowed to particular relation types — `cgm_find_related_code`
  • Context packaged for another model to consume, as `structured`, `markdown` or `prompt` — `cgm_extract_context`
  • The LLM pipeline: submit an issue for resolution, analysis, bug fixing or feature implementation, then poll it — `cgm_process_issue`, `cgm_get_task_status`
  • Health, cache statistics, performance and GPU state as resources — `cgm://health`, `cgm://cache`, `cgm://performance`, `cgm://gpu`
  • A call to release GPU memory when a long session has filled it — `clear_gpu_cache`
Requirements

Python 3.8+. Clone, `pip install -r requirements.txt`, then start with `python main.py`. The model-agnostic analysis tools need no API keys. For the full pipeline choose a provider: cloud via `CGM_LLM_PROVIDER`, `CGM_LLM_API_KEY` and `CGM_LLM_MODEL`, local via `./scripts/start_local.sh --provider ollama --model deepseek-coder:6.7b`, or LM Studio via `--provider lmstudio`. GPU acceleration is optional — Apple Silicon MPS is detected automatically, NVIDIA and AMD need the matching PyTorch build, and CPU is the fallback.