abcop_inspection
Integrates with Git repositories to compare the working tree against HEAD, scope scans to uncommitted changes or merge request branches, and filter findings to edited functions.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@abcop_inspectionrun an ABC complexity inspection on src/main.rs"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
abcop
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.
Install
brew install adrianov/abcop/abcopcargo install abcopmacOS (.tar.gz from GitHub Releases; binary + man):
# Apple Silicon — use the *-x86_64-apple-darwin.tar.gz asset on Intel Macs
curl -LO https://github.com/adrianov/abcop/releases/download/v0.22.0/abcop-0.22.0-aarch64-apple-darwin.tar.gz
tar -xzf abcop-0.22.0-aarch64-apple-darwin.tar.gz
sudo cp abcop-0.22.0-aarch64-apple-darwin/abcop /usr/local/bin/
sudo mkdir -p /usr/local/share/man/man1
sudo cp abcop-0.22.0-aarch64-apple-darwin/abcop.1 /usr/local/share/man/man1/Ubuntu / Debian (.deb from GitHub Releases; amd64, Ubuntu 22.04+ / Debian bookworm+):
# example for v0.22.0 — use the asset name from the release page
curl -LO https://github.com/adrianov/abcop/releases/download/v0.22.0/abcop_0.22.0-1_amd64.deb
sudo dpkg -i abcop_0.22.0-1_amd64.deb
man abcopRelated MCP server: genpark-cyclomatic-complexity-refactoring-scout-skill
Example run
lib/sinatra/base.rb:1254:0: C: Metrics/AbcSize: Assignment Branch Condition size for `error_block!` is too high. [<7, 14, 9> 18.06/17]
src/main.rs: W: Metrics/ModuleAbcSize: Assignment Branch Condition size for module is too high. [<80, 200, 60> 228.04/120] -- extract a coherent subunit
132 files analysed in 0.09s, 7 abc offenses, 0 used-once offenses, 0 never-used warnings, 14 module-abc warningsWhy ABC, not line counts
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 |
| C | function ABC above |
| W | module ABC above |
| W | local written once and read once, inside a function the edit changed. |
| W | local written and never read, inside a function the edit changed. Same whole-tree switch as UsedOnce |
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.
Built for AI workflows
Understandable by construction. AbcSize 17 and ModuleAbcSize 120 keep every new unit inside a human head and an LLM context window. An existing unit may stay over that ceiling when the edit does not raise its score. Models edit small units reliably; when something breaks, the blast radius is tiny.
Refactoring hook. Exit code
1plus 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.Fast enough for every push. Sub-second whole-tree scans — including code an agent will never re-read tomorrow.
Signal only. No formatting or style cops. Vendored, generated and test trees are skipped by default. Knobs:
--max-abcand--max-module-abc.--fulland--everythingreport every hit, not only the current edit.Prefer MCP with LLMs.
abcop --mcpis 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 RustrmcpSDK; toolabcop_inspection. Listed on the MCP Registry asio.github.adrianov/abcop(crates.io package + each GitHubv*tag).
Inspired by RuboCop (Ruby AbcSize
parity and # rubocop:disable directives) and
lizard (one tool, many languages).
Ruby method counting matches RuboCop 1.89 byte-for-byte
(scripts/compare_parity.py). A block outside a method (match do,
before do, a class-level each) is its own unit; each / map /
select still roll into the block that contains them.
Advantages
~850k–940k LOC/s per core (Apple M1 Pro). RuboCop's lib tree (943 files, 110k LOC): 0.13 s — ~39× faster than
rubocop --only Metrics/AbcSize(cache off), ~140× a full rubocop run.One binary, zero deps — grammars and an embedded result cache (
cache.redb) compiled in; works on clean CI images with no language toolchains.Deterministic — same findings every run; text / JSON / JSONL stream as files finish;
--sort-by-scorebuffers for worst-first emit.
Usage
abcop [OPTIONS] PATH...Option | Default | Meaning |
| auto | targets; omitted → scope selection |
|
| function ABC ceiling |
|
| module ABC ceiling |
| all | single check |
| off | whole production tree, and every function over the ceiling plus every local (default skips stay on) |
| off | no gitignore / hidden / vendored pruning ( |
|
| CI-friendly output |
| off | highest ABC first |
| off | MR scope (uncommitted + branch vs base) |
| off | working-tree + index + untracked vs |
| off | skip on-disk cache |
| off | MCP server on stdio (for AI clients) |
| — | debug syntax tree |
Exit codes: 0 clean, 1 findings, 2 usage error.
abcop app lib # two trees; rises and edited functions only
abcop --format jsonl lib > abcop.jsonl # streaming CI / agent input
abcop --only used-once src # inline candidates in edited functions
abcop --max-abc 12 --only abc lib # stricter function budget
abcop --full lib # every function over the ceiling, every local
abcop --everything lib # same report, with no default pruning
abcop --max-module-abc 80 lib # stricter module budget
abcop --sort-by-score --only abc lib # worst first
abcop --uncommitted # pre-commit; rises and edited functions only
abcop --mr --only abc # branch files; still only ABC rises vs HEAD
abcop --mcp # MCP server on stdio (for AI clients)JSON diagnostics include file, line, column, severity, rule,
message, plus score / vector for ABC rules:
{"rule":"Metrics/AbcSize","score":10.0,"vector":"<6, 8, 0>"}
{"rule":"Metrics/ModuleAbcSize","score":120.5,"vector":"<40, 100, 40>"}Scope selection
Named paths — those targets only. Findings still follow the edit filter below.
Omitted — narrowest useful scope, announced on stderr:
uncommitted work vs
HEADif the tree is dirtyelse current MR (
--mrforces this)else the tree (outside a repo)
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.
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.
What a normal scan reports
Every scan except --full and --everything compares the working tree
to HEAD:
AbcSize reports a method over
--max-abconly when its score is strictly higher than the same method inHEAD(same name, source order). A score that stayed the same or fell stays quiet, including a legacy method that was already over the ceiling. A method that exists only in the working tree counts as an increase. The message asks to return to the previous score when that score was already over the ceiling (rose from 20 to 21 -- back to 20 or below). WhenHEADwas under the ceiling, the target is the ceiling (rose from 16.28 to 21.28 -- back to 17 or below).UsedOnce / NeverUsed report only inside a function whose text changed against
HEAD. A local in a function the edit did not touch stays quiet. Locals outside any function still report.ModuleAbcSize reports a module over
--max-module-abconly when its whole-file score is strictly higher than that file inHEAD. A score that stayed the same or fell stays quiet, including a legacy module already over the ceiling. A file that does not exist inHEADis held to the ceiling. The message asks to return to the previous score when that score was already over the ceiling (rose from 200 to 210 -- back to 200 or below). WhenHEADwas under the ceiling, the target is the ceiling.No
HEADblob (not a git checkout, or an untracked file) reports every method over the ceiling, every local, and every module over the ceiling.
--uncommitted and --mr also drop function and local findings on lines
the diff did not touch.
Whole-tree report
--full and --everything report every method over --max-abc, every
local, and every production module over --max-module-abc. ModuleAbcSize
still exempts test trees on those runs. --full keeps the default skips.
--everything lifts gitignore, hidden directories, and vendored/generated/test
pruning. ignore in the user config still applies to both.
User config
One file holds user options. It is $XDG_CONFIG_HOME/abcop when that
variable is set, otherwise ~/.config/abcop. $ABCOP_CONFIG replaces
the path. Nothing is written into the project.
ignore is a gitignore pattern, one option per line, applied in every
project relative to that project's root. A directory pattern covers
everything inside it. Naming the path, --full, and --everything do
not bring a match back. An MCP inspection of a matched path is empty.
ignore = app/services/legacy/
ignore = lib/old.rbDirectives
Everywhere except Rust, RuboCop-style # / // suppressions work
(trailing and block; bare Metrics allowed). rubocop:disable-next is
ignored, matching rubocop.
def legacy_path # rubocop:disable Metrics/AbcSize
...
endMCP (Model Context Protocol)
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 |
| Analyse via |
MCP Registry name:
mcp-name: io.github.adrianov/abcop
Metadata 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):
{
"mcpServers": {
"abcop": {
"type": "stdio",
"command": "abcop",
"args": ["--mcp"],
"cwd": "/path/to/your/project"
}
}
}Claude Code:
claude mcp add abcop -- abcop --mcpIntended for MCP clients, not interactive use.
Caching
Content-addressed cache under $XDG_CACHE_HOME/abcop (or ~/.cache/abcop;
override with ABCOP_CACHE_DIR). Warm reruns ~5× faster. Keys cover
contents, version, rule revision, threshold, checks and path — no
cross-project collisions. Auto-pruned to 20 000 entries; --no-cache
disables. Nothing is written inside the project.
Supported languages
Seventeen languages plus embedded JS in HTML/templates, four rules each, one CI gate.
Language | Files | Notes |
Ruby |
| RuboCop-parity method AbcSize; blocks outside methods are units |
Rust |
| |
Python |
| |
Go |
| |
PHP |
| |
Java |
| |
C# |
| |
Solidity |
| |
Dart |
| |
Zig |
| |
Haskell |
| |
JavaScript |
| also |
TypeScript |
|
|
Embedded JS |
| extract scripts; blank |
C / C++ |
|
|
Objective-C |
| |
Swift |
|
Named declarations are measured units; anonymous function-likes roll into
the enclosing unit; nested units never double-count. C-family: file-scope
globals are out of single-file reach; loop-head locals are protocol;
field writes also read the object; export-macro class forms
(class UTIL_EXPORT Foo) are skipped for variable rules.
Benchmarks
Apple M1 Pro, warm cache:
Corpus | Size | abcop | rubocop | Full rubocop |
rubocop/lib | 943 files, 110k LOC | 0.13 s | 5.1 s (~39×) | 18.3 s |
cargo registry sample | 6,603 files, 2.6M LOC | ~2.8 s | — | — |
¹ --cache false — rubocop's own cache otherwise makes repeats look free.
Development
cargo test
cargo build --all-targets # zero warnings
abcop src # dogfoodShared engine: src/scope_model/ (backend, walk, eval); language
collectors sit beside each backend (clike/, sollang/, …). Probe
grammar nodes with abcop --dump-tree FILE. Parity:
scripts/compare_parity.py.
License
GNU GPL v3 or later (SPDX: GPL-3.0-or-later). See LICENSE.
Copyright © 2026 Peter Adrianov. All rights reserved.
This server cannot be deployed
Maintenance
Related MCP Connectors
AI-powered codebase analysis — call graphs, security, dead code, complexity. 150+ tools.
Stateless TS/JS compiler facts for agents: references, imports, impact. No repo index or OAuth.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables coding agents to scan their work mid-session for dead seams — files reachable only by tests — returning the same JSON as the CLI.3 npmMIT
- FlicenseNot gradedqualityBmaintenanceEnables coding agents and developers to parse Python source into ASTs and compute complexity metrics that pinpoint refactoring hotspots, dead code, and breaking API diffs. It returns decomposition plans and dependency-graph telemetry over MCP, keeping token usage low with zero external dependencies.7-
- AlicenseNot gradedqualityAmaintenanceEnables AI coding agents and other MCP clients to interrogate a repository — or a frontend and backend pair — returning a single JSON document of findings such as which calls reach which routes, what is dead, and where to refactor first. Exposes tools like analyze_repo, cross_repo, check_endpoint, and check_coverage, along with contract resources for authoring adapters and rule packs, entirely over local stdio with no network access.MIT
- AlicenseNot gradedqualityCmaintenanceEnables coding agents to select bounded Python source context, run configured checks, and retrieve compact failure reports, diagnostic comparisons, and freshness evidence tied to the checked code.MIT