Skip to main content
Glama

validate_syntax

Check code files for syntax errors to identify and fix issues before execution. Supports multiple file paths for batch validation.

Instructions

Validate syntax of code files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filesYesFile paths to validate

Implementation Reference

  • Handler logic for the 'validate_syntax' tool: parses input files, calls validateSyntax helper on each, and returns validation results per file.
    case 'validate_syntax': { const files = params.files as string[]; const codeFiles = await FileReader.readFiles(files.join(',')); const results = codeFiles.map((file) => { const validation = lintingUtils.validateSyntax( file.content, file.language || 'javascript' ); return { file: file.path, ...validation, }; }); return results; }
  • Tool registration defining name, description, and input schema for 'validate_syntax'.
    { name: 'validate_syntax', description: 'Validate syntax of code files', inputSchema: { type: 'object', properties: { files: { type: 'array', items: { type: 'string' }, description: 'File paths to validate', }, }, required: ['files'], }, },
  • Input schema defining the expected parameters: array of file paths.
    inputSchema: { type: 'object', properties: { files: { type: 'array', items: { type: 'string' }, description: 'File paths to validate', }, }, required: ['files'], },
  • Helper function implementing basic syntax validation by matching braces, parentheses, and brackets for JS/TS code.
    validateSyntax(code: string, language: string): { valid: boolean; errors: string[] } { const errors: string[] = []; if (language === 'javascript' || language === 'typescript') { // Basic bracket matching const openBracesCount = (code.match(/{/g) || []).length; const closeBracesCount = (code.match(/}/g) || []).length; if (openBracesCount !== closeBracesCount) { errors.push('Unmatched braces'); } const openParens = (code.match(/\(/g) || []).length; const closeParens = (code.match(/\)/g) || []).length; if (openParens !== closeParens) { errors.push('Unmatched parentheses'); } const openBrackets = (code.match(/\[/g) || []).length; const closeBrackets = (code.match(/\]/g) || []).length; if (openBrackets !== closeBrackets) { errors.push('Unmatched brackets'); } } return { valid: errors.length === 0, errors, }; }

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/code-alchemist01/development-tools-mcp-Server'

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