convez.ai
MCP ServerDevOps & InfraestruturaAvançado
anatolykoptev

go-code MCP Server

anatolykoptev/go-code

Inteligência de código com AST, grafos de chamadas e análise estrutural para 16 linguagens

Ver no GitHub
BomPluginScore · de 0 a 100

Servidor MCP de inteligência de código baseado em análise AST com tree-sitter. Oferece 30 ferramentas para busca semântica, rastreamento de chamadas, detecção de código morto, análise de impacto e investigação de incidentes em repositórios locais ou GitHub.

Instalação

$npx convez-ai anatolykoptev/go-code

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
7
Forks
2
Acompanhando
0
Saúde
71%
Último commit
há 2 dias
Versão
v1.76.0
Issues abertas
113
Contribuidores
1

Casos de uso

  • Análise profunda de repositórios e arquitetura de código
  • Rastreamento bidirecional de cadeias de chamadas com detecção de ciclos
  • Investigação de root cause em incidentes de produção (integração Prometheus + Jaeger)
  • Detecção e remoção de código morto com confiança cross-encoder
  • Busca semântica híbrida (BM25F + embeddings + grafos de conhecimento)
  • Análise de impacto e blast radius de mudanças

Veredito

Ferramenta profissional e abrangente para engenharia de código em larga escala. Combina análise estática sofisticada (AST, grafos de chamadas, taint tracking) com recursos operacionais (investigação de incidentes, análise de impacto). Ideal para times que trabalham com monorepos complexos ou precisam automatizar revisões de código e análise de risco — exige investimento em setup mas oferece ROI significativo.

README

A tradução para o português deste README ainda está na fila.

go-code

Code intelligence MCP server powered by tree-sitter AST parsing. Analyzes repositories, compares implementations, traces call chains, and searches symbols across any codebase — GitHub or local.

Features

  • 16 languages — Go, Python, TypeScript/JavaScript, Rust, Java, C, C++, Ruby, C#, PHP, Svelte, Astro, Kotlin, Swift, HTML
  • 30 MCP tools — code search, AST analysis, knowledge graph queries, observability ⇄ code (debug_investigate), structural rewrite, code review, design search
  • Multiple analysis modes — deep (clone + AST + LLM), quick (GitHub Code Search), issues/PRs
  • Call chain tracing — bidirectional BFS with cycle detection and LLM narrative
  • Code comparison — three-pass symbol matching (exact/fuzzy/semantic) with quality verdicts
  • Knowledge graph — Apache AGE graph with NL-to-Cypher query generation
  • Caching — LRU in-memory + optional Redis L2 (200x speedup on repeated queries)
  • Learnings — prior review verdicts auto-surface in understand

Tools

ToolDescription
repo_analyzeAnalyze a repository. Deep mode (AST + LLM), quick mode (GitHub Code Search), or issue/PR search
repo_searchDiscover GitHub repos via parallel SearXNG + GitHub API search with LLM-ranked results
file_parseParse a single file with tree-sitter. Returns symbol table or raw AST
code_compareCompare two repositories structurally — architecture, API design, code quality
dep_graphBuild dependency graph. Output as Mermaid, Graphviz DOT, or JSON
symbol_searchSearch symbols (functions, types, consts) by name pattern across a repo
call_traceTrace call chains — callees (forward) or callers (reverse) with depth control
code_graphQuery a persistent code knowledge graph in Apache AGE via natural language
debug_investigate7-phase prod incident root cause: Prom spikes + Jaeger failed traces + symbol resolution + callgraph walks + LLM fusion + runtime binary drift → ranked file:function
semantic_searchHybrid RRF: BM25F + pgvector + 1-hop AGE graph expansion. Find by concept, not keyword
understandType-aware symbol deep-dive. Aggregates call_trace + symbol_search + complexity + tested_by + dead_code_score
impact_analysisBlast radius up to depth 10. Direct callers, transitive callers, hotspot reordering by churn
prepare_changePre-change risk: impact + dead_code combined
dead_codeCross-encoder confidence [0..1] per symbol (CE reranker), not flat list
dataflow_analyzeIL/CFG taint tracking + dead stores + SQL/cmd injection sinks
rewriteStructural AST search-replace with $WILDCARDS across 16 languages, dry-run + apply
review_prDifferential blast radius between git refs; persists per-symbol learnings
review_deltaDifferential blast radius between git refs; persists per-symbol learnings
code_researchBM25F + embeddings + DAG expansion for 10k+ file monorepos
design_searchFind DESIGN.md systems by UI description (multilingual-e5-large 1024-dim)
resolve_frameUnminify a JS stack frame via source maps
site_analyzeTech stack + SEO audit, BFS crawler
site_crawlBFS crawler
code_healthRepo grade A-F: complexity, test coverage, dep freshness, OSV vulns
exploreQuick repo overview, sub-second, no LLM, no clone for remote repos
fleet_versionsDiff pinned container image references in indexed source (Dockerfile, docker-compose*.yml) against deployed runtime containers. Probes local docker socket by default; ssh://[user@]host[:port] reaches remote hosts via the system ssh client (requires GOCODE_FLEET_SSH_ENABLE=true). Catches the "config aligned, source looks right, behaviour wrong" bug class where prod runs a different binary version than the repo pins.
remember_graph_insightsPersist learnings surfaced in future understand calls
wp_plugin_searchSearch WordPress.org plugin directory

