Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

merge-rules

Consolidate two ANTLR4 grammar rules into one rule with alternatives, reducing grammar complexity and rule count.

Instructions

Merge two related rules into one rule with alternatives.

When to use: Consolidate similar rules, reduce rule count, group related alternatives.

Example - Merge literal rules: rule1_name: "intLiteral" rule2_name: "floatLiteral" new_rule_name: "numericLiteral"

Result: numericLiteral: intLiteral | floatLiteral

Benefits:

  • Reduces grammar complexity

  • Groups related alternatives logically

  • Simplifies parser structure

Note: Original rules are removed; references to them should be updated manually or use rename-rule first.

Returns: Modified grammar with merged rule created and original rules removed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_fileNoOptional: path to a grammar file to read
rule1_nameYesName of the first rule to merge (will be removed)
rule2_nameYesName of the second rule to merge (will be removed)
new_rule_nameYesName for the merged rule (must follow ANTLR4 naming conventions)
grammar_contentNoThe ANTLR4 grammar file content
Behavior5/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It explicitly states that original rules are removed, references need manual updates, and the return value is a modified grammar. This fully discloses the side effects and output behavior.

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-structured with clear sections: core action, when to use, example, benefits, and a note on side effects. It is front-loaded with the essential purpose and usage, and every sentence adds value. The length is appropriate for the tool's complexity.

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 the moderate complexity (5 parameters, no output schema), the description fully covers the needed context: what the tool does, when to use it, an example, side effects, and return value. The schema and description together provide complete information for correct invocation.

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%, with each parameter already described in the input schema. The description adds context about the merge behavior (originals removed) and includes an example, but it does not significantly enhance parameter semantics beyond what the schema provides. Baseline 3 is appropriate.

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 function: 'Merge two related rules into one rule with alternatives.' This is a specific verb+resource combination that distinguishes it from sibling tools like add-rule, remove-rule, and rename-rule. The example with intLiteral/floatLiteral/numericLiteral further clarifies the intended operation.

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?

An explicit 'When to use' section lists concrete scenarios: consolidate similar rules, reduce rule count, group related alternatives. It also mentions 'or use rename-rule first' for updating references, providing an alternative strategy. This gives clear guidance for when to select this tool over siblings.

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