Skip to main content
Glama

find_the_most_critical_design_issue

Analyze Java code to identify and locate the most serious design flaw requiring immediate refactoring to improve maintainability, readability, and structure.

Instructions

Analyze one Java file. Find the most serious design flaw. It must need immediate refactoring. Ignore cosmetic or minor issues. Fix the one problem that will best improve code quality. Code quality means maintainability, readability, loose coupling, and high cohesion. Point out the problem and where it is in the file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The main handler function for the tool. It takes the Java file path, safely executes aibolit on it, and returns the result as a text content block.
    async ({ path }) => { return ({ content: [{ text: await safe(() => aibolit(path)), type: 'text' }] }); }
  • Zod schema for the tool input, requiring a 'path' string parameter.
    { path: z.string() },
  • src/tools.ts:10-32 (registration)
    Registration of the MCP tool using server.tool, including name, GPT-formatted description prompt, input schema, and handler function.
    server.tool( 'find_the_most_critical_design_issue', to_gpt( ` Analyze one Java file. Find the most serious design flaw. It must need immediate refactoring. Ignore cosmetic or minor issues. Fix the one problem that will best improve code quality. Code quality means maintainability, readability, loose coupling, and high cohesion. Point out the problem and where it is in the file. ` ), { path: z.string() }, async ({ path }) => { return ({ content: [{ text: await safe(() => aibolit(path)), type: 'text' }] }); } );
  • Core helper function that implements the tool logic: checks Aibolit version, runs the Aibolit analyzer on the Java file, parses the warnings to find the one with the highest priority value, and formats a response describing the most critical design issue.
    export const aibolit = async function(path: string): Promise<string> { check_version(); if (!fs.existsSync(path)) { return `File does not exist: ${path}`; } const warns = execSync( ` /bin/bash -c "set -o pipefail; (python3 -m aibolit check --full --filenames ${path} || true)" ` ).toString(); const lines = warns.trim().split('\n').filter(line => line.trim()); const parsed = lines.map(line => { const match = line.match(/^.+?\[(\d+)\]:\s(.+?)\s\(P\d+:\s(\d+(?:\.\d+)?)\)$/); if (match) { return { line: parseFloat(match[1]), name: match[2].trim(), value: parseFloat(match[3]) }; } return null; }).filter(item => item !== null) as { line: number, name: string; value: number }[]; const sorted = parsed.sort((a, b) => b.value - a.value); const top = sorted[0]; if (!top) { return 'Your code is perfect'; } return to_gpt( ` The most important design issue in this Java file (${path}) is on the line no.${top.line}: "${top.name}". It needs immediate refactoring if you want to increase code maintainability. ` ); }
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/cqfn/aibolit-mcp-server'

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