Skip to main content
Glama

run_linter

Run standardized linting for projects, enabling automatic fixes and targeting specific files to ensure code quality and consistency.

Instructions

Run standardized linter for the project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesNoSpecific files to lint
fixNoAttempt to fix issues automatically

Implementation Reference

  • The RunLinterTool class implements the core logic for the run_linter tool. It extends BaseExecTool and provides the action name 'Lint' and builds the lint command based on project config, optional --fix flag, and file list.
    class RunLinterTool extends BaseExecTool<LinterOptions> { protected getActionName(): string { return 'Lint'; } protected async buildCommand(args: LinterOptions): Promise<string> { const { fix = false, files = [] } = args; const config = await loadProjectConfig(); const command = config.lintCommand ?? 'npm run lint'; const parts = [command]; if (fix && !command.includes('--fix')) { parts.push('--fix'); } if (files.length > 0) { parts.push(...files); } return parts.join(' '); } }
  • The exported runLinter function acts as the direct handler entry point, delegating to the tool instance's execute method.
    export async function runLinter(args: LinterOptions): Promise<CallToolResult> { return tool.execute(args); }
  • Type definition for the input schema of the run_linter tool, including optional fix flag and list of files to lint.
    export interface LinterOptions { fix?: boolean; files?: string[]; }
  • BaseExecTool provides the generic execution logic for shell commands, used by RunLinterTool.
    export abstract class BaseExecTool<T = unknown> { protected abstract getActionName(): string; protected abstract buildCommand(args: T): Promise<string> | string; async execute(args: T): Promise<CallToolResult> { try { const command = await this.buildCommand(args); let output = ''; let error = ''; let exitCode = 0; try { const result = await execAsync(command, { cwd: process.cwd(), env: process.env, maxBuffer: 1024 * 1024 * 10, }); output = result.stdout; error = result.stderr; } catch (execError) { const err = execError as { stdout?: string; stderr?: string; message?: string; code?: number }; output = err.stdout ?? ''; error = err.stderr ?? err.message ?? 'Unknown error'; exitCode = err.code ?? 1; } const formattedOutput = formatExecOutput(output, error, exitCode, this.getActionName()); return createSuccessResult(formattedOutput); } catch (error) { return createErrorResult(this.getActionName(), error); } } }

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/jaggederest/mcp_reviewer'

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