cgm_analyze_repositoryLABSCO 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,markdownorprompt—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.
Setup effort
Build from source — git clone https://github.com/yangweijie/cgm-mcp.git
USE CASES
Getting oriented in an unfamiliar repository
Analyze the tree for a query and read back the entities that matter, capped to a manageable number of files.
Following a symbol through the codebase
Ask for entities related to one name and narrow to the relation types you care about.
Feeding another model good context
Extract context for a query as markdown or as a prompt and hand it to whichever assistant you are using.
Turning an issue into a patch
Submit the issue description with repository context, then poll the task until the pipeline returns.
8 tools
Listed in project docs. Your client may show a different list.
cgm_get_file_contentcgm_find_related_codecgm_extract_contextclear_gpu_cachecgm_process_issuecgm_get_task_statuscgm_health_checkBEFORE YOU INSTALL
What to know first
Tools you get
8 tools named in the project's documentation.
Requires
Python 3.8+
Optional
CGM_LLM_API_KEY in your environment
Where it runs
All 4 documented setups run the server on your machine.
INSTALLATION
Connect your client
You clone this one yourself.
Server setup
Clone the repository
git clone https://github.com/yangweijie/cgm-mcp.git
cd cgm-mcpInstall dependencies
pip install -r requirements.txtMCP Clients
Claude Desktop
{
"mcpServers": {
"cgm": {
"command": "python",
"args": [
"<YOUR_PATH_TO_CGM_MCP>/main.py"
],
"env": {
"CGM_LLM_API_KEY": "<YOUR_CGM_LLM_API_KEY>"
}
}
}
}Claude Desktop — Model-less
{
"mcpServers": {
"cgm-modelless": {
"command": "python",
"args": [
"<YOUR_PATH_TO_CGM_MCP>/main_modelless.py"
]
}
}
}Cursor
{
"mcpServers": {
"cgm": {
"command": "python",
"args": [
"<YOUR_PATH_TO_CGM_MCP>/main.py"
],
"cwd": "<YOUR_PATH_TO_CGM_MCP>",
"env": {
"CGM_LLM_PROVIDER": "cursor_native",
"CGM_LOG_LEVEL": "INFO"
}
}
}
}Augment
{
"mcpServers": {
"cgm": {
"command": "python",
"args": [
"<YOUR_PATH_TO_CGM_MCP>/main.py"
],
"env": {
"CGM_LLM_PROVIDER": "augment_native",
"CGM_LOG_LEVEL": "INFO"
}
}
}
}