Skip to main content
Glama

run_linter

Analyze Kotlin Multiplatform Mobile code for Android or iOS projects to detect issues and provide structured feedback with suggested fixes.

Instructions

Run code linter (Detekt, Android Lint, SwiftLint, ktlint). Returns structured lint results with issue locations and suggestions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
platformYesTarget platform
projectPathYesPath to the project root directory
linterNoLinter to run (default: detekt for Android, swiftlint for iOS)
moduleNoGradle module for Android linters (e.g., :app)
configPathNoPath to linter configuration file
timeoutMsNoTimeout in milliseconds (default: 300000)
autoFixNoAuto-fix issues if supported by the linter (default: false)

Implementation Reference

  • Primary execution handler for the 'run_linter' tool. Validates inputs, selects appropriate linter based on platform, runs the linter, processes results, generates summary and top issues with suggestions.
    export async function runLinter(args: RunLinterArgs): Promise<RunLinterResult> { const { platform, projectPath, linter, module = '', configPath, timeoutMs = 300000, autoFix = false, } = args; // Validate platform if (!isPlatform(platform)) { throw Errors.invalidArguments(`Invalid platform: ${platform}. Must be 'android' or 'ios'`); } // Determine linter based on platform if not specified const selectedLinter = linter || (platform === 'android' ? 'detekt' : 'swiftlint'); let result: LintResult; switch (selectedLinter) { case 'detekt': result = await runDetekt(projectPath, module, configPath, timeoutMs, autoFix); break; case 'android-lint': result = await runAndroidLint(projectPath, module, timeoutMs); break; case 'swiftlint': result = await runSwiftLint(projectPath, configPath, timeoutMs, autoFix); break; case 'ktlint': result = await runKtlint(projectPath, timeoutMs, autoFix); break; default: throw Errors.invalidArguments(`Unknown linter: ${selectedLinter}`); } const summary = createLintSummary(result); // Get top issues with suggestions const allIssues = result.files.flatMap((f) => f.issues); const topIssues = allIssues .filter((i) => i.severity === 'error' || i.severity === 'warning') .slice(0, 10) .map((issue) => ({ ...issue, suggestion: getLintSuggestions(issue), })); return { result, summary, topIssues }; }
  • Type definitions for LinterType, input arguments (RunLinterArgs), and output result (RunLinterResult) used by the run_linter tool.
    export type LinterType = 'detekt' | 'android-lint' | 'swiftlint' | 'ktlint'; /** * Input arguments for run_linter tool */ export interface RunLinterArgs { /** Target platform */ platform: string; /** Project root directory */ projectPath: string; /** Linter to run */ linter?: LinterType; /** Gradle module for Android linters */ module?: string; /** Configuration file path */ configPath?: string; /** Timeout in milliseconds */ timeoutMs?: number; /** Auto-fix issues (if supported) */ autoFix?: boolean; } /** * Result structure for run_linter */ export interface RunLinterResult { /** Lint execution result */ result: LintResult; /** Human-readable summary */ summary: string; /** Top issues with suggestions */ topIssues: Array<LintIssue & { suggestion?: string }>; }
  • Registration function for the 'run_linter' tool, including detailed input schema definition and binding to the runLinter handler. This function is invoked during tool initialization.
    export function registerRunLinterTool(): void { getToolRegistry().register( 'run_linter', { description: 'Run code linter (Detekt, Android Lint, SwiftLint, ktlint). Returns structured lint results with issue locations and suggestions.', inputSchema: createInputSchema( { platform: { type: 'string', enum: ['android', 'ios'], description: 'Target platform', }, projectPath: { type: 'string', description: 'Path to the project root directory', }, linter: { type: 'string', enum: ['detekt', 'android-lint', 'swiftlint', 'ktlint'], description: 'Linter to run (default: detekt for Android, swiftlint for iOS)', }, module: { type: 'string', description: 'Gradle module for Android linters (e.g., :app)', }, configPath: { type: 'string', description: 'Path to linter configuration file', }, timeoutMs: { type: 'number', description: 'Timeout in milliseconds (default: 300000)', }, autoFix: { type: 'boolean', description: 'Auto-fix issues if supported by the linter (default: false)', }, }, ['platform', 'projectPath'] ), }, (args) => runLinter(args as unknown as RunLinterArgs) ); }
  • Invocation of registerRunLinterTool during the central registerAllTools process, ensuring the tool is registered in the global MCP tool registry.
    const { registerRunLinterTool } = await import('./testing/run-linter.js'); registerRunUnitTestsTool(); registerRunMaestroFlowTool(); registerRunLinterTool();

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/abd3lraouf/specter-mcp'

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