ABC complexity gate for AI-written code with an MCP inspection tool.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
A must-have gate for AI-written code. Agents ship faster than humans can re-read; abcop keeps that code understandable by gating function and module ABC complexity so every unit fits a human head and an LLM context window. Diagnostics are also a hook for automated refactoring β extract a method, split a module β so CI rejects bad growth and points agents at concrete maintainability fixes.
One self-contained binary across Ruby, Rust, Python, Go, PHP, Java, C#, Dart, JavaScript, TypeScript, C, C++, Objective-C, Swift, Solidity, Zig and Haskell β no runtimes, no plugins, no per-language installs. Written in Rust for speed: one parse per file, one walk per metric, grammars compiled in; whole trees in milliseconds.
macOS (.tar.gz from GitHub Releases; binary + man):
Ubuntu / Debian (.deb from GitHub Releases; amd64, Ubuntu 22.04+ / Debian bookworm+):
Line counts lie. The ABC metric
(Jerry Fitzpatrick, C++ Report, June 1997) counts what does work β
assignments (A), branches (B), conditions (C) β as sqrt(AΒ² + BΒ² + CΒ²).
Fitzpatrick defined both method and module scope; abcop gates both:
| Rule | Severity | Meaning |
|---|---|---|
Metrics/AbcSize | C | function ABC above --max-abc (default 17) |
Metrics/ModuleAbcSize | W | module ABC above --max-module-abc (default 120) |
UsedOnce | W | local written once, read once β consider inlining |
NeverUsed | W | local written, never read |
A sparse wrapper and a dense god-object can share a line count; ABC separates them. Complexity is the gate β never a line budget. UsedOnce / NeverUsed are secondary.
1 plus stable JSON/JSONL diagnostics
(rule, score, vector, message) feed agents and scripts: split
oversized modules, extract hot methods. Each finding is an actionable
maintainability step, not a style nit.--max-abc and
--max-module-abc.abcop --mcp is the best way to use abcop from
an agent: the model gets offenses as soon as it writes, so it can fix
complexity and dead locals in the same turn and ship effective code
right away β not after a later CLI/CI pass. Official Rust
rmcp SDK; tool abcop_inspection.
Listed on the
MCP Registry as
io.github.adrianov/abcop (crates.io package + each GitHub v* tag).Inspired by RuboCop (Ruby AbcSize
parity and # rubocop:disable directives) and
lizard (one tool, many languages).
Ruby's counting matches RuboCop 1.89 byte-for-byte
(scripts/compare_parity.py).
rubocop --only Metrics/AbcSize (cache off), ~140Γ a full rubocop run.cache.redb) compiled in; works on clean CI images with no language
toolchains.--sort-by-score buffers for worst-first emit.| Option | Default | Meaning |
|---|---|---|
[PATH]... | auto | targets; omitted β scope selection |
--max-abc N | 17 | function ABC ceiling |
--max-module-abc N | 120 | module ABC ceiling |
--only abc|used-once|never-used | all | single check |
--full | off | whole production tree (default skips stay on) |
--everything | off | no gitignore / hidden / vendored pruning |
--format text|json|jsonl | text | CI-friendly output |
--sort-by-score | off | highest ABC first |
--mr | off | MR scope (uncommitted + branch vs base) |
--uncommitted | off | working-tree + index + untracked vs HEAD only |
--no-cache | off | skip on-disk cache |
--mcp | off | MCP server on stdio (for AI clients) |
--dump-tree FILE | β | debug syntax tree |
Exit codes: 0 clean, 1 findings, 2 usage error.
JSON diagnostics include file, line, column, severity, rule,
message, plus score / vector for ABC rules:
Named paths β those targets only.
Omitted β narrowest useful scope, announced on stderr:
HEAD if the tree is dirty--mr forces this)Default walks prune test/fixture trees, vendored/build output
(vendor/, node_modules/, target/, β¦), db/migrate/, route tables
(config/routes.rb, config/routes/*.rb), and generated names
(*.min.js, *_pb.go, β¦). Name a path explicitly to scan it anyway.
Third-party, route-table, and fixture paths are never scoped review
surface β a diff through vendor/ or tests/fixtures/ does not make
that material owned code.
Scoped ModuleAbcSize re-sums only methods that intersect the diff and
compares that total to --max-module-abc (default 120; untracked =
every method). A small patch into an oversized legacy file stays quiet
unless the touched methods themselves exceed the ceiling; AbcSize still
reports any changed method over --max-abc. Full scans (--full,
--everything) report every production module over the ceiling;
ModuleAbcSize still exempts test trees on full scans (scoped runs can
flag them when changed methods sum over the limit). UsedOnce /
NeverUsed always follow the changed lines.
On a dirty tree the bare default is uncommitted-only; --mr takes the
full branch union. Commits straight to main use a 36-hour window when no
branch base applies. --uncommitted fails outside a repository instead
of silently widening.
Everywhere except Rust, RuboCop-style # / // suppressions work
(trailing and block; bare Metrics allowed). rubocop:disable-next is
ignored, matching rubocop.
Preferred for LLM / agent workflows. Wire abcop as an MCP server so the
model can call abcop_inspection while it edits: feedback arrives in the
same turn, the agent corrects soon, and it writes maintainable code on the
first pass instead of discovering ABC / UsedOnce / NeverUsed only in CI.
abcop --mcp runs a long-lived MCP server on stdio β same idea as
RuboCopβs MCP
and rrubocop, with no Ruby mcp
gem. Tool:
| Tool | Purpose |
|---|---|
abcop_inspection | Analyse via path and/or inline source_code; returns compact offense JSON (code, line, column, message; score / vector for ABC rules) |
mcp-name: io.github.adrianov/abcopMetadata lives in server.json, which is part of the
Cargo package on crates.io. Each GitHub
v* release tag publishes that listing to the
MCP Registry (after the
crates.io upload).
Example client config (Cursor / VS Code / Windsurf):
Claude Code:
Intended for MCP clients, not interactive use.
Factual signals from GitHub, npm, and our automated checks β not a rating.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/abcop)<a href="https://allmcps.com/mcp/abcop"><img src="https://allmcps.com/api/badge/abcop?style=directory" alt="Abcop on AllMCPs" /></a>