Skip to main content
Glama
regexlab-mcp
by 0xmortuex

convert_pattern

Translate regular expressions between Python and JavaScript syntax, flagging unsupported features and validating the converted pattern in the target engine.

Instructions

Translate a regex between Python and JavaScript syntax, with explicit warnings.

Handles named groups and named backreferences, \A \Z and $ (using exact lookaround equivalents), inline global flags, verbose mode, {,n}, \U and \u{...} escapes, [^] and [], and the g/y/u flags. Things with no equivalent (atomic groups, possessive quantifiers, \p{..} in Python re, POSIX classes, recursion) are left unchanged and listed as WARNINGS. Differences that cannot be fixed syntactically (Unicode-aware \d \w vs ASCII-only) are listed too. The result is compiled in the target engine to prove it is at least valid; run test_regex or compare_engines to prove it is equivalent.

from_engine / to_engine: "python", "javascript" (or "js"), "regex". flags: flags of the source pattern; the converted flags are returned.

Input Schema

NameRequiredDescriptionDefault
flagsNo
patternYes
timeout_sNo
to_engineYes
from_engineYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses that unsupported constructs (atomic groups, possessive quantifiers, \p{..}, POSIX classes, recursion) are left unchanged and reported as WARNINGS, and that unfixable semantic differences are listed. It also reveals the verification step of compiling in the target engine. It does not mention the timeout behavior or failure modes for invalid source patterns.

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?

Purpose is front-loaded in a single line, then details follow in a logical order: handled constructs, unhandled constructs, verification path, then parameter notes. The construct catalogue is long but each item informs the agent about coverage limits. Minor waste in the awkward escaped literal rendering (\A \Z, {,n}).

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

Completeness3/5

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

An output schema exists, so return values need no explanation, and the description thoroughly covers conversion scope and warnings. The gaps are the unexplained timeout_s parameter and the absence of any statement about what happens when the target engine rejects the converted pattern, which matters for a tool that admits conversions may be invalid.

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 coverage is 0%, so the description must compensate. It does supply the allowed values for from_engine and to_engine ("python", "javascript"/"js", "regex") and explains that flags are the source pattern's flags with converted flags returned — genuinely useful given the schema has no enums. However, pattern and timeout_s receive no explanation at all, leaving one of five parameters completely undocumented.

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 opening sentence names a specific verb and resource — translating a regex between Python and JavaScript syntax — and the closing note routes validation work to test_regex and compare_engines. An agent can distinguish this from explain_regex or check_backtracking without opening any schema.

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 description states the follow-up condition clearly: use test_regex or compare_engines to prove equivalence, implying this tool only produces a candidate conversion. It gives no explicit when-not-to-use guidance versus explain_regex or replace_preview, but the context is otherwise unambiguous.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.