Skip to main content

Non-AI static analysis layer for AI IDEs and coding agents - bug detection, security scanning, and CVE checking via MCP

Project description

mustel

PyPI version PyPI Downloads Python 3.10+ License: MIT

Mustel is a static analysis orchestrator designed for AI-assisted development environments (such as Cursor, Windsurf, or Claude Code). It coordinates Ruff, Bandit, Oxlint, Pip-Audit, and custom YAML patterns in parallel, operating in two modes:

  • Dev Mode (Default): Executes only local, non-networked checks (Ruff, Oxlint, and custom rule patterns) during editor save loops. Version 0.3.0 introduces a stat-based (mtime + size) cache, reducing incremental scan latency from 300ms (in v0.2.0) to under 30ms (in v0.3.0), providing a 10x speed improvement that allows real-time feedback.
  • Audit Mode: Triggered inside pre-commit hooks or CI/CD pipelines (when CI, GITHUB_ACTIONS, or PRE_COMMIT variables are present). Enables deep security scans (Bandit) and package audits (pip-audit) to prevent vulnerabilities from being committed.

The Problem

When AI agents review or edit a codebase, they consume thousands of tokens reading full file contents simply to parse class and method relationships. Additionally, when they write code with syntax or import errors, developers must spend manual chat turns copying and pasting tracebacks to resolve them.

The Solution

Mustel runs locally to provide:

  • Repository Mapping: Exposes a compressed, 1,500-token skeleton (get_code_map) of classes, functions, and docstrings so the agent learns your codebase structure without opening raw files.
  • Save Guardrails: Catches compile and syntax errors on file save, injecting an immediate === MUSTEL GUARDRAIL ALERT === block directly into the agent's tool output to enforce correction before user review.
Your Code -> mustel (Dev/Audit) -> Token-Saved JSON/Text -> AI Agent -> Instant Fixes

⚡ Key Architecture & Design

1. Dual-Execution Modes (Zero Configuration)

Mustel switches its execution profile dynamically based on environmental indicators:

  • Dev Mode (Default): Automatically triggered on editor save events and MCP reviews. Runs only local, non-networked checks (Ruff, Oxlint, local pattern files) and leverages a stat-based cache (checking file modification time and size) to keep incremental latency under 30ms.
  • Audit Mode: Triggered inside pre-commit hooks or CI/CD pipelines (when CI, GITHUB_ACTIONS, or PRE_COMMIT variables are present). Enables security checks (Bandit) and package dependency audits (pip-audit).

2. Repository Mapping (get_code_map)

Exposes codebase mapping tools via the get_code_map MCP tool and mustel map CLI command. It parses the project structures using AST parsing for Python/Jupyter and regex-based scanning for JS/TS, producing a highly compressed code skeleton (classes, method signatures, arguments, and docstrings) that fits under 1,500 tokens for average repositories, reducing initial context-loading token consumption by up to 95%.

3. Save Loop Guardrails

Mustel intercepts file save events via the editor. If syntax, compile, or import errors are found, it inserts a high-priority === MUSTEL GUARDRAIL ALERT === block in the tool output, directing the AI agent to resolve compiling issues in 1 turn before presenting the changes to the user.

4. Language & Environment Support

  • Javascript & TypeScript: Integrated oxlint engine to provide sub-millisecond JS/TS checks.
  • Jupyter Notebooks: Native parser that extracts Python code cells from .ipynb JSON models, running all custom rules against notebooks.
  • Rule Sets: Local YAML rule matching engine supporting standard libraries and data frameworks (pandas, numpy, streamlit, google_cloud, azure, and boto3).

5. Automated IDE Configuration (bootstrap)

Registers Mustel as a global MCP server across active user directories:

  • Cursor: %USERPROFILE%\.cursor\mcp.json (Windows) / ~/.cursor/mcp.json (Mac/Linux)
  • Windsurf: ~/.codeium/windsurf/mcp_config.json
  • Claude Code: ~/.claude.json
  • Claude Desktop: OS-specific configuration directories

It also automatically appends required instructions to project .cursorrules / .windsurfrules and configures git pre-commit hooks.


Quick Start

Install

pip install mustel

Configure

# Register MCP server globally across Cursor, Windsurf, and Claude
mustel bootstrap --global

# Configure local rules and install pre-commit hook in the current workspace
mustel bootstrap

CLI Reference

# Run local incremental review (Dev Mode)
mustel review

# Force deep security and dependency audits (Audit Mode)
mustel review --audit

# Review a single target file
mustel review --file mustel/runner.py

# Print the repository codebase map
mustel map

🛠️ MCP Server Tools

Mustel runs an MCP server over stdio transport via mustel serve. The exposed tools are documented below:

MCP Tool Arguments Output Type Description
review path (str), skip_packages (bool), compact (bool), audit (bool) JSON Concurrently scans files in the workspace.
review_file file_path (str), compact (bool) JSON + Text Scans single file on save (triggers guardrails).
get_code_map path (str) Text Returns a compact AST/regex codebase skeleton.
env None JSON Returns a snapshot of the Python environment.
bootstrap global_install (bool) Text Re-configures IDE settings and hook scripts.

📂 Codebase Layout

mustel/
├── mustel/
│   ├── cli.py         # CLI entrypoints (review, serve, bootstrap, map)
│   ├── runner.py      # Parallel execution engine and thread orchestrator
│   ├── cache.py       # Stat-based (mtime + size) file caching layer
│   ├── code_map.py    # AST & regex repository map generator
│   ├── normalizer.py  # Deduplication, formatting, and prompt serializer
│   ├── schema.py      # TypedDict specifications and compact serializers
│   ├── bootstrap.py   # IDE config injector and pre-commit hook installer
│   └── patterns/      # YAML rules and notebook loader

📄 License

MIT License - Copyright (c) 2026 Ameya K, Raunak N. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mustel-0.3.3.tar.gz (346.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mustel-0.3.3-py3-none-any.whl (58.4 kB view details)

Uploaded Python 3

File details

Details for the file mustel-0.3.3.tar.gz.

File metadata

  • Download URL: mustel-0.3.3.tar.gz
  • Upload date:
  • Size: 346.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for mustel-0.3.3.tar.gz
Algorithm Hash digest
SHA256 fee10762305725ead0c2685c4ce735d1c22d2ec8e92f25c9c69916b7ca3670ba
MD5 02a29fd591120443ad6b6a70721e5836
BLAKE2b-256 1dc22cf904b9fa521047cfaa114e2d959c467316ca920a911c17c89e3eeea633

See more details on using hashes here.

File details

Details for the file mustel-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: mustel-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 58.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for mustel-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9c537962b16ee4ed1015d32b7c0d4196344ef699e047dc820bdd291a96d631ae
MD5 818a2fe8f79769676eb468a8eb0647a2
BLAKE2b-256 07b099d66affb8ba527c13e9682edb8eecda981f579b62d7b128da5de5d07de9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page