Optional: dead_code and code_health tools integrate with ox-codes, an internal Rust code analysis service. Without it, these tools degrade to AST-only heuristics and still produce useful results.

Runtime version awareness

When a production bug lives at the deployed binary level rather than in source — pinned tag drift, sibling-host divergence, silent auto-updates — go-code can probe the running containers and diff them against what the indexed repo pins.

Two surfaces:

  1. fleet_versions — explicit tool. Pass host (optional, defaults to local docker socket) and service (optional filter). Returns per-target image diff with status: Match / TagDrift / DigestDrift / OnlySource / OnlyRuntime / Unresolved.

  2. debug_investigate — Phase 7 runs automatically when an investigation is started with host set. Drift is included in the LLM prompt with priority-capped cardinality (top 20 non-Match diffs, sorted TagDrift > DigestDrift > Unresolved > OnlyRuntime > OnlySource).

SSH probe

Reaching a remote host uses the system ssh binary directly — go-code does not maintain its own SSH stack. This means ~/.ssh/config (ProxyJump, agent, identities, port, known_hosts) is the single source of truth and you get all of it for free. The driver is disabled by default; enable with GOCODE_FLEET_SSH_ENABLE=true.

Commands executed on the remote host are limited to an internal allowlist: exactly docker ps --no-trunc --format={{json .}}. Filter values are regex-validated before any exec call.

Configuration

EnvDefaultPurpose
GOCODE_FLEET_DEFAULT_HOST""Fallback host for debug_investigate Phase 7. Empty = skip.
GOCODE_FLEET_DOCKER_SOCKET/var/run/docker.sockLocal docker engine socket path.
GOCODE_FLEET_SSH_ENABLEfalseSecurity gate. Must be true to use ssh:// targets.
GOCODE_FLEET_SSH_BINARYsshSystem ssh binary; PATH-resolved by default.
GOCODE_FLEET_TIMEOUT10sPer-probe timeout.

Quick Start

Docker (recommended)

docker build -t go-code .
docker run -p 8897:8897 \
  -e LLM_API_BASE=http://host.docker.internal:8317/v1 \
  -e LLM_API_KEY=your-key \
  go-code

From source

Requires Go 1.24+ and a C compiler (CGO for tree-sitter grammars).

make build    # → bin/go-code
./bin/go-code

Register as MCP server

claude mcp add -s user -t http go-code http://127.0.0.1:8897/mcp

Usage Examples

Analyze a GitHub repo

{
  "tool": "repo_analyze",
  "arguments": {
    "repo": "golang/go",
    "query": "How does the garbage collector work?"
  }
}

Quick code search (no cloning)

{
  "tool": "repo_analyze",
  "arguments": {
    "repo": "anthropics/claude-code",
    "query": "MCP tool registration",
    "mode": "quick"
  }
}

Search issues and PRs

{
  "tool": "repo_analyze",
  "arguments": {
    "repo": "golang/go",
    "query": "generics performance",
    "type": "issue"
  }
}

Compare two implementations

