Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

analyze-mode-transitions

Builds a mode transition graph for ANTLR4 lexers to detect circular transitions, unbalanced pushMode/popMode, and modes lacking exits, providing suggestions for better mode structure.

Instructions

Analyze mode transition graph and detect issues in ANTLR4 lexer modes.

When to use: Debugging mode switching logic, ensuring balanced push/pop, detecting circular transitions.

Features:

  • Builds complete mode transition graph

  • Detects circular mode transitions

  • Checks for balanced pushMode/popMode usage

  • Identifies modes with no exit points

  • Suggests improvements for mode structure

Returns:

  • transitions: List of all mode transitions (from, to, via action, rule)

  • issues: Problems detected (circular transitions, unbalanced push/pop)

  • suggestions: Recommendations for improving mode structure

Example usage: from_file: "MyLexer.g4"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_fileNoOptional: path to a grammar file to read
grammar_contentNoThe ANTLR4 grammar file content
Behavior4/5

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

Since no annotations are provided, the description carries the full burden. It discloses the tool's analysis behavior in detail: builds a complete transition graph, detects circular transitions, checks balanced push/pop, identifies modes without exit points, and suggests improvements. It also clearly describes the return structure, making the tool's behavior transparent. However, it doesn't explicitly state that it is read-only (non-destructive), though this is implied by its analytical 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?

The description is well-organized with clear sections: purpose, when-to-use, features, returns, and example. Every sentence contributes meaningful information, and the bulleted features improve scannability without unnecessary verbosity.

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 fully covers the tool's context: it explains what it does, when to use it, its key features, the structure of its return values (transitions, issues, suggestions), and provides a usage example. With no output schema present, the description adequately compensates by detailing the return fields. No important aspects appear missing.

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?

The input schema already provides 100% coverage, with both parameters (from_file and grammar_content) having descriptions. The tool description adds an example usage with from_file, but does not introduce new semantic meaning beyond the schema. Thus, the baseline of 3 applies.

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 with a specific verb ('Analyze') and resource ('mode transition graph'), and further specifies it detects issues in ANTLR4 lexer modes. This distinguishes it from siblings like analyze-grammar or list-mode-rules, and the 'When to use' section reinforces the specific function.

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

Usage Guidelines4/5

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

The 'When to use' section explicitly lists concrete use cases: debugging mode switching logic, ensuring balanced push/pop, detecting circular transitions. This provides clear context for when this tool is appropriate, though it does not explicitly mention alternatives or when-not-to-use, which would elevate it to a 5.

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