Skip to main content
Glama
natl-set

ANTLR4 MCP Server

by natl-set

generate-tokens-from-pattern

Generate ANTLR4 lexer tokens from natural language input patterns, converting sample text into grammar rules for prototyping.

Instructions

Generate lexer tokens automatically from natural language input patterns.

When to use:

  • Quick token generation from sample input text

  • Convert configuration snippets into grammar rules

  • Generate tokens from command examples

  • Prototype grammars from example input

Example - Generate tokens from command: input_pattern: "ignore config system ftm-push" → Generates: IGNORE, CONFIG, SYSTEM, FTM_PUSH tokens

Example - Generate single compound token: input_pattern: "config-system-admin" tokenize: false → Generates: CONFIG_SYSTEM_ADMIN token

Example - Add prefix to generated tokens: input_pattern: "show running-config" prefix: "CMD" → Generates: CMD_SHOW, CMD_RUNNING_CONFIG tokens

Features:

  • Automatic tokenization (splits on whitespace by default)

  • Intelligent name generation (uppercase with underscores)

  • Optional prefix for token namespacing

  • Supports all standard token options (skip, channel, fragment)

  • Generates proper ANTLR4 string literal patterns

Returns:

  • List of generated tokens with names and patterns

  • Per-rule success/failure status

  • Modified grammar

  • Summary of results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
skipNoIf true, adds "-> skip" directive to all generated tokens
prefixNoOptional: Prefix to add to all generated token names
channelNoOptional: Channel name for all generated tokens
fragmentNoIf true, marks all generated tokens as fragments
tokenizeNoIf true (default), splits input into individual tokens. If false, creates single token.
from_fileNoOptional: path to a grammar file to read. Required if using write_to_file.
input_patternYesInput text to generate tokens from (e.g., "ignore config system ftm-push")
write_to_fileNoIf true, writes modified grammar back to from_file
grammar_contentNoThe ANTLR4 grammar file content
Behavior4/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. It discloses key behavioral traits: automatic tokenization, intelligent name generation, optional prefix support, support for token options (skip, channel, fragment), and generation of ANTLR4 string literal patterns. It also lists return values (list of tokens, per-rule status, modified grammar, summary). It does not explicitly warn about potential file mutation via write_to_file, but that is disclosed in the schema. The description provides substantial behavioral detail beyond the schema.

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 structured with clear sections (When to use, Examples, Features, Returns) and uses bold headers. While it is relatively long (~200 words), every section contributes useful information. The examples are concrete and aid comprehension. It is not overly verbose, but could be slightly trimmed without losing value.

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?

The tool has 9 parameters and no output schema, so the description must cover return values and behavior. It does so by listing output categories and providing examples. It also covers most relevant scenarios (tokenization, prefixing, token options). It does not fully explain the interplay between from_file and write_to_file, but that is available in the parameter descriptions. Overall, it is quite complete for a complex tool.

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%, so baseline is 3. The description adds value beyond the schema through concrete examples illustrating how to use input_pattern, tokenize, and prefix. The features section also explains the tokenization behavior that parameters like tokenize control. This enhances understanding of parameter semantics without duplicating schema text.

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 clear verb+resource: 'Generate lexer tokens automatically from natural language input patterns.' The examples further clarify the exact functionality, and this is distinct from sibling tools like 'preview-tokens' (which likely previews tokens) or 'add-tokens-with-template' (which uses templates). The purpose is unambiguous and well-differentiated.

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 lists specific scenarios (quick token generation, converting configuration snippets, generating tokens from command examples, prototyping grammars). This provides clear context for when the tool is appropriate. It does not explicitly mention alternatives or exclusions relative to sibling tools, which would push it to a 5, but the guidance is sufficient for selecting it in common cases.

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