About Portfolio Cases Services Blog Contact 🎙 Talk to AI
EN DE RU
🎙 Talk to AI
August 3, 2026 · 3 min read

Cut Your AI Coding Costs: jcodemunch-mcp Server Slashes Token Spend by 95%+ for Code Exploration

I'm Denis Shokhirev, Enterprise AI architect based in Erlangen, Germany. At DennisCraft AI Studio, I deliver production AI for DACH B2B clients on a stack of Claude, Supabase, n8n, Doppler, and self-hosted Postgres. Last month, a logistics client handed me a 60,000-line Python repo and asked for a quick security review—without burning their entire LLM token budget. This is a common pain in regulated industries: the real costs hit when scaling AI code analysis. Why AI Code Analysis Eats Budgets

Denis Shokhirev
Denis Shokhirev
Agentic AI Systems Architect
Telegram LinkedIn

I'm Denis Shokhirev, Enterprise AI architect based in Erlangen, Germany. At DennisCraft AI Studio, I deliver production AI for DACH B2B clients on a stack of Claude, Supabase, n8n, Doppler, and self-hosted Postgres. Last month, a logistics client handed me a 60,000-line Python repo and asked for a quick security review—without burning their entire LLM token budget. This is a common pain in regulated industries: the real costs hit when scaling AI code analysis.

Why AI Code Analysis Eats Budgets

In my recent projects, LLMs like Claude Code and GPT-4 are central for static code review, identifying risky patterns (SQL injection, privilege escalation, weak cryptography). But API costs add up fast: at $20–$40 per million tokens (Anthropic API pricing, June 2024), one audit can easily top $100 for a mid-size repo.

Where Most Teams Waste Tokens

Most teams send their entire codebase straight to the LLM. The result: 80% of tokens go to boilerplate, autogenerated code, and legacy files—none of which are relevant for targeted analysis. The challenge is to send only what truly matters, without missing critical context.

How jcodemunch-mcp Works: Targeted Code Chunking

jcodemunch-mcp is a lightweight server I deploy to preprocess large codebases before touching the LLM. Its job: extract just the relevant code blocks, deduplicate, build a minimal dependency tree, and package code into tight, context-rich chunks for prompts.

Stack and Architecture

  • Core: Python 3.11 + FastAPI
  • Code parsing: tree-sitter, ast
  • Semantic filter: semgrep, bandit, gitleaks
  • Integration: n8n for orchestration, Supabase for storage, Claude Code (Anthropic SDK)

This is classic data preprocessing, not magic: it strips code down to what actually matters for the LLM’s context window.

Concrete Numbers: Real Token Savings

Method Avg Input Size (tokens) Cost for 60k Lines Preprocessing Time Audit Quality
Whole Repo to LLM 2,400,000 $48–$96 5 min High false positives
Manual Chunking/Filtering 400,000 $8–$16 2 hours Better, but manual errors
jcodemunch-mcp Preprocessing 90,000 $1.80–$3.60 12 min Targeted, high-precision

That’s a 95%+ reduction in token usage. More importantly, only the risky, relevant code hits the LLM—improving both cost and audit accuracy.

Step-by-Step: The Pipeline in Production

Launching Preprocessing


from fastapi import FastAPI, UploadFile
import subprocess

app = FastAPI()

@app.post("/analyze/")
async def analyze_repo(file: UploadFile):
    repo_path = "/tmp/repo"
    with open(repo_path + ".zip", "wb") as f:
        f.write(await file.read())
    subprocess.run(["unzip", repo_path + ".zip", "-d", repo_path])
    # Run jcodemunch-mcp preprocessing
    subprocess.run(["python3", "jcodemunch_mcp.py", repo_path])
    # ...then integrate with n8n and Claude
    return {"status": "ok"}

Filtering and Compaction


import semgrep

def filter_code(repo_path):
    findings = semgrep.run("--config", "p/ci", repo_path)
    relevant_files = [f for f in findings if "security" in f["check_id"]]
    return relevant_files

The output: a JSON with only the minimal high-risk chunks, ready for LLM review via an n8n workflow.

Common Pitfalls and Practical Solutions

Missed Critical Code

If your semgrep or bandit rules are too narrow or default, you’ll miss important risky code sections. I always tune rules per project and cross-check with human review.

Chunk Boundaries

Claude and GPT-4 context windows work best when you chunk at function/class boundaries, not arbitrary line counts. tree-sitter gets you close, but often needs post-processing for accuracy.

CI/CD Integration

Best results come from plugging jcodemunch-mcp into your n8n flow as a preprocessing step before the LLM call. This cuts unnecessary jobs and keeps token spend predictable.

FAQ

Can I use only open-source tools?

Yes. tree-sitter, semgrep, bandit, and FastAPI are fully open source. You’ll only need an API key for your LLM (Claude, GPT-4, etc.).

Does this work for multi-language repos?

Yes—just configure the correct parsers in jcodemunch-mcp for each language.

What’s the ideal chunk size for LLM prompts?

400–1200 lines per chunk is the sweet spot: fits context windows, preserves function-level logic, and minimizes context loss.

Can preprocessing run locally?

Absolutely. jcodemunch-mcp runs as a Docker container, so you can preprocess locally before sending to your LLM pipeline.

Should I trust LLM code audits alone?

No. I always combine LLM audits with static analysis (semgrep, bandit) and manual review. See OWASP’s AI/LLM guidelines (2024) for more: OWASP Top 10 for LLM Apps.

Where do you see the biggest token waste in your LLM-aided code audits—preprocessing, chunking, or the LLM step itself? I genuinely want to hear from production teams. I run a free 30-min stack audit for DACH founders building AI in regulated markets. DM me on LinkedIn or write to @ger_dennis_ai.

Continue reading
How to Turn Codebase Chaos into a Queryable Knowledge Graph in 1 Day: The Graphify Case
Your AI Agent Can Be Hacked via Plugins: How to Secure Claude Code and Codex Skills in Production
OpenAI Codex hard resets usage limits after unexpected drains — how to protect production from API quota shocks
172 Production-Ready Claude Code Skills: How to Accelerate AI Agent Integration into Business Workflows (Without the Pain)
All articles →
Ready to build?

Turn your process into an AI system

Fixed price. Production quality. DACH B2B focus.

Start a project → ← All articles