Skip to main content
Glama
syrian963

django-chainsaw-mcp

by syrian963

choice_typos

Read-onlyIdempotent

Find Django queryset filters using literals that never match field choices, catching typos like "cancelled" vs "canceled". Scans your project to prevent zero-row results and invalid data writes.

Instructions

Literals compared against a field whose choices will never match them.

    STATUS = [("canceled", "Canceled"), ...]
    Order.objects.filter(status="cancelled")

Two Ls. Valid Python, valid SQL, zero rows, no exception, wrong forever.
Nothing in Django objects: `choices` is checked by `full_clean()`, which a
queryset never calls and `create()` never calls either - so the write side
is worse, and puts a value in the column the application does not believe
exists.

No existing tool finds this: django-stubs types the field as `str` rather
than a Literal union of its choices, so mypy is satisfied, and the DJ rules
do not read the model registry.

Only literals are checked - an enum member is the spelling that cannot go
wrong - and only equality and `in`, because `iexact` can legitimately match
a differently spelled value. `order.status == "..."` names no model, so it
is reported only when the literal is wrong for every model with a field of
that name.

Args:
    search_path: directory to scan. Defaults to the configured project.
    include_tests: also scan test files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
search_pathNo
include_testsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.3

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare read-only/idempotent behavior, and the description adds substantial non-obvious context: the write path is worse because `create()` bypasses `full_clean()`, mypy is satisfied by `str` typing, and the typo silently yields zero rows without exceptions. This goes well beyond the structured annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The definition is long but every section earns its place: concrete example, root-cause explanation, matching boundaries, and Args. Core behavior is front-loaded before examples and parameter details, making it easy to scan.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

It gives the full detection rules, explains why no other tool catches the defect, covers the write-side danger, and documents all parameters. An output schema exists, so omitting return-format details is appropriate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate; it does by explaining `search_path` as the directory to scan with a project default and `include_tests` as toggling test-file scanning. The two Args lines are concise but cover both parameters meaningfully.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence precisely describes what the tool does: detecting string literals compared against Django field choices that can never match. The included example and the claim that no existing tool finds this clearly distinguish it from sibling linters.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit detection boundaries: only literals, only equality and `in`, not `iexact`, and not enum members, plus a false-positive rule for model-less comparisons. It does not name sibling alternatives directly, but the when/when-not guidance is otherwise clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.