Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

analyze-lexer-modes

Analyze ANTLR4 lexer modes: list defined modes, rules, entry/exit points, and detect issues like undefined or unreachable modes. Helps debug mode transitions and understand tokenization context.

Instructions

Analyze lexer mode structure in ANTLR4 grammars.

When to use: Understanding mode-based tokenization, debugging mode transitions, documenting mode structure.

Lexer modes allow context-sensitive tokenization by switching between different sets of lexer rules. Common use cases:

  • String interpolation (switching modes inside strings)

  • Nested comments

  • Template parsing

  • Context-specific keywords

Features:

  • Lists all defined modes with their rules

  • Identifies mode entry points (pushMode actions)

  • Identifies mode exit points (popMode actions)

  • Detects common issues (undefined modes, unreachable modes, popMode in DEFAULT_MODE)

Returns:

  • modes: List of modes with their rules and line numbers

  • entryPoints: Rules that push to each mode

  • exitPoints: Rules that pop from each mode

  • issues: Problems detected (undefined modes, empty modes, etc.)

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
Behavior3/5

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

No annotations are provided, so the description must carry the transparency burden. It describes what the tool does (lists, identifies, detects) and its return structure, but it does not explicitly state that it is read-only or mention any side effects, limitations, or error behavior. This is a partial disclosure.

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

Conciseness3/5

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

The description is well-structured with headers and bullet points, and the main purpose is front-loaded. However, it includes a lengthy background explanation of lexer modes that is not strictly necessary for using the tool. It could be tightened without losing value.

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

Completeness3/5

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

With no output schema, the 'Returns' section is helpful and describes the main output fields. However, it does not cover edge cases like invalid grammar input, missing parameters, or how the tool behaves when both from_file and grammar_content are used. The description is adequate but not fully complete for all usage scenarios.

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?

Schema coverage is 100% since both parameters have descriptions. The description adds an example usage for from_file but does not clarify the relationship or precedence between the two parameters (e.g., which is used if both are supplied, or what happens if neither is provided). This leaves some ambiguity beyond the schema.

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 opens with a clear, specific statement: 'Analyze lexer mode structure in ANTLR4 grammars.' It distinguishes itself from siblings by listing features (lists all modes, entry/exit points, detects issues) that go beyond what analyze-mode-transitions or list-mode-rules might offer.

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?

Provides an explicit 'When to use' section with concrete scenarios: understanding mode-based tokenization, debugging mode transitions, documenting mode structure. It does not explicitly compare to alternative tools or state when not to use, but the context is clear enough.

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