Skip to main content
Glama

ternary_search

Read-onlyIdempotent

Searches a sorted numeric array for a target value or locates the maximum/minimum extremum in a unimodal array.

Instructions

Ternary search on a sorted array (search mode) or find the extremum of a unimodal array (max/min mode).

Input Schema

NameRequiredDescriptionDefault
modeNoMode: search (default), max, or min
arrayYesArray of numbers
targetNoValue to search for (search mode only)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.11

TDQS

A3.5/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false and openWorldHint, so the safety profile is covered structurally. The description adds genuine behavioral context by tying array shape to mode (sorted vs. unimodal), which is more than the annotations say. It omits what the call returns (index vs. value), and undefined behavior for edge cases, so it does not earn a 4.

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 well-formed sentence with zero filler, front-loading the algorithm and then partitioning behavior by mode. Nothing repeats the tool name or restates the schema verbatim.

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 carries the burden of saying what comes back — and it does not, leaving ambiguous whether the result is an index, a value, or a boolean. For a computational tool with no output schema, that is a meaningful gap, though the mode semantics and preconditions are otherwise adequately covered.

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%, so the baseline is 3; the schema already documents mode (with enum values and default), array, and target. The description contributes only the semantic constraint that array ordering depends on mode, which is marginal added meaning over the schema. It does not clarify what 'target' yields on success.

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?

The description names the specific algorithm (ternary search) and clearly splits the two behaviors by mode: searching a sorted array vs. finding the extremum of a unimodal array. That is a concrete verb+resource statement an agent can act on. It does not differentiate itself from the many other algorithm siblings (e.g. kmp_search, bfs_search, binary-style search tools), so it stops short of a 5.

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

Usage Guidelines3/5

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

The mode-to-behavior mapping implies when each mode applies ('search mode' for sorted arrays, 'max/min mode' for unimodal arrays), which is useful usage context. However, it never states prerequisites explicitly as constraints (array MUST be sorted for search, MUST be unimodal for max/min), nor what to do when the target is absent, nor any named alternative tool for plain linear/exact lookups.

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