Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

suggest-tokens-from-errors

Analyze parser error logs and automatically suggest missing tokens to add to ANTLR grammar, with confidence scoring.

Instructions

Parse error logs and automatically suggest missing tokens to add to grammar.

When to use:

  • Debugging parser failures with error logs

  • Identifying missing tokens from Batfish errors

  • Analyzing ANTLR parse error output

  • Incremental grammar development based on test failures

Supported error log formats:

  1. Batfish-style: "unexpected token: 'word'"

  2. ANTLR-style: "mismatched input 'word'"

  3. ANTLR-style: "no viable alternative at input 'word'"

  4. Generic: any quoted strings in error context

Example - Analyze Batfish error log: error_log: "Error parsing config: unexpected token: 'ftm-push' at line 10" → Suggests: FTM_PUSH token with pattern 'ftm-push'

Example - Parse ANTLR errors: error_log: "line 5:10 mismatched input 'admin' expecting {CONFIG, SYSTEM}" → Suggests: ADMIN token with pattern 'admin'

Features:

  • Multi-format error log parsing

  • Confidence scoring (high/medium/low)

  • Automatic deduplication

  • Skips tokens that already exist in grammar

  • Provides reasoning for each suggestion

  • Handles multiple errors in batch

Returns:

  • List of suggested tokens with:

    • Token name (uppercase with underscores)

    • Pattern (string literal)

    • Reason for suggestion

    • Confidence level

  • Summary of suggestions found

Note: This tool only suggests tokens. Use add-lexer-rules to actually add them to your grammar.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
error_logYesError log content to analyze (supports Batfish and ANTLR error formats)
from_fileNoOptional: path to a grammar file to read
grammar_contentNoThe ANTLR4 grammar file content
Behavior5/5

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

With no annotations provided, the description takes full burden and does an excellent job: it explains supported error formats, deduplication, skipping existing tokens, confidence scoring, and the fact that it makes no changes to the grammar. The 'Note' reinforces its non-mutating nature.

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?

Although long, the description is well-structured with headers, bullet points, and examples. Every section contributes useful information, and key points like 'only suggests tokens' are front-loaded. No wasted sentences.

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

Completeness5/5

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

The description covers the tool's purpose, supported formats, examples, output structure, and limitations. Given the lack of an output schema, it adequately describes return values and next steps, leaving no major gaps for the user.

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

Parameters4/5

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

Schema coverage is 100%, so baseline is 3. The description adds value by giving concrete examples of error_log formats and the expected behavior, which enriches the skeletal schema descriptions and helps users craft valid input.

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

Purpose5/5

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

The description clearly states the tool parses error logs and suggests missing tokens for the grammar. It distinguishes itself from sibling tools by explicitly noting it only suggests tokens and directs users to add-lexer-rules for actual modifications.

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

Usage Guidelines5/5

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

Includes a dedicated 'When to use' section listing concrete scenarios like debugging parser failures and analyzing ANTLR errors. It also differentiates from the alternative tool, providing clear guidance on when not to use it.

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/natl-set/antlr4-mcp'

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