Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

add-lexer-rules-removed

Add multiple lexer rules to an ANTLR4 grammar in one operation. Specify patterns, channels, and skip directives to quickly build or extend grammars.

Instructions

Add multiple lexer rules to a grammar in a single operation (bulk add).

When to use: Set up initial grammar structure, add multiple related tokens at once, or import rules from another grammar.

Example - Add common tokens: rules: [ { name: "ID", pattern: "[a-zA-Z_][a-zA-Z0-9_]" }, { name: "INT", pattern: "[0-9]+" }, { name: "WS", pattern: "[ \t\n\r]+", skip: true }, { name: "COMMENT", pattern: "//.?\n", channel: "COMMENTS" } ] write_to_file: true

Features:

  • All rules inserted in alphabetical order

  • Duplicate prevention per rule

  • Partial success: some rules can succeed even if others fail

  • Per-rule success/failure reporting

  • Atomic per-rule operations

Returns:

  • Summary: "Added X rules, Y failed"

  • Per-rule results with success/failure status

  • Modified grammar

  • File write confirmation if applicable

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rulesYesArray of lexer rules to add. Each rule requires name and pattern properties.
from_fileNoOptional: path to a grammar file to read. Required if using write_to_file.
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
Behavior5/5

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

With no annotations, the description carries the full burden and does excellently: it discloses alphabetical insertion, duplicate prevention, partial success with per-rule reporting, atomic per-rule operations, and file write confirmation. This is exemplary 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 headers and bullets, and each section (summary, when-to-use, example, features, returns) earns its place. It's longer than minimal, but the extra length is used for genuinely useful detail like the example and return format.

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?

Given 5 params and no output schema, the description covers return values (summary, per-rule results, modified grammar, file confirmation), key behaviors (partial success, duplicate prevention), and an illustrative example. This gives an agent everything needed to select and invoke the tool correctly.

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 the baseline is 3. The description adds a concrete example showing the rules array structure (name, pattern, skip, channel) and clarifies the relationship between from_file and write_to_file. This goes beyond the schema and earns a 4.

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 starts with a clear verb-resource statement: 'Add multiple lexer rules to a grammar in a single operation (bulk add).' It explicitly specifies 'lexer' and 'multiple', which distinguishes it from single-rule tools like add-rule and parser-rule tools like add-parser-rules.

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 gives three concrete scenarios: initial grammar structure, adding multiple related tokens, and importing rules. It doesn't explicitly name alternative tools or say when not to use this tool, but the context is clear enough for an agent to choose it appropriately for bulk lexer additions.

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