Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

find-rule

Search ANTLR4 grammar rules by exact name, regex, wildcard, or partial match. Retrieve rule definitions, references, and usage counts to debug and understand grammar relationships.

Instructions

Find rules with multiple matching modes: exact, regex, wildcard, or partial matching.

When to use: Locate specific rules, understand rule relationships, or discover rules matching a pattern.

Matching Modes:

  1. Exact (default) - Exact rule name match: rule_name: "expression"

  2. Regex - Regular expression pattern: rule_name: "^[A-Z]+$" match_mode: "regex" (Finds all lexer rules)

  3. Wildcard - Shell-style wildcards (* and ?): rule_name: "expr*" match_mode: "wildcard" (Finds expression, expr, exprStatement, etc.)

    rule_name: "stat?" match_mode: "wildcard" (Finds stat1, stat2, stats, etc.)

  4. Partial - Substring/contains search (case-insensitive): rule_name: "token" match_mode: "partial" (Finds tokenList, getToken, TOKEN_TYPE, etc.)

Examples:

  • All lexer rules: rule_name="^[A-Z]+$", match_mode="regex"

  • All parser rules: rule_name="^[a-z]+$", match_mode="regex"

  • Rules starting with "expr": rule_name="expr*", match_mode="wildcard"

  • Rules containing "statement": rule_name="statement", match_mode="partial"

Returns (exact match):

  • Rule definition, type, and line number

  • Referenced rules (fan-out: what this rule uses)

  • Referencing rules (fan-in: what uses this rule)

  • Usage count

Returns (pattern match):

  • All matching rules with their details

  • Match count

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_fileNoOptional: path to a grammar file to read
rule_nameYesRule name or pattern. For wildcards: * matches any characters, ? matches single character. For regex: use standard regex syntax.
use_regexNoDEPRECATED: Use match_mode="regex" instead. If true, treats rule_name as regex pattern.
match_modeNoMatching mode: "exact" (default, exact name), "regex" (regex pattern), "wildcard" (* and ?), "partial" (substring search)
grammar_contentNoThe content of the ANTLR4 grammar file
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains the default matching mode, the different behavior for exact vs. pattern matches, and the return data (rule definition, fan-in/fan-out, usage count). It lacks an explicit statement that this is a read-only operation, which would push it to 5.

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 a clear summary, 'When to use' section, labeled matching modes with examples, and a 'Returns' section. It is moderately sized but every sentence earns its place, and the use of bullet points enhances scannability.

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?

There is no output schema, so the description must explain return values, and it does: it details what is returned for exact matches (definition, type, line number, fan-in/fan-out, usage count) and for pattern matches (matching rules, match count). Combined with thorough coverage of matching modes, this makes the tool context complete for an agent.

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 description coverage is 100% (baseline 3), but the description adds significant value by giving concrete examples for each matching mode and explaining how rule_name is interpreted differently in each mode (e.g., regex syntax, wildcard characters, case-insensitive partial). This goes beyond the schema's simple parameter descriptions.

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 opens with a specific verb and resource: 'Find rules with multiple matching modes' and clearly distinguishes itself from siblings like list-rules and find-rule-usages by emphasizing pattern matching. It explicitly names four matching modes, leaving no ambiguity about the tool's purpose.

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 provides clear context: 'Locate specific rules, understand rule relationships, or discover rules matching a pattern.' However, it does not explicitly mention when not to use it or name alternative sibling tools, so it stops short of a 5.

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