Skip to main content
Glama
Bigsy

clj-kondo MCP Server

lint_clojure

Analyze and identify errors or warnings in Clojure, ClojureScript, and EDN files using clj-kondo. Supports file paths, directories, or classpaths, with customizable linting levels and configurations.

Instructions

Lint Clojure/ClojureScript/EDN content using clj-kondo

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
configDirNoOptional absolute path to .clj-kondo config directory (e.g. /Users/name/project/.clj-kondo). If not provided, clj-kondo will look for .clj-kondo directory in the current and parent directories.
fileYesCan be: 1) Absolute path to a file, 2) Directory path (will lint all .clj/.cljs/.cljc files recursively), or 3) Classpath string (obtained via `lein classpath` or `clojure -Spath`)
levelNoOptional linting level. By default all lints are errors. Set to "warning" to use warning level instead.

Implementation Reference

  • CallToolRequestSchema handler that dispatches to lint_clojure tool by validating arguments and executing clj-kondo CLI.
    this.server.setRequestHandler(CallToolRequestSchema, async (request: Request) => {
      if (!request.params || request.params.name !== 'lint_clojure') {
        throw new McpError(
          ErrorCode.MethodNotFound,
          `Unknown tool: ${request.params?.name || 'undefined'}`
        );
      }
    
      if (!request.params.arguments || !isValidLintArgs(request.params.arguments)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid lint arguments'
        );
      }
    
      try {
        const configDirArg = request.params.arguments.configDir
          ? `--config-dir "${request.params.arguments.configDir}"`
          : '';
        const levelArg = request.params.arguments.level === 'warning'
          ? '--fail-level error'
          : '--fail-level warning';
        const { stdout, stderr } = await execAsync(
          `clj-kondo --lint "${request.params.arguments.file}" ${configDirArg} ${levelArg} --parallel`
        );
    
        return {
          content: [
            {
              type: 'text',
              text: stdout || stderr,
            },
          ],
        };
      } catch (error: any) {
        // clj-kondo returns non-zero exit code when it finds linting issues
        if (error.stdout || error.stderr) {
          return {
            content: [
              {
                type: 'text',
                text: error.stdout || error.stderr,
              },
            ],
          };
        }
        throw error;
      }
    });
  • Input schema definition for the lint_clojure tool.
    inputSchema: {
      type: 'object',
      properties: {
        file: {
          type: 'string',
          description: 'Can be: 1) Absolute path to a file, 2) Directory path (will lint all .clj/.cljs/.cljc files recursively), or 3) Classpath string (obtained via `lein classpath` or `clojure -Spath`)',
        },
        configDir: {
          type: 'string',
          description: 'Optional absolute path to .clj-kondo config directory (e.g. /Users/name/project/.clj-kondo). If not provided, clj-kondo will look for .clj-kondo directory in the current and parent directories.',
        },
        level: {
          type: 'string',
          enum: ['warning'],
          description: 'Optional linting level. By default all lints are errors. Set to "warning" to use warning level instead.',
        }
      },
      required: ['file'],
    },
  • src/index.ts:53-75 (registration)
    Tool registration in the ListToolsRequestSchema handler.
    {
      name: 'lint_clojure',
      description: 'Lint Clojure/ClojureScript/EDN content using clj-kondo',
      inputSchema: {
        type: 'object',
        properties: {
          file: {
            type: 'string',
            description: 'Can be: 1) Absolute path to a file, 2) Directory path (will lint all .clj/.cljs/.cljc files recursively), or 3) Classpath string (obtained via `lein classpath` or `clojure -Spath`)',
          },
          configDir: {
            type: 'string',
            description: 'Optional absolute path to .clj-kondo config directory (e.g. /Users/name/project/.clj-kondo). If not provided, clj-kondo will look for .clj-kondo directory in the current and parent directories.',
          },
          level: {
            type: 'string',
            enum: ['warning'],
            description: 'Optional linting level. By default all lints are errors. Set to "warning" to use warning level instead.',
          }
        },
        required: ['file'],
      },
    },
  • Helper function to validate input arguments for lint_clojure.
    const isValidLintArgs = (
      args: any
    ): args is { file: string; configDir?: string; level?: 'warning' } =>
      typeof args === 'object' &&
      args !== null &&
      typeof args.file === 'string' &&
      (args.configDir === undefined || typeof args.configDir === 'string') &&
      (args.level === undefined || args.level === 'warning');

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

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/Bigsy/clj-kondo-MCP'

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