Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

add-lexer-mode

Add a new lexer mode declaration to ANTLR4 grammars for context-sensitive tokenization. Automatically validates the mode name and prevents duplicates, with optional insertion after a specific rule.

Instructions

Add a new lexer mode declaration to an ANTLR4 grammar.

When to use: Creating new modes for context-sensitive tokenization.

Features:

  • Adds "mode MODE_NAME;" declaration

  • Optional positioning with insert_after

  • Validates mode name format

  • Prevents duplicate mode names

Example - Add mode after specific rule: mode_name: "STRING_MODE" insert_after: "STRING" write_to_file: true

Example - Add mode at end of grammar: mode_name: "TEMPLATE_MODE" write_to_file: true

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_fileNoOptional: path to a grammar file to read. Required if using write_to_file.
mode_nameYesName of the new mode (UPPER_CASE recommended)
output_modeNoOutput format: "full", "diff", or "none"
insert_afterNoOptional: Insert mode declaration after this rule name
write_to_fileNoIf true, writes modified grammar back to from_file
grammar_contentNoThe ANTLR4 grammar file content
Behavior3/5

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

With no annotations provided, the description carries full behavioral burden. It discloses useful details like validation of mode name format and prevention of duplicate mode names. However, it omits potential side effects (e.g., file overwriting, permissions) and error behaviors, which are important for a mutation tool.

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-organized with 'When to use', 'Features', and 'Example' sections. It is front-loaded with the main purpose and remains reasonably sized. The examples are useful but could be trimmed slightly 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?

The tool has 6 parameters and no output schema. The description explains the main use cases and features, but it does not clarify more complex aspects like the output_mode parameter (full/diff/none) or the exact relationship between from_file and grammar_content. For a moderately complex tool, this leaves some gaps.

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 description coverage is 100%, so the baseline is 3. The description adds examples and mentions optional positioning, but it does not significantly enhance the existing parameter descriptions. The examples clarify parameter combinations but do not add new semantic meaning 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 begins with a specific verb and resource: 'Add a new lexer mode declaration to an ANTLR4 grammar.' This clearly distinguishes it from sibling tools like add-rule or add-parser-rules, which operate on rules rather than mode declarations.

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 states the intended context: 'Creating new modes for context-sensitive tokenization.' It provides clear guidance on when to invoke this tool, though it does not name alternative tools or explicit exclusion criteria.

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