Skip to main content
Glama

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
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 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}` } ] }; } }
  • 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);

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