Skip to main content
Glama
aws-samples

MCP Security Scanner

Official
by aws-samples

scan_directory_with_bandit

Scan a directory of Python files with Bandit to uncover security vulnerabilities like SQL injection, hardcoded passwords, and unsafe functions.

Instructions

Scan an entire project directory with Bandit for Python security issues.

This tool scans all Python files in a directory for security issues using Bandit.

Unlike scan_with_bandit which scans code snippets, this tool scans the actual project directory to find issues across all Python files.

Bandit can detect issues like:

  • Use of insecure functions (pickle, eval, exec)

  • Hardcoded passwords and secrets

  • SQL injection vulnerabilities

  • Command injection risks

  • Weak cryptographic practices

  • Insecure random number generation

  • And many other Python-specific security issues

Args: directory_path: Path to the directory to scan (relative or absolute) severity_threshold: Minimum severity level to report (LOW, MEDIUM, HIGH)

Returns: A dictionary with security findings from Bandit

Note: Bandit must be installed and available in PATH. Install with: - pip: pip install bandit - pipx: pipx install bandit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
return_outputNoReturn full output instead of saving to file (default: False)
directory_pathYesPath to the directory to scan
severity_thresholdNoMinimum severity threshold (LOW, MEDIUM, HIGH)MEDIUM

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

With no annotations, the description carries the full burden of behavior. It discloses that it scans all Python files, requires Bandit to be installed, returns a dictionary of findings, and honors severity thresholds. It also notes installation instructions. The only notable gap is that the description omits the 'return_output' parameter's behavior (returning output vs. saving to file) even though it's in the schema, which would have added extra transparency.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, contrast, issue types, args, returns, note). It is somewhat lengthy due to the bulleted list of security issues, but these bullets are informative and give the agent a concrete sense of what Bandit detects. The front-loaded purpose sentence is strong, and the overall organization aids comprehension.

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

Completeness4/5

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

For a security scanning tool with an output schema and no annotations, the description covers most essential context: purpose, scope, return type, installation requirements, and parameter meanings. It does not describe the exact structure of the returned dictionary (though the output schema handles that), nor does it mention performance or side effects. Given the tool's moderate complexity, this is a solid, complete-enough description, though not exhaustive.

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

Parameters3/5

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

The input schema has 100% description coverage for all three parameters, so the baseline is 3. The description adds a few extra details (e.g., 'relative or absolute' for directory_path) but largely repeats the schema information. It does not clarify the 'return_output' parameter beyond the schema, so it does not significantly enhance parameter understanding.

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 description clearly states the tool scans whole directories with Bandit for Python security issues, using a specific verb ('scan') and resource ('project directory'). It explicitly distinguishes itself from the sibling scan_with_bandit, which scans code snippets, and enumerates the types of issues it catches, leaving no ambiguity about its purpose.

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 explicitly contrasts this tool with scan_with_bandit, stating the former scans directories while the latter scans snippets. This gives clear guidance on when to use this tool over that specific alternative. However, it does not mention sibling directory scanning tools (e.g., sync_directory_with_grype) or explicitly state that it is Python-specific, though the implication is clear from the 'Python files' phrasing.

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

Install Server

Other Tools

Latest Blog Posts

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/aws-samples/sample-mcp-security-scanner'

If you have feedback or need assistance with the MCP directory API, please join our Discord server