Skip to main content
Glama

lint_code

Analyze codebase for syntax errors, style issues, and potential bugs using custom lint commands. Specify a directory to ensure consistent coding standards and improve code quality in development workflows.

Instructions

Run linting on the codebase

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandNoLint command to run (e.g., "npm run lint", "eslint .")npm run lint
directoryNoDirectory to run linting in (default: current directory)

Implementation Reference

  • The handler function that executes the linting command using child_process.execSync. It runs the specified lint command in the given directory and handles both successful linting and cases with issues by returning appropriate output.
    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:113-130 (registration)
    Registration of the 'lint_code' tool in the ListToolsRequestSchema handler, defining its name, description, and input schema.
    { 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)' } } } }
  • Input schema definition for the lint_code tool, specifying parameters for command and directory.
    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)' } } }
  • Dispatcher case in CallToolRequestSchema handler that routes 'lint_code' calls to the lintCode method.
    case 'lint_code': return await this.lintCode(args);

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/TeodorTrotea/mcptest'

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