Skip to main content
Glama

UK Data: Code utilities

find_majority_element

Read-onlyIdempotent

Finds the majority element in a list that appears more than ⌊n/2⌋ times using Boyer-Moore voting algorithm. Returns the majority element if it exists, null otherwise. (cost: 1 credit)

Input Schema

NameRequiredDescriptionDefault
numsNoarray, required, list of integers to search

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.8/5.0
Behavior4/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. The description adds genuinely new behavioural detail beyond that: the exact algorithm (Boyer-Moore voting), the null return when no majority exists, and a credit cost of 1. It stops short of covering edge cases such as empty input or ties, which keeps it off a 5.

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?

Three short sentences, front-loaded with the core action, then return semantics, then cost. Nothing is redundant and every clause carries information the agent needs.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description correctly takes on the burden of explaining the return value (element or null), and it also discloses cost and algorithm. For a one-parameter pure function this is nearly sufficient; only edge-case behaviour (empty list, multiple candidates) is left unstated.

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% for the single `nums` parameter, so the baseline of 3 applies. The description adds the majority-element condition the list is being tested against, but gives no format or size guidance, and notably the schema allows a string or an array of strings while the prose says "list of integers" — a mismatch the description does not resolve.

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 and resource ("finds the majority element in a list") and even defines the mathematical criterion (appears more than ⌊n/2⌋ times) plus the algorithm used. It is unambiguous on its own, but it does not distinguish itself from near-neighbour tools such as find_duplicate_number or find_missing_number, which an agent scanning the sibling list might confuse it with.

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?

Usage is only implied: the definition of majority element tells an agent what input qualifies, but there is no explicit when-to-use or when-not-to-use guidance and no named alternative for related array-search tasks. The agent must infer that this is the right tool for majority-frequency queries.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources