Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

move-rule

Move an existing rule to a new position relative to another rule to reorganize ANTLR4 grammars, group related rules, or fix rule order while preserving formatting and comments.

Instructions

Move an existing rule to a new position relative to another rule.

When to use: Reorganizing grammar, grouping related rules, fixing rule order.

Use cases:

  • Move related rules together for better organization

  • Position rules before/after their dependencies

  • Group similar functionality

  • Manual rule ordering (alternative to sort-rules)

Features:

  • Preserves rule formatting (multi-line, comments)

  • Maintains blank lines between rules

  • Validates both rule and anchor exist

  • Detects if rule is already in target position

Example usage:

Move expr rule before term rule: rule_name: "expr" position: "before" anchor_rule: "term"

Move NUMBER token after PLUS token: rule_name: "NUMBER" position: "after" anchor_rule: "PLUS" write_to_file: true

Note: This moves EXISTING rules. To insert NEW rules at specific positions, use add-parser-rule or add-lexer-rule with insert_before/insert_after.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
positionYesMove rule before or after the anchor rule
from_fileNoOptional: path to a grammar file to read
rule_nameYesName of the rule to move
anchor_ruleYesName of the rule to use as anchor/reference point
write_to_fileNoIf true, writes modified grammar back to from_file (requires from_file to be set)
grammar_contentNoThe ANTLR4 grammar file content
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses preservation of formatting, blank line maintenance, validation of rule and anchor existence, and detection of already-in-position. This is useful behavioral context, though it doesn't specify error handling or return behavior.

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?

Well-structured with sections (When to use, Use cases, Features, Example, Note). It is longer than a single sentence but each section adds value. Front-loaded with a clear one-liner purpose. Slightly verbose but appropriate for the tool's complexity.

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

Completeness4/5

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

Given schema covers all parameters and no output schema, the description still explains when to use, features, examples, and alternatives. It does not describe return values or in-memory vs file write behavior beyond the write_to_file param, but overall it is sufficiently complete for an AI agent.

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 baseline is 3. The description adds example usage for rule_name, position, anchor_rule, and write_to_file, but does not add new semantic meaning beyond the schema's parameter descriptions. The examples clarify relationships but the schema already defines them.

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 moves an existing rule to a new position relative to another rule. It distinguishes from siblings like sort-rules and move-rule-to-mode by specifying it reorganizes within the same context, and explicitly contrasts with add-rule for new rules.

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?

Provides explicit 'When to use' section listing reorganization scenarios, plus concrete use cases. It also gives a clear exclusion: 'This moves EXISTING rules. To insert NEW rules... use add-parser-rule or add-lexer-rule' — good alternative guidance.

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