{
  "tool": "code_compare",
  "arguments": {
    "repo_a": "gin-gonic/gin",
    "repo_b": "labstack/echo",
    "query": "middleware architecture and routing"
  }
}

Trace call chains

{
  "tool": "call_trace",
  "arguments": {
    "repo": "owner/repo",
    "function": "handleRequest",
    "direction": "callees",
    "depth": 5
  }
}

Analyze a local directory

{
  "tool": "repo_analyze",
  "arguments": {
    "repo": "/home/user/src/my-project",
    "query": "How is authentication implemented?"
  }
}

Configuration

VariableDefaultDescription
MCP_PORT8897HTTP server port
LLM_API_BASEhttp://127.0.0.1:8317/v1OpenAI-compatible LLM endpoint
LLM_API_KEY(optional)API key for LLM — see LLM dependency below
LLM_MODELgemini-2.5-flashModel name
GITHUB_TOKEN(optional)GitHub token for higher API rate limits
WORKSPACE_DIR/tmp/go-code-workspaceTemp directory for cloned repos
MAX_FILE_KB512Max file size to parse (KB)
MAX_REPO_MB200Max repo size to accept (MB)
REDIS_URL(optional)Redis URL for L2 cache
DATABASE_URL(optional)PostgreSQL DSN for Apache AGE code graph
SEARXNG_URLhttp://searxng:8888SearXNG instance for repo_search

LLM dependency

LLM_API_KEY is optional. The server starts and most tools operate without it. The exact behavior per tool category when LLM_API_KEY is unset:

CategoryToolsBehavior without LLM_API_KEY
Hardcode_graph (NL query), repo_searchReturns MCP error: "requires LLM_API_KEY to be set"
Softrepo_analyze (quick/raw modes), repo_analyze_issuesReturns deterministic results + (LLM unavailable) marker
Augmentcall_trace, dead_code, impact_analysisReturns full core output; narrative/augmentation fields are empty
Debugdebug_investigateRuns deterministic phases (trace analysis, metric spikes, alert violations); LLM hypothesis ranking is skipped with LLMSkippedReason: "LLM_API_KEY not set"

Set LLM_API_BASE + LLM_API_KEY + LLM_MODEL to enable all tools. Any OpenAI-compatible endpoint works (OpenAI, Anthropic via proxy, local Ollama, etc.).

Architecture

cmd/go-code/          — MCP server, tool handlers (one file per tool)
internal/
  parser/             — tree-sitter AST parsing, 16 language handlers
  ingest/             — repo cloning, file walking, gitignore filtering
  clean/              — smart code cleaning for LLM context
  render/             — rendering modes (signatures, skeleton, focused)
  analyze/            — analysis orchestration
  compare/            — structural diff engine
  callgraph/          — call chain tracing (BFS/DFS, bidirectional)
  codegraph/          — Apache AGE knowledge graph
  github/             — GitHub API (search code/issues/repos, metadata)
  search/             — SearXNG web search client
  llm/                — LLM client with retry + fallback keys
  cache/              — generic LRU cache with Redis L2
  retry/              — exponential backoff with jitter
  metrics/            — atomic operation counters

Analysis Modes

Deep mode (default)

Clones the repo, walks the file tree, parses ASTs with tree-sitter, builds a symbol table, and answers questions via LLM. Supports depth (overview/module/deep) and mode (signatures/skeleton/focused) for controlling context size.

Quick mode (mode=quick)

Uses GitHub Code Search API — no cloning. Returns code fragments matching the query, optionally summarized by LLM. Use mode=raw for fragments without LLM processing.

Issues/PRs mode (type=issue or type=pr)

Searches GitHub Issues/Pull Requests API. Returns structured results with state, labels, author, and LLM analysis of trends and patterns.

Transport

  • HTTP (default): Streamable HTTP on MCP_PORT
  • Stdio: ./go-code --stdio — for pipe/SSH access

Build

make build      # Build binary (CGO required)
make lint       # Run golangci-lint
make test       # Run tests
make deploy     # Docker build + deploy

License

License Apache 2.0 — Copyright 2026 Anatoly Koptev

Contributing

See CONTRIBUTING.md for how to add new tools and languages.

For security vulnerabilities, see SECURITY.md.

Ver o original no GitHub

Bom para

Relacionados