Skip to main content
Glama

lehmer_code

Convert between permutations and Lehmer codes, and compute lexicographic rank or unrank permutations to support combinatorial indexing and ordering.

Instructions

Convert between permutations and Lehmer codes, compute permutation rank and unrank.

Input Schema

NameRequiredDescriptionDefault
nNoPermutation size for unranking (use with rank)
rankNoLexicographic rank to decode (use with n)
permutationNoPermutation of [0..n-1] to encode

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.11

TDQS

A3.5/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full behavioral burden. It does not explain input validation (e.g. that the permutation must be of [0..n-1]), error behavior for invalid inputs, or what the return shape looks like for the different modes.

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, tight sentence with zero filler that front-loads the core purpose.

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?

For a 3-parameter pure-function tool with no output schema and no annotations, the description is minimally adequate but omits how the three optional parameters combine into distinct operations and what is returned.

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 parameter documentation is already handled by the schema. The description adds no meaning beyond restating the conversion concept; baseline 3 applies.

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?

States a precise verb+resource: converting between permutations and Lehmer codes, plus rank/unrank. This clearly distinguishes it from sibling combinatorics tools like permutation_calc or catalan_calc.

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 mention of 'use with rank' and 'use with n' in the schema implies the two modes (encoding vs unranking), but the description itself gives no explicit when-to-use guidance or alternative routing.

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