Skip to main content
Glama

Matrix

matrix
Read-onlyIdempotent

Compute determinant, inverse, eigenvalues, transpose, rank, or trace of a numerical grid by supplying its rows as a JSON array of numbers or expressions.

Instructions

Structured matrix operations: det, inverse, eigenvalues, transpose, rank, trace.

evaluate_expression refuses Matrix([[1,2],[3,4]]) on purpose — [/] are denied there to block subscript-based RCE escapes, and a matrix literal is collateral from that (correctly aimed) screen. This tool is the structured replacement: rows is a JSON array of arrays (row-major), never a string to parse. Each entry is either a JSON number, used directly, or a scalar expression string ('1/2', 'sqrt(2)', 'x+1'), screened per-entry the same way evaluate_expression screens its input before anything reaches SymPy. Example: rows=[[1,2],[3,4]], op='det' -> -2.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
opYesOperation to apply: one of det, inverse, eigenvalues, transpose, rank, trace
rowsYesRow-major matrix as a JSON array of arrays; each entry is a number or a scalar expression string like 'sqrt(2)'

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 / op / description
      Added value: +"Operation to apply: one of det, inverse, eigenvalues, transpose, rank, trace"
    • addedInput schema / properties / rows / description
      Added value: +"Row-major matrix as a JSON array of arrays; each entry is a number or a scalar expression string like 'sqrt(2)'"
  2. Changed1 schema field changedv0.11.0
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "additionalProperties": true,
      +  "title": "matrixDictOutput",
      +  "type": "object"
      +}
  3. Addedv0.4.0

TDQS

A4.6/5.0
Behavior5/5

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

Beyond the readOnlyHint and idempotentHint annotations, the description discloses how entries are handled: JSON numbers are used directly, string entries are treated as scalar expressions, and each entry is screened per-entry like evaluate_expression. It also explains the security rationale for rejecting matrix literals in evaluate_expression, adding meaningful behavioral context not available in annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the operation list and follows with a clear example, but the RCE/security explanation is more verbose than necessary. Phrases like 'collateral from that (correctly aimed) screen' add color but not essential guidance, so the description could be tightened without losing meaning.

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 an output schema present, the description does not need to explain return values. It covers the input format, per-entry expression behavior, an example, and the relationship to evaluate_expression. It could still note shape constraints (e.g., square matrices for det/inverse/eigenvalues), but the core invocation details are sufficiently complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, but the description still adds value by specifying row-major ordering, the exact meaning of string entries ('1/2', 'sqrt(2)', 'x+1'), and that rows is never a string to parse. The op parameter is straightforwardly listed in both the first line and the schema, so no additional interpretation is needed.

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 first line, 'Structured matrix operations: det, inverse, eigenvalues, transpose, rank, trace,' names the resource and the exact operations, and the example with op='det' makes the behavior concrete. It also explicitly positions this tool against evaluate_expression, so an agent can distinguish it from the closely related sibling.

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 directly says evaluate_expression refuses Matrix([[...]]) and that this tool is 'the structured replacement.' This gives an explicit when-to-use-this vs. when-not-to-use-the-alternative rule. It also clarifies that rows must be JSON, not a string, which is crucial for correct invocation.

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