Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

add-rules

Add multiple mixed parser and lexer rules to an ANTLR4 grammar in a single bulk operation, enabling rapid grammar setup and prototyping with per-rule success reporting.

Instructions

Add multiple mixed parser and lexer rules in a single operation (bulk add).

When to use: Set up complete grammar structure, add both tokens and parsing rules together, or quickly prototype.

Example - Add mixed rules: rules: [ { type: "lexer", name: "PLUS", pattern: "'+'" }, { type: "lexer", name: "MINUS", pattern: "'-'" }, { type: "parser", name: "expression", definition: "term ((PLUS | MINUS) term)*" }, { type: "parser", name: "term", definition: "INT | ID" } ] write_to_file: true

Features:

  • Handles both lexer and parser rules in one operation

  • Rules sorted alphabetically within their type category

  • 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 mixed rules to add. Each rule requires type and name. Lexer rules need pattern, parser rules need definition.
from_fileNoOptional: path to a grammar file to read. Required if using write_to_file.
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 provided, the description fully discloses key behaviors: alphabetical sorting, duplicate prevention, partial success, atomic per-rule operations, and per-rule reporting. Also explains return values and file write behavior, exceeding what annotations would typically convey.

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 for when to use, an example, features, and returns. Although lengthy, every sentence contributes value and there is no redundancy or fluff.

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?

For a complex bulk operation with mixed rule types and partial success, the description covers usage context, behavioral details, return format, and a concrete example. Without an output schema, it still explains what the caller receives, making the description complete.

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?

Since schema description coverage is 100%, the schema already documents all parameters. The description adds an example demonstrating the rules array structure, but no additional parameter semantics beyond what the schema provides, so the 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?

States clearly that it adds multiple mixed lexer and parser rules in a single operation, distinguishing it from singular add-rule sibling. The verb 'Add' and resource 'multiple mixed parser and lexer rules' are specific and unambiguous.

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?

Provides explicit 'When to use' scenarios such as setting up complete grammar structure or prototyping, but does not explicitly name alternatives or state when not to use the tool. Clear context without exclusions.

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