lint_code
Run code linting to identify and fix programming errors, enforce coding standards, and improve code quality in development workflows.
Instructions
Run linting on the codebase
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | No | Lint command to run (e.g., "npm run lint", "eslint .") | npm run lint |
| directory | No | Directory to run linting in (default: current directory) |
Implementation Reference
- src/index.ts:274-307 (handler)The main handler function for the 'lint_code' tool. It executes the specified linting command (default 'npm run lint') in the given directory using execSync, returns success output or issues with stdout/stderr on failure.private async lintCode(args: any) { const command = args?.command || 'npm run lint'; const directory = args?.directory || process.cwd(); try { const output = execSync(command, { cwd: directory, encoding: 'utf8', timeout: 300000 // 5 minutes }); return { content: [ { type: 'text', text: `Linting completed!\nCommand: ${command}\nDirectory: ${directory}\nOutput:\n${output}` } ] }; } catch (error: any) { // Linting might fail but still provide useful output const output = error.stdout || ''; const stderr = error.stderr || ''; return { content: [ { type: 'text', text: `Linting completed with issues:\nCommand: ${command}\nDirectory: ${directory}\nOutput:\n${output}\nErrors:\n${stderr}` } ] }; } }
- src/index.ts:116-128 (schema)Input schema for the lint_code tool, defining optional command and directory parameters.inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Lint command to run (e.g., "npm run lint", "eslint .")', default: 'npm run lint' }, directory: { type: 'string', description: 'Directory to run linting in (default: current directory)' } }
- src/index.ts:113-130 (registration)Registration of the lint_code tool metadata (name, description, schema) in the ListToolsRequestSchema handler.{ name: 'lint_code', description: 'Run linting on the codebase', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Lint command to run (e.g., "npm run lint", "eslint .")', default: 'npm run lint' }, directory: { type: 'string', description: 'Directory to run linting in (default: current directory)' } } } }
- src/index.ts:147-148 (registration)Switch case dispatching CallToolRequest for 'lint_code' to the lintCode handler method.case 'lint_code': return await this.lintCode(args);