Skip to main content
Glama

Combinatorics Operation

combinatorics_operation
Idempotent

Compute binomial coefficients, permutations, combinations, partitions, factorial, Catalan, Fibonacci, and Bell numbers from integer inputs.

Instructions

Combinatorics: binomial coefficients, permutations, combinations, integer partitions, factorial, Catalan, Fibonacci and Bell numbers. Prefer this over evaluate_sage for any of these.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kNoSecondary argument (for binomial, combinations). Decimal strings accepted, as for n.
nYesPrimary integer argument. Values at or above 2^53 must be passed as a decimal string, e.g. "9007199254740993", because a JSON number that large has already been rounded by the client.
sessionNoWorkspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the same workspace across reconnects and is a bearer credential -- keep it secret. Omit for 'default'.default
operationYesOne of: binomial (n choose k), permutations (n!), combinations (n choose k), partitions (COUNT of integer partitions of n), factorial (n!), catalan (nth Catalan number), fibonacci (nth Fibonacci number), bell (nth Bell number). All return a single integer.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.7.0
    • changedInput schema / properties / session / description
      Previous value: -"Named workspace to use. Workspaces have independent variables; omit for 'default'."New value: +"Workspace to use, as a name or a portable handle. Workspaces have independent variables. A name is scoped to this MCP session; a handle returned by start_sage_session (workspace_token) reaches the same workspace across reconnects and is a bearer credential -- keep it secret. Omit for 'default'."
  2. Changed7 schema fields changedv0.5.0
    • changedInput schema / properties / k / anyOf
      Previous value: -[
      -  {
      -    "type": "integer"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "type": "integer"
      +  },
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedInput schema / properties / k / description
      Previous value: -"Secondary argument (for binomial, combinations)"New value: +"Secondary argument (for binomial, combinations). Decimal strings accepted, as for n."
    • addedInput schema / properties / n / anyOf
      Added value: +[
      +  {
      +    "type": "integer"
      +  },
      +  {
      +    "type": "string"
      +  }
      +]
    • changedInput schema / properties / n / description
      Previous value: -"Primary integer argument"New value: +"Primary integer argument. Values at or above 2^53 must be passed as a decimal string, e.g. \"9007199254740993\", because a JSON number that large has already been rounded by the client."
    • removedInput schema / properties / n / type
      Removed value: -"integer"
    • changedInput schema / properties / operation / description
      Previous value: -"One of: binomial, permutations, combinations, partitions, factorial, catalan, fibonacci, bell"New value: +"One of: binomial (n choose k), permutations (n!), combinations (n choose k), partitions (COUNT of integer partitions of n), factorial (n!), catalan (nth Catalan number), fibonacci (nth Fibonacci number), bell (nth Bell number). All return a single integer."
    • addedInput schema / properties / session
      Added value: +{
      +  "default": "default",
      +  "description": "Named workspace to use. Workspaces have independent variables; omit for 'default'.",
      +  "type": "string"
      +}
  3. First observedv0.3.1

TDQS

A4.2/5.0
Behavior3/5

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

Annotations already declare idempotentHint=true and destructiveHint=false, so the agent knows this is a safe, non-destructive operation. The description adds no behavioral context beyond the operation list; it doesn't mention side effects, permissions, or return behavior beyond what the schema states. With annotations covering the safety profile, a 3 is appropriate.

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 two sentences with zero waste. The operation list is front-loaded, and the preference over evaluate_sage is stated immediately after. Every word earns its place.

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 tool's simplicity and the presence of an output schema, the description is complete enough. It covers the operations and the key alternative. The session parameter is documented in the schema, and return values are stated in the operation parameter description ('All return a single integer'). Minor gaps like error handling aren't necessary here.

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 all parameters (operation, n, k, session) are already documented in the schema. The description's list of operations mirrors the operation parameter's description without adding new information. It doesn't explain parameter formats or edge cases beyond the schema, so 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?

The description clearly states the tool performs combinatorics operations and enumerates the specific types (binomial, permutations, combinations, partitions, factorial, Catalan, Fibonacci, Bell). It distinguishes itself from the sibling evaluate_sage by explicitly saying to prefer this tool for these operations, so an agent can tell them apart.

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

Usage Guidelines5/5

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

The description gives an explicit when-to-use directive: 'Prefer this over evaluate_sage for any of these.' This names the primary alternative and the condition for choosing this tool, which is exactly the kind of guidance needed. It doesn't list other siblings but the key alternative is covered.

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