Skip to main content
Glama

segment_tree

Builds a segment tree for sum, min, or max range queries with point updates on a mutable numeric array. Use it to answer repeated range queries and apply index-based updates efficiently.

Instructions

Build a segment tree for range queries (sum/min/max) with point updates on a mutable array.

Input Schema

NameRequiredDescriptionDefault
valuesYesInitial array of numbers
operationNoAggregate operation (default sum)
operationsNoOperations: {type:'update',index,value} or {type:'query',left,right}

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.11

TDQS

B3.1/5.0
Behavior2/5

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

With no annotations, the description carries the full behavioral burden. It does not disclose whether the built tree persists across calls, what the return value looks like (query results? tree handle?), or how the operations list is processed, leaving significant behavioral gaps for a stateful-looking construct.

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 that front-loads the core action and enumerates the supported operations with zero filler. Nothing could be trimmed without losing meaning.

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 and no annotations, so the description is the only carrier of return/persistence behavior, and it omits that. For a moderately simple algorithmic tool the purpose is conveyed, but the agent cannot tell what calling it actually yields.

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 schema already documents values, operation (with enum), and operations. The description's mention of sum/min/max and point updates maps to the schema but adds no syntax or format detail beyond it, so the baseline 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?

The description gives a specific verb+resource ('Build a segment tree') and enumerates its capabilities (range sum/min/max queries and point updates). It is clear what the tool produces, but it does not differentiate from algorithmic siblings like fenwick_tree, sparse_table, or 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?

There is no explicit when-to-use or when-not-to-use guidance and no alternative tool is named. The phrase 'on a mutable array' implicitly hints at the scenario, but the agent is left to infer selection against the many other range-query/data-structure siblings.

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