CodePecker
Click on "Install 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., "@CodePeckerReview this code for security and standards issues and fix them."
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.
CodePecker
An MCP server that reviews a piece of code across four dimensions — security, standards, production readiness, sustainability — automatically fixes the issues, verifies the fix by running the code's tests, and reports what it did. Any MCP-capable agent (Claude Code, Codex, Copilot) can call it as a tool; there's also a CLI for local demos.
review → remediate → run tests → repeat (bounded) → findings + scorecard + fixed code + diff + citationsQuickstart (30 seconds)
git clone <this repo> && cd CodePecker
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt && pip install -e . --no-deps
cp .env.example .env # add a free Groq key — see Setup
codepecker examples/urlshortener_sample/store.py # review a flawed sample fileNo key yet? pytest -q runs the whole suite fully offline. Full details, other
providers, and MCP client wiring are below.
Related MCP server: code-review-mcp-server
How it works
For each of the four dimensions, CodePecker gathers findings two ways:
Deterministic checks (regex/code) for rules that must be caught reliably — hardcoded secrets,
eval/unsafe deserialization, bareexcept, missing tests. No LLM, so they never "forget".An LLM judge for the nuanced rules (input validation, logging, timeouts, N+1 queries, …), with guardrails: it may only cite rules from the batch it was given, any evidence it quotes must appear in the code, and severity/dimension come from the rule metadata — hallucinated findings are dropped in code.
Each rule lives in a markdown file in codepecker-skill/rules/ (RAG), tagged
deterministic: true|false so it's enforced by exactly one path. A hand-written,
bounded agent loop then asks the model to remediate and re-runs the tests — a fix
that resolves a finding but breaks the tests is not accepted.
The rule corpus is packaged as an Agent Skill: codepecker-skill/ is a valid
skill (a SKILL.md entry point over the same rules/ folder). So the same corpus
serves two surfaces from one source of truth — a Claude agent can load it as a skill
to suggest fixes at the desk, and the MCP server reads the same rules/ to
enforce them (deterministic checks, guardrails, test-verified remediation). One
corpus, no drift: the skill suggests, the MCP tool guarantees.
Setup
Requires Python 3.10+.
git clone <this repo> && cd CodePecker
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
pip install -e . --no-deps # makes `codepecker` + `python -m codepecker.*` work
cp .env.example .env # then add your key (below)Verify the install (fully offline — no key needed):
pytest -q # the test suite should passKeys — the default needs just one. Text runs on Groq (fast Llama 3.3 70B) and
embeddings run locally (no key). Put your Groq key in .env:
GROQ_API_KEY=... # free key at https://console.groq.com/keysProvider-agnostic via LiteLLM — switch model or provider with no code change,
e.g. CODEPECKER_TEXT_MODEL=openai/gpt-4o (one key does both), or go fully offline
with CODEPECKER_TEXT_MODEL=ollama/llama3.1. See .env.example.
Usage
CLI (local demo)
codepecker examples/urlshortener_sample/store.py
# or: python -m codepecker.cli examples/urlshortener_sample/store.pyPrints the findings, a rule-coverage scorecard (how the code did against all
rules per dimension — passes included, so you can attest coverage, not just
violations), the remediated code, a unified diff, the rules cited, and a metrics
summary. Each run is appended to metrics.jsonl.
If the file imports sibling modules, pass them with --support (repeatable) so the
sandbox can run the code's tests instead of failing on the import:
python -m codepecker.cli examples/urlshortener_sample/service.py \
--support examples/urlshortener_sample/store.py \
--support examples/urlshortener_sample/shortener.pyUseful flags:
Flag | What it does |
| run the code's test file (it should import the code as |
| confirm tests exist (rule RDY-03) without running them — the way to attest coverage in detect-only mode |
| add a sibling module the code imports (repeatable) |
| detect-only: report findings but never call the model to rewrite the code — bounds token burn when you just want a report |
A realistic, multi-file example. examples/auth_sample/ is an auth module split
across several files (hardcoded secrets, weak crypto, missing validation) — closer to
real code than a single snippet. Review its entry point, bringing the siblings it
imports so the sandbox can run the tests:
python -m codepecker.cli examples/auth_sample/auth.py \
--support examples/auth_sample/crypto.py \
--support examples/auth_sample/db.pySee examples/GROUND_TRUTH.md for the exact issues this auth sample is seeded with.
Reliable live demo: the loop makes many LLM calls, so a free tier's tokens-per-minute cap can throttle a full run. The loop is resilient — a mid-run rate limit is recorded and the review still completes (with degraded coverage noted) rather than crashing. For a smooth end-to-end demo, use a higher-limit tier or run the text model locally:
CODEPECKER_TEXT_MODEL=ollama/llama3.1(no key, no limits).
MCP server (in a coding agent)
CodePecker speaks MCP over stdio — no ports, no daemon. Every client points at the same command; only the config file and its shape differ:
command
/absolute/path/to/CodePecker/.venv/bin/pythonargs
["-m", "codepecker.server"]env
GROQ_API_KEY(or whichever provider key your model IDs need)
Use the absolute path to the venv's Python so the agent inherits CodePecker's dependencies. Sanity-check that it launches (it waits on stdio; Ctrl-C to exit):
python -m codepecker.serverclaude mcp add codepecker \
--env GROQ_API_KEY=your-key \
-- /absolute/path/to/CodePecker/.venv/bin/python -m codepecker.serverAdd --scope project to share it with your team via a checked-in .mcp.json.
Create .vscode/mcp.json in the workspace — note the top-level servers key and
the type field (VS Code's shape differs from the mcpServers one below):
{
"servers": {
"codepecker": {
"type": "stdio",
"command": "/absolute/path/to/CodePecker/.venv/bin/python",
"args": ["-m", "codepecker.server"],
"env": { "GROQ_API_KEY": "your-key" }
}
}
}Open Copilot Chat → switch to Agent mode → codepecker shows up in the tools
picker. (To avoid hardcoding the key, use VS Code's "inputs" secret prompt.)
Identical mcpServers block; only the file location differs:
Cursor —
.cursor/mcp.json(project) or~/.cursor/mcp.json(global)Windsurf —
~/.codeium/windsurf/mcp_config.jsonClaude Desktop —
claude_desktop_config.json(macOS:~/Library/Application Support/Claude/)
{
"mcpServers": {
"codepecker": {
"command": "/absolute/path/to/CodePecker/.venv/bin/python",
"args": ["-m", "codepecker.server"],
"env": { "GROQ_API_KEY": "your-key" }
}
}
}Add to ~/.codex/config.toml (TOML, not JSON):
[mcp_servers.codepecker]
command = "/absolute/path/to/CodePecker/.venv/bin/python"
args = ["-m", "codepecker.server"]
env = { GROQ_API_KEY = "your-key" }MCP config conventions move fast. If a client has renamed a key or moved its config file, check that client's own MCP docs — only the
command/args/envvalues above are CodePecker-specific.
The server exposes one tool:
review_and_remediate(code, language="python", tests="", tests_dir="", support_files={})code — the source to review.
tests (optional) — a separate test file; the code should import as
solution(from solution import ...). Passing it runs the tests and suppresses the "no tests" finding.tests_dir (optional) — path to the code's test directory; confirms tests exist (rule RDY-03) without running them. This is how coverage is attested in detect-only mode (
CODEPECKER_REMEDIATE=false), which skips test execution.support_files (optional) —
{"sibling.py": "<source>", …}for modules the code (or its tests) imports, so they resolve in the sandbox instead of crashing test collection.
Detect-only vs. remediate is controlled by the CODEPECKER_REMEDIATE env var (default
true); set it false to report findings without ever calling the model to rewrite
code — the same behaviour as the CLI's --no-remediate.
Evaluation
python eval/run_eval.pyRuns CodePecker over the labeled golden set (eval/golden/) and reports
precision/recall/F1 per dimension, remediation resolution + test-pass rates, and mean
iterations/latency; writes eval/report.json. This is the "how do I know it's good?"
evidence and is meant to run in CI. (It drives the full loop over every sample, so use
a decent rate-limit tier.)
Design decisions (the short "why")
Decision | Why |
MCP server, not a bot/CI check | Reusable across agents, and reviews in the loop rather than post-hoc |
Hand-written loop, no LangChain | Bounded task; transparent and testable control flow |
RAG over fine-tuning for rules | Rules stay editable, auditable, and citable (markdown files) |
Deterministic secrets/eval/except vs LLM for nuance | Reliability where it's non-negotiable, flexibility where it's fuzzy |
Tests gate success | A fix that breaks behavior is a failure, not a fix |
Judge guardrails (constrained citations + evidence grounding) | Hallucinated findings are dropped by code, not trusted |
One LLM seam (LiteLLM behind | Swapping provider — or going offline — is a config change |
Sandboxed test run (subprocess + timeout) | Executing untrusted code is a security boundary |
Project layout
src/codepecker/
config.py env-driven model IDs + tuning constants
types.py LLM Protocols (DIP/ISP) + the Finding type
llm_client.py the only module that talks to a provider (LiteLLM)
vector_store.py ChromaDB adapter (RAG index)
knowledge/loader.py parse + embed the markdown knowledge banks
tools/
deterministic_checks.py code checks, keyed by rule id
judge.py batched, guardrailed LLM judge
run_tests.py sandboxed pytest runner
agent.py review_and_remediate() — the bounded loop
metrics.py append-only metrics log + summary
evaluation.py pure detection/remediation metrics (used by eval/run_eval.py)
cli.py local demo runner
server.py FastMCP server (stdio)
codepecker-skill/ the corpus as an Agent Skill (one source of truth)
SKILL.md agent-facing entry point (the "suggest" surface)
rules/ the rules: security/ standards/ readiness/ sustainability/
eval/ golden samples + run_eval.py
tests/ the test suiteTesting
pytest -q # 97 offline tests (local embeddings, faked LLM)
pytest -m "live or not live" # + the 1 live acceptance test (needs GROQ_API_KEY)The default suite is fully offline and deterministic; the one live test is opt-in.
Non-goals / next steps
MVP simplifications, called out honestly:
Sandbox is a subprocess + timeout, not a container — production wants gVisor/a microVM with no network and resource limits.
Deterministic checks are regex-based — production would use AST analysis.
Local embeddings (all-MiniLM-L6-v2) trade recall for zero keys — swap in a hosted embedder for higher-quality retrieval at scale.
Not yet: metadata-routed retrieval for very large rule sets, a metrics dashboard, real GitHub integration, runtime energy profiling, remote HTTP/Cloud Run deploy.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server for comprehensive code analysis, navigation, and quality assessment across 25+ programming languages.988MIT
- AlicenseNot gradedqualityFmaintenanceAn MCP server that provides senior-level code review, quality checks, security analysis, and refactoring suggestions directly in your editor.1MIT
- FlicenseNot gradedqualityCmaintenanceMCP server for AI-powered code security, quality, and performance review. Enables auditing code directly from VS Code via right-click or MCP tools.
- FlicenseNot gradedqualityDmaintenanceMCP server that provides code validation rules and analysis for various stacks/frameworks, enabling automated code reviews and reporting directly from VS Code and other editors.
Related MCP Connectors
Scan any public GitHub MCP-server repo for security issues. 37 MCP-specific L1 rules, 8 languages.
Conformance checker for MCP servers. Free, no key, verdicts recomputable and re-measured daily.
MCP server for static security analysis of Android source code
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Abdul4code/CodePecker'
If you have feedback or need assistance with the MCP directory API, please join our Discord server