Skip to main content
Glama

find_the_most_critical_design_issue

Analyze Java files to identify and prioritize the most critical design flaw requiring immediate refactoring, focusing on improving maintainability, readability, loose coupling, and cohesion.

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 tool handler function that destructures the input path, safely executes aibolit(path), and returns it wrapped in the expected content format for MCP.
    async ({ path }) => { return ({ content: [{ text: await safe(() => aibolit(path)), type: 'text' }] }); }
  • Zod input schema requiring a 'path' string parameter.
    { path: z.string() },
  • src/tools.ts:10-32 (registration)
    Registers the MCP tool 'find_the_most_critical_design_issue' with server.tool, including description prompt, schema, and handler.
    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 'aibolit' that checks Aibolit version, runs the CLI on the Java file, parses warnings, selects the top-priority design issue by score, and formats the result.
    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. ` ); }

Other Tools

Related 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