Mustel logo

Documentation & Setup

Get up and running with Mustel in minutes. Learn standard configurations, IDE setup steps, and CLI references.

Lazy Agentic AI Setup Prompt

Copy and paste this guided instruction prompt directly into Cursor Chat, Claude Code, or Windsurf. Your AI agent will automatically configure the MCP server and run the installation:

Please set up the Mustel static analysis MCP server in this workspace:

1. Run `pip install mustel` to install the linter core.

2. Locate or create the MCP configuration file for this editor environment.

3. Add a new server named "mustel" with command "mustel" and args ["serve"] under "mcpServers".

4. Confirm once the server is successfully registered.

Quick Start Guide

1

Install the Mustel Core

Mustel is distributed as a Python package. We recommend installing it globally using pip so it can be resolved globally by all IDE plugin instances.

terminal
pip install mustel
2

Bootstrap configurations & hooks

Generate git pre-commit hooks, IDE rule files (.cursorrules, .windsurfrules), and default prompt templates under the active project root directory.

terminal
mustel bootstrap 
3

Verify scan pipeline

Trigger a local incremental check to verify Ruff rules, Bandit patterns, and local caches are running smoothly. Mustel returns a clean, deduplicated schema JSON.

terminal
mustel review .

IDE Integration Setup

Mustel exposes a Model Context Protocol (MCP) server so AI-powered editors can call it automatically. Below is the universal JSON configuration, followed by per-editor setup steps.

mcp-config.json
{  "mcpServers": {    "mustel": {      "command": "mustel",      "args": ["serve"]    }  }}

Cursor

.cursor/mcp.json
  1. 1Open your project root.
  2. 2Create or edit .cursor/mcp.json.
  3. 3Paste the MCP JSON config shown below.
  4. 4Restart the Cursor editor.

Windsurf

~/.codeium/windsurf/mcp_config.json
  1. 1Open a terminal.
  2. 2Navigate to ~/.codeium/windsurf/.
  3. 3Create or edit mcp_config.json.
  4. 4Paste the MCP JSON config shown below.

Claude Code

Terminal command
  1. 1Open a terminal in your project.
  2. 2Run: claude mcp add mustel mustel serve
  3. 3The MCP server is now registered.

Claude Desktop

claude_desktop_config.json
  1. 1Open Claude Desktop settings.
  2. 2Navigate to the MCP configuration file.
  3. 3Add the MCP JSON config shown below to the mcpServers object.
  4. 4Restart Claude Desktop.
Claude Code shortcut: You can skip file editing entirely and register Mustel with a single terminal command:claude mcp add mustel mustel serve

CLI Reference

mustel review [PATH]

Runs static analysis on Python files. It acts as a save-trigger guardrail, scanning code in milliseconds.

FlagDescription
--file <PATH>Target a single file (used primarily for IDE save triggers).
--no-packagesSkips pip-audit dependency CVE checks for sub-30ms performance.
--auditForces a deep security audit, checking Bandit patterns and dependency vulnerability databases.
--prettyPretty-prints the schema-compliant JSON report.

mustel env

Outputs a JSON snapshot of the local machine environment. Used by client IDE plugins to dynamically locate Python interpreters and resolve configuration paths.

FlagDescription
--prettyPretty-print the JSON environment details.

mustel serve

Spawns the Model Context Protocol (MCP) server over standard I/O (stdin/stdout). Features shebang-aware EOF tracking to shut down automatically if the editor host crashes, preventing background zombie processes.

No additional flags.

mustel bootstrap

Registers configurations. Without flags, it installs shebang-aware git pre-commit hooks and generates prompt files (.cursorrules, .windsurfrules).

FlagDescription
--globalConfigures MCP global settings for Cursor, Windsurf, Claude Code, and Claude Desktop.

mustel map [PATH]

Generates a highly compressed structural blueprint of the repository. Traverses folders, AST-parses classes/methods, and serializes docstrings into an indented skeleton under 1,500 tokens (reducing initial onboarding token costs by 95%).

No additional flags.

Architecture & Internals

Under the hood, Mustel is composed of four tightly integrated subsystems. Each is designed for a single responsibility and communicates via schema-compliant JSON payloads.

Two-Tier Cache

mustel/cache.py

Mustel's cache validates files by comparing mtime and size file stats. If both match, the cached result is returned instantly — this is Dev Mode (sub-30ms scans). When --audit is passed, cache validation is bypassed for deep dependency checks — this is Audit Mode.

AST Code Map

mustel/code_map.py

The codebase mapper traverses the file tree, AST-parses Python files, and extracts class structures and method signatures. It serializes this data into a compressed indented skeleton that fits under 1,500 tokens, reducing prompt context overhead by 95%.

JSON Normalizer

mustel/normalizer.py

Multiple linting tools can report overlapping issues. The normalizer deduplicates these reports and maps findings from Ruff, Bandit, and pip-audit into a unified internal schema containing file, line, rule, and message.

MCP Server

mustel serve

The MCP server communicates over standard I/O (stdin/stdout) with the host editor. It implements shebang-aware EOF tracking— if the parent editor process crashes, Mustel detects the closed pipe and shuts itself down, preventing lingering "zombie" processes.

Troubleshooting

1AI agent ignores custom rules

CauseAI agents load prompt settings once at the beginning of a conversation. Any changes to .cursorrules, .windsurfrules, or AGENTS.md after the chat has started will not be read.
SolutionStart a new chat session in your IDE (e.g. Cmd/Ctrl + L → New Chat) to force the editor to reload the workspace guidelines.

2mustel: command not found in editor terminal

CauseIDE environments often use isolated PATH contexts that differ from your main system terminal, causing global script resolution failures.
SolutionMustel v0.3.4+ solves this. When running `mustel bootstrap`, the absolute python executable path is written directly into your global configuration. Run the bootstrap command inside your active workspace terminal to map it.

3connect ENOENT pipe/socket lockups

CauseA previously crashed editor session left orphaned processes holding onto the named pipes or socket locks.
SolutionForce-kill lingering node or python processes. On Windows, run: `Stop-Process -Name python, node -Force` in PowerShell. On Unix/macOS, run: `killall python node`.

4Slow scan triggers (>1s save latency)

CauseCI or git-related flags (e.g. CI=true, PRE_COMMIT=true) are forcing Audit Mode checks (such as active CVE queries) on every single file save.
SolutionVerify your workspace terminal environment. Remove or clear active CI/PRE_COMMIT flags from your shell profile to allow Dev Mode (sub-30ms checks) to run.
Created & maintained by the authors.