Skip to main content
Glama

Code Security Scan

code_security_scan

Scan custom Drupal PHP/JS code for XSS, SQL injection, command injection, secrets, CSRF, access-control, and deprecated APIs, with Drupal-aware false-positive rules and fix recommendations.

Instructions

Scan custom code for vulnerability patterns — no tools to install.

Matches PHP/JS/Drupal files against a curated registry of XSS, SQL injection, command injection, path traversal, hardcoded secrets, access-control, CSRF, and deprecated-API patterns, with Drupal-aware false-positive rules (EntityQuery conditions, stream wrappers, escapeshellarg, and similar safe APIs are recognized). The counterpart of security_scan, which needs PHPStan installed.

Target one module by machine name, or a directory relative to DRUPAL_ROOT; with neither, the site's own modules/ and themes/ directories are scanned (contrib and core excluded). categories narrows to registry keys ('xss', 'sql_injection', 'command_injection', 'path_traversal', 'hardcoded_secrets', 'access_control', 'csrf', 'deprecated_api'); severity narrows to one level. Findings carry file, line, snippet, and a fix recommendation; counts cover the full run even when max_findings truncates the list.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo
moduleNo
severityNo
categoriesNo
max_findingsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.3.1

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations the description carries the full burden and does a lot: no install prerequisite, Drupal-aware false-positive suppression (EntityQuery, stream wrappers, escapeshellarg), default exclusions of contrib/core, and the specific caveat that counts cover the full run even when max_findings truncates the list. It omits permission/auth requirements and any runtime cost, keeping it from a 5.

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?

Front-loaded with the core action, then scoping, then category enumeration, then return/truncation behavior. Every sentence carries information, though the description is on the dense side and the category list could be trimmed against the schema in principle.

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?

An output schema exists, so return-shape explanation isn't required, yet the description still tells the agent findings carry file, line, snippet, and a fix recommendation, and warns about max_findings truncation. Combined with full parameter and scope coverage, only auth/permissions context is missing.

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

Parameters5/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 — and it does for all five parameters: path is 'relative to DRUPAL_ROOT', module is a machine name, categories lists the exact registry keys, severity narrows to one level, and max_findings is tied to the truncation caveat. No parameter is left undocumented.

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?

States a specific verb ('scan') and resource ('custom code') with the exact pattern classes covered (XSS, SQL injection, command injection, path traversal, hardcoded secrets, access-control, CSRF, deprecated-API). It also names the sibling it pairs with ('the counterpart of security_scan, which needs PHPStan installed'), so an agent can pick it apart from security_scan/security_audit without opening a schema.

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?

Explicitly routes against the alternative: security_scan requires PHPStan, this one requires nothing installed. It also spells out the default scope when no path or module is given (site's own modules/ and themes/, contrib and core excluded). It stops short of naming security_audit/config_security_check as further alternatives, so not a full 5.

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

Deploy Server

Other Tools