Skip to main content
Glama
JJJHoons

Python Code Review MCP Agent

by JJJHoons

security_audit

Analyzes Python code to identify security vulnerabilities like SQL injection and command injection, helping developers detect risks before deployment.

Instructions

Focused security vulnerability analysis for Python code. Identifies SQL injection, command injection, and other security risks.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesPython code to audit for security vulnerabilities
filenameNoName of the file (optional)unknown.py

Implementation Reference

  • Handler function that executes the security_audit tool. Parses input arguments using SecurityAuditSchema, performs code analysis using PythonAnalyzer, generates a security report with ReportFormatter, adds custom security insights, and returns the result as MCP content.
    private async handleSecurityAudit(args: unknown) {
      const { code, filename } = SecurityAuditSchema.parse(args);
      
      const result = this.analyzer.analyzePythonCode(code, filename);
      const securityReport = this.formatter.generateSecurityReport(result);
      
      // Add additional security insights
      const securityInsights = this.generateSecurityInsights(result);
      
      return {
        content: [
          {
            type: 'text',
            text: `${securityReport}\n\n${securityInsights}`
          }
        ]
      };
    }
  • Zod validation schema for security_audit tool inputs: requires 'code' string, optional 'filename' defaulting to 'unknown.py'.
    const SecurityAuditSchema = z.object({
      code: z.string().min(1, "Code cannot be empty"),
      filename: z.string().optional().default("unknown.py")
    });
  • src/index.ts:106-124 (registration)
    Tool registration in the ListTools response, defining name 'security_audit', description, and input schema matching the Zod schema.
    {
      name: 'security_audit',
      description: 'Focused security vulnerability analysis for Python code. Identifies SQL injection, command injection, and other security risks.',
      inputSchema: {
        type: 'object',
        properties: {
          code: {
            type: 'string',
            description: 'Python code to audit for security vulnerabilities'
          },
          filename: {
            type: 'string',
            description: 'Name of the file (optional)',
            default: 'unknown.py'
          }
        },
        required: ['code']
      }
    },
  • Supporting helper function called by the handler to generate additional security insights, including vulnerability summaries and critical alerts.
    private generateSecurityInsights(result: AnalysisResult): string {
      const securityIssues = result.issues.filter(i => i.type === 'security');
      
      const insights = [
        '## 🧠 **SECURITY INSIGHTS**',
        ''
      ];
    
      if (securityIssues.length === 0) {
        insights.push('✅ **No immediate security vulnerabilities detected in this code.**');
        insights.push('');
        insights.push('**Proactive Security Measures:**');
        insights.push('- Implement input validation for all user inputs');
        insights.push('- Use environment variables for sensitive configuration');
        insights.push('- Enable logging for security-relevant events');
        insights.push('- Regularly update dependencies to patch known vulnerabilities');
        return insights.join('\n');
      }
    
      const vulnTypes = [...new Set(securityIssues.map(i => i.rule))];
      insights.push(`**Vulnerability Types Found:** ${vulnTypes.length}`);
      insights.push(`**Most Common:** ${this.getMostCommonVulnerability(securityIssues)}`);
      insights.push('');
    
      const criticalSecurity = securityIssues.filter(i => i.severity === 'critical');
      if (criticalSecurity.length > 0) {
        insights.push('🚨 **CRITICAL SECURITY ALERT:**');
        insights.push(`This code contains ${criticalSecurity.length} critical security vulnerabilities that could lead to:`);
        insights.push('- Data breaches and unauthorized access');
        insights.push('- Remote code execution');
        insights.push('- SQL injection attacks');
        insights.push('- Complete system compromise');
        insights.push('');
        insights.push('**IMMEDIATE ACTION REQUIRED BEFORE DEPLOYMENT**');
      }
    
      return insights.join('\n');
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does (analyzes for security vulnerabilities) but doesn't describe how it behaves: no information about output format, whether it's a read-only analysis or modifies code, performance characteristics, error handling, or any limitations. For a security analysis tool with zero annotation coverage, this leaves significant gaps in understanding its operational behavior.

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 description is extremely concise - just two sentences that directly state the tool's purpose and scope. Every word earns its place: 'Focused security vulnerability analysis for Python code' establishes the core function, and 'Identifies SQL injection, command injection, and other security risks' provides concrete examples without unnecessary elaboration. It's front-loaded with the most important information.

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

Completeness2/5

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

Given that this is a security analysis tool with no annotations and no output schema, the description is insufficiently complete. While concise, it doesn't explain what the tool returns (e.g., a vulnerability report, risk scores, remediation suggestions), how comprehensive the analysis is, what types of 'other security risks' it covers, or any limitations. For a tool that presumably produces important security findings, more context about outputs and scope would be valuable.

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?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description doesn't add any meaningful parameter semantics beyond what's in the schema - it mentions 'Python code to audit' which aligns with the 'code' parameter description, but provides no additional context about parameter usage, constraints, or interactions. This meets the baseline expectation when schema coverage is complete.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Focused security vulnerability analysis for Python code' with specific examples of what it identifies (SQL injection, command injection, and other security risks). It distinguishes itself from siblings by focusing specifically on security vulnerabilities rather than general code quality, version comparison, or improvement suggestions. However, it doesn't explicitly contrast with the 'review_python_code' sibling, which might have some overlap.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. While it mentions 'focused security vulnerability analysis,' it doesn't specify when to choose this over 'review_python_code' (which might include security aspects) or 'analyze_code_quality' (which might cover security as part of broader quality metrics). There's no mention of prerequisites, limitations, or typical use cases.

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/JJJHoons/python_code_review_mcp'

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