Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

update-rule

Replace an existing ANTLR4 grammar rule definition in place, preserving its position. Handles multi-line definitions for complex grammar modifications.

Instructions

Update an existing rule definition in place. Now supports multi-line definitions!

When to use: Modify rule logic, add alternatives, refine patterns, or fix issues.

Example - Simple update: rule_name: "expression" new_definition: "term ((PLUS | MINUS) term)*"

Example - Multi-line update (string with \n): rule_name: "srp_uuid_null" new_definition: "UUID\n | ~(\n ACTION\n | FROM\n )"

Example - Multi-line update (JSON array): rule_name: "srp_uuid_null" new_definition: ["UUID", " | ~(", " ACTION", " | FROM", " )"]

Multi-line support:

  • Pass a string with embedded \n characters, OR

  • Pass an array of strings (one per line) - more readable!

  • Formatting is automatically preserved based on grammar style

Preserves rule position in grammar. Use rename-rule if changing the rule name.

Returns: Modified grammar with rule updated, success message, file write confirmation if applicable.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_fileNoOptional: path to a grammar file to read. Required if using write_to_file.
rule_nameYesName of the rule to update (case-sensitive)
output_modeNoOutput format: "full" returns entire modified grammar, "diff" returns git-style unified diff (default for modification tools), "none" returns no content (useful for write-only operations)
write_to_fileNoIf true, writes modified grammar back to from_file (requires from_file to be set)
new_definitionYesThe new rule definition to replace the existing one
grammar_contentNoThe ANTLR4 grammar file content
Behavior4/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It discloses multi-line support, preservation of rule position, return values, and optional file writing. However, it does not explicitly state potential side effects like whether the input grammar is modified in memory or file, or if validation is performed, leaving minor gaps.

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-structured with clear sections and examples, but it is longer than necessary. While the examples are helpful, they add length; the core message could be condensed. Still, the front-loaded first sentence states the primary purpose effectively, and the overall structure earns its place.

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 the tool's complexity (6 parameters, no output schema, no annotations), the description covers key aspects: behavior, multi-line handling, return values, and file writing. However, it does not mention how the grammar content is specified (from_file vs grammar_content) in the examples, which is a notable omission for a tool that modifies grammar. The schema covers this, but the description could be more complete.

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?

The schema already covers all parameters (100% coverage), so the baseline is 3. The description adds meaningful semantics by explaining the new_definition parameter supports both strings with \n and arrays of strings, which is beyond the schema's type declaration. It also clarifies the relationship between from_file and write_to_file. However, the array example contradicts the schema's 'string' type for new_definition, which could confuse an agent.

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: updating an existing rule definition. It includes a specific verb ('update'), the resource ('rule definition'), and explicitly differentiates from rename-rule, which is a sibling tool. The phrase 'in place' and preserving rule position adds clarity.

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?

The description explicitly states when to use it ('Modify rule logic, add alternatives, refine patterns, or fix issues') and refers to rename-rule as the alternative when changing the rule name. This direct guidance helps an agent choose between 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