Skip to main content
Glama

mos_algorithm

Answers offline range sum and distinct count queries on arrays using Mo's algorithm with sqrt decomposition.

Instructions

Offline range query processing using Mo's algorithm with sqrt decomposition (range sum and distinct count).

Input Schema

NameRequiredDescriptionDefault
arrayYesInput array of numbers
queriesYesRange queries as [l, r] pairs (0-indexed, inclusive)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.11

TDQS

C2.9/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 burden, yet it says nothing about the return shape, whether the input array is mutated, complexity/latency, or limits on query count. The only real behavioral signal is 'offline', which does usefully imply the queries are batched, but the rest of the behavioral profile is absent.

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?

A single front-loaded sentence with no filler; the technique, the decomposition strategy, and the supported query types are all packed in efficiently. Slightly dense but nothing redundant.

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?

With no output schema and no annotations, the description should clarify the return format, and it only partially does by naming the two computed quantities. Parameters are fully covered by the schema, so the remaining gap is modest but real.

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% (array of numbers, [l, r] 0-indexed inclusive pairs), so the schema already documents both parameters. The description adds the semantics of the computation (range sum, distinct count), but no syntax or format detail beyond the schema.

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?

It names a specific technique and resource ('Mo's algorithm with sqrt decomposition') and states exactly what queries it answers (range sum and distinct count), so an agent can tell what it computes. It does not, however, differentiate itself from the many neighbouring range-query tools (fenwick_range, segment_tree, sparse_table, rmq_sparse).

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?

No when-to-use guidance and no named alternative is given, despite dozens of sibling range-query/sequence tools. The word 'offline' hints that all queries must be supplied up front, but this is never stated as a condition for choosing this tool over an online structure.

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