Skip to main content
Glama

prefix_function

Computes the KMP prefix/failure function array for an input string and optionally counts pattern occurrences to support string matching and failure-link analysis.

Instructions

Compute the KMP prefix/failure function array, with optional pattern occurrence counting.

Input Schema

NameRequiredDescriptionDefault
textYesInput string (max 1,000,000 chars)
patternNoOptional pattern to count occurrences of

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.11

TDQS

B3.3/5.0
Behavior3/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 does disclose the dual behavior — array computation alone, or array plus occurrence counting when a pattern is given — but says nothing about output shape (array of integers vs. a count), complexity, or what happens with empty/degenerate patterns.

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?

A single front-loaded sentence with no filler; the core operation is stated first and the optional mode second. Nothing can be trimmed without losing information.

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?

There is no output schema, so the description must convey the return value, and it does only loosely ('array' — but it is unclear what the tool returns when 'pattern' is supplied, e.g. array plus count versus count alone). For a two-mode computational tool this leaves a real ambiguity.

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 description coverage is 100%: the schema already defines 'text' (max 1,000,000 chars) and 'pattern' (optional pattern to count occurrences of). The description only restates the optional pattern role, adding no syntax, format, or constraint detail beyond the schema, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and algorithm resource ('Compute the KMP prefix/failure function array') and names the optional secondary behavior. It is distinguishable from algorithmic siblings such as kmp_search or kmp_automaton by naming the exact artifact produced, though it does not explicitly contrast itself with them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this versus the many adjacent string-algorithm siblings (kmp_search, kmp_automaton, z_function, z_algorithm). The mention that 'pattern' is optional is schema-level information, not usage direction.

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

Deploy Server

Other Tools