Skip to main content
Glama

Analyze Complexity

analyze_complexity
Read-onlyIdempotent

Estimate asymptotic Big-O time complexity of a code snippet through structural analysis. Identify performance scaling without running the code.

Instructions

Estimate the asymptotic (Big-O) time complexity of a code snippet via structural analysis.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesSource code snippet to analyze structurally for its asymptotic time complexity
languageNoLanguage `code` is written in; default 'python3'python3

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.12.0
    • addedInput schema / properties / code / description
      Added value: +"Source code snippet to analyze structurally for its asymptotic time complexity"
    • addedInput schema / properties / language / description
      Added value: +"Language `code` is written in; default 'python3'"
  2. Changed1 schema field changedv0.11.0
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": true,
      +  "title": "analyze_complexityDictOutput",
      +  "type": "object"
      +}
  3. Changed5 schema fields changedv0.2.0
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / code / title
      Added value: +"Code"
    • addedInput schema / properties / language / title
      Added value: +"Language"
    • addedInput schema / title
      Added value: +"analyze_complexityArguments"
    • changedOutput schema / (root)
      Previous value: -{
      -  "additionalProperties": true,
      -  "type": "object"
      -}New value: +null
  4. First observedv0.1.0

TDQS

A4.2/5.0
Behavior4/5

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

With annotations already indicating readOnlyHint, openWorldHint=false, and idempotentHint, the description adds value by stating 'structural analysis', implying the code is not executed. This goes beyond the annotations and helps an agent understand the tool's non-executing behavior.

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?

The description is a single, compact sentence with no filler. It front-loads the core purpose and the method in a way an agent can parse immediately.

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?

Given the annotations, full schema parameter documentation, and the presence of an output schema, the description is sufficient for a tool of this complexity. It could mention limitations or rough heuristics, but 'estimate' already signals approximate results.

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 coverage is 100%, so the parameters are already well documented. The description only reinforces the 'code snippet' nature and does not add significant new meaning beyond the schema, placing it at the baseline for this dimension.

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?

The description uses a specific verb ('Estimate') and a specific object ('asymptotic (Big-O) time complexity'), and clarifies the method ('via structural analysis'). This clearly distinguishes it from execution or benchmarking siblings like execute_code and compare_execution.

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

Usage Guidelines4/5

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

The description makes clear that the tool is for static, structural complexity estimation rather than runtime measurement. It provides useful context for when to choose it over execution-based tools, though it does not explicitly name alternatives or edge cases where it should not be used.

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