Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

fix-quantifier-issues

Fix suspicious quantifier patterns in ANTLR4 grammars, converting ')?' to ')*' for rules that should allow repetition. Targets rules with alternatives and collection-named rules.

Instructions

Selectively fix suspicious quantifier patterns - change )? to )* for specific rules.

When to use: After detect-quantifier-issues identifies problems.

Workflow:

  1. Run detect-quantifier-issues to see what's suspicious

  2. Review the suggestions

  3. Run fix-quantifier-issues with specific rule_names to fix

What it fixes:

  • Rules with alternatives: (a | b | c)? → (a | b | c)*

  • Multiple optional elements that suggest repetition

  • Collection-named rules (_rules, _settings) using )?

Examples:

// Step 1: Detect issues detect-quantifier-issues(from_file: "PaloAlto_interface.g4") → Shows: snie_ethernet, snie_lacp, sniel_high_availability, snil_units

// Step 2: Fix specific rules fix-quantifier-issues( from_file: "PaloAlto_interface.g4", rule_names: ["snie_ethernet", "snie_lacp", "snil_units"] ) → Fixes only those 3 rules

// Fix all detected issues fix-quantifier-issues(from_file: "PaloAlto_interface.g4") → Fixes all suspicious patterns

// Preview without changing fix-quantifier-issues( from_file: "PaloAlto_interface.g4", dry_run: true ) → Shows what would change

Real-world: Palo Alto grammar had 15 rules flagged. User fixed 12, left 3 as-is (they were correct).

Returns: List of changes with line numbers and reasoning

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dry_runNoIf true, shows what would change without modifying. Default: false
from_fileNoOptional: path to a grammar file to read
rule_namesNoOptional: Array of specific rule names to fix. If omitted, fixes all suspicious patterns
output_modeNoOutput mode: "full" returns complete grammar, "diff" returns git-style diff (default: diff), "none" returns no content
write_to_fileNoIf true, writes modified grammar back to from_file (requires from_file to be set)
grammar_contentNoThe ANTLR4 grammar file content
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses key behaviors: the transformation performed, selective fixing via rule_names, preview capability with dry_run, and the return format (list of changes with line numbers and reasoning). It does not fully explain the interplay between write_to_file, output_mode, and grammar_content, but it is not misleading and provides substantial behavioral context beyond a bare minimum.

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

Conciseness4/5

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

The description is well-structured with clear headings, a workflow list, code examples, and a real-world anecdote. Every section serves a purpose: summary, when to use, workflow, what it fixes, examples, and return info. It is somewhat long but avoids fluff, and the structure makes it easy to scan. The real-world paragraph adds credibility but is slightly tangential.

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

Completeness4/5

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

Given the tool's moderate complexity (6 optional parameters, no output schema), the description is quite complete. It covers when to use, exactly what it fixes, how to select rules, preview behavior, and return details. The only noticeable gap is not explaining how grammar_content relates to from_file or how write_to_file and output_mode behave together, but the examples and workflow cover the main usage scenarios.

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 description coverage is 100%, so the baseline is 3. The description adds meaningful usage examples (e.g., from_file, rule_names, dry_run) and clarifies that omitting rule_names fixes all suspicious patterns. It does not add detail on grammar_content, but the workflow focuses on from_file, and the examples illustrate the intended usage patterns effectively.

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's purpose: 'Selectively fix suspicious quantifier patterns - change )? to )* for specific rules.' This is a specific verb (fix) and resource (quantifier patterns in grammar rules), and it distinguishes itself from the sibling tool detect-quantifier-issues by framing it as the follow-up action. The 'What it fixes' section adds concrete pattern examples, making the purpose unmistakable.

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?

The description explicitly says 'When to use: After detect-quantifier-issues identifies problems' and provides a clear workflow (detect → review → fix). It gives examples for fixing specific rules, fixing all, and previewing with dry_run, which clarify when to include rule_names and when to omit it. This is strong guidance with explicit alternatives and exclusions.

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