Skip to main content
Glama
JJJHoons

Python Code Review MCP Agent

by JJJHoons

get_improvement_suggestions

Analyze Python code to generate specific suggestions for improving quality, security, performance, and maintainability.

Instructions

Get specific, actionable suggestions for improving Python code quality, security, and maintainability.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesPython code to get improvement suggestions for
filenameNoName of the file (optional)unknown.py
focusAreaNoFocus area for suggestionsall

Implementation Reference

  • Main handler function for 'get_improvement_suggestions' tool. Parses input using GetSuggestionsSchema, analyzes code with analyzer, generates focused suggestions, and returns formatted text response.
    private async handleGetSuggestions(args: unknown) {
      const { code, filename, focusArea } = GetSuggestionsSchema.parse(args);
      
      const result = this.analyzer.analyzePythonCode(code, filename);
      const suggestions = this.generateFocusedSuggestions(result, focusArea);
      
      return {
        content: [
          {
            type: 'text',
            text: suggestions
          }
        ]
      };
    }
  • Zod schema for input validation of the get_improvement_suggestions tool parameters: code (required), filename (optional), focusArea (optional enum).
    const GetSuggestionsSchema = z.object({
      code: z.string().min(1, "Code cannot be empty"),
      filename: z.string().optional().default("unknown.py"),
      focusArea: z.enum(["security", "quality", "performance", "style", "all"]).optional().default("all")
    });
  • src/index.ts:178-201 (registration)
    Tool registration in the MCP server tools list, including name, description, and JSON input schema matching the Zod schema.
      name: 'get_improvement_suggestions',
      description: 'Get specific, actionable suggestions for improving Python code quality, security, and maintainability.',
      inputSchema: {
        type: 'object',
        properties: {
          code: {
            type: 'string',
            description: 'Python code to get improvement suggestions for'
          },
          filename: {
            type: 'string',
            description: 'Name of the file (optional)',
            default: 'unknown.py'
          },
          focusArea: {
            type: 'string',
            enum: ['security', 'quality', 'performance', 'style', 'all'],
            description: 'Focus area for suggestions',
            default: 'all'
          }
        },
        required: ['code']
      }
    }
  • Core helper function that generates focused improvement suggestions by filtering issues by focusArea, grouping by line, formatting with severity icons and best practices.
    private generateFocusedSuggestions(result: AnalysisResult, focusArea: string): string {
      const sections = [
        `💡 **${focusArea.toUpperCase()} IMPROVEMENT SUGGESTIONS**`,
        '=' + '='.repeat(50),
        `**File:** ${result.fileName}`,
        ''
      ];
    
      let relevantIssues = result.issues;
      
      if (focusArea !== 'all') {
        if (focusArea === 'style') {
          relevantIssues = result.issues.filter(i => 
            i.type === 'style' || i.rule.includes('naming-convention')
          );
        } else {
          relevantIssues = result.issues.filter(i => i.type === focusArea);
        }
      }
    
      if (relevantIssues.length === 0) {
        sections.push(`✅ No ${focusArea} issues found! Your code looks good in this area.`);
        sections.push('');
        sections.push('## 🚀 **GENERAL BEST PRACTICES:**');
        sections.push(this.getGeneralBestPractices(focusArea));
        return sections.join('\n');
      }
    
      sections.push(`## 🎯 **${focusArea.toUpperCase()} ISSUES TO ADDRESS (${relevantIssues.length})**`);
      sections.push('');
    
      const groupedByLine = this.groupIssuesByLine(relevantIssues);
      Object.entries(groupedByLine).forEach(([line, issues]) => {
        sections.push(`### Line ${line}:`);
        issues.forEach(issue => {
          sections.push(`- ${this.getSeverityIcon(issue.severity)} **${issue.message}**`);
          if (issue.suggestion) {
            sections.push(`  💡 *${issue.suggestion}*`);
          }
        });
        sections.push('');
      });
    
      sections.push(this.getFocusAreaBestPractices(focusArea));
    
      return sections.join('\n');
    }
  • src/index.ts:223-225 (registration)
    Dispatch case in the tool request handler switch statement that routes to the specific handler.
    case 'get_improvement_suggestions':
      return await this.handleGetSuggestions(args);
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 the tool provides 'specific, actionable suggestions' but doesn't describe how suggestions are generated, whether they include code examples, if there are rate limits, or what the output format looks like. This is a significant gap for a tool that analyzes code without output schema details.

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 a single, efficient sentence that front-loads the core purpose without unnecessary words. Every part of the sentence contributes to understanding the tool's function, making it appropriately concise and well-structured.

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 the complexity of code analysis, lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like suggestion depth, error handling, or output format, which are crucial for an AI agent to use this tool effectively in context with its siblings.

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 description adds no parameter-specific information beyond what's in the schema, which has 100% coverage with clear descriptions for all parameters. The baseline score of 3 is appropriate since the schema adequately documents parameters, but the description doesn't enhance understanding of how parameters like 'focusArea' affect the suggestions.

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 with specific verbs ('get suggestions') and resources ('Python code quality, security, and maintainability'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'analyze_code_quality' or 'review_python_code', which might have overlapping functionality.

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 like 'security_audit' or 'compare_code_versions'. It mentions 'focusArea' in the schema but doesn't explain in the description when to choose specific focus areas or when this tool is preferred over siblings, leaving usage context implied at best.

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