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);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of behavioral disclosure. It states the action ('Run linting') but doesn't explain what happens during execution (e.g., outputs linter warnings, may fail on errors), potential side effects (e.g., modifies files), or performance aspects (e.g., time-consuming). This leaves key behavioral traits unspecified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly without unnecessary details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a tool with parameters. It doesn't cover what the tool returns (e.g., lint results, success/failure status) or behavioral nuances, which are critical for an AI agent to use it effectively. This gap makes it inadequate despite the concise structure.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents the parameters ('command' and 'directory') with descriptions and defaults. The description adds no additional meaning beyond implying linting occurs, which the schema already covers. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Run') and resource ('linting on the codebase'), making the purpose understandable. It doesn't explicitly differentiate from sibling tools like 'run_build' or 'run_test', which might also involve code analysis, but it's specific enough to convey its function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'check_package_json' or 'run_test'. The description lacks context about prerequisites (e.g., dependencies installed) or typical scenarios (e.g., pre-commit checks), leaving usage unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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