Skip to main content
Glama

solve_knapsack

Maximize item value under a weight capacity constraint by solving the 0/1 knapsack problem. Provide item values, weights, and capacity to get the optimal selection.

Instructions

Solve the classic 0/1 knapsack problem: maximize value subject to weight capacity constraint.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valuesYesValue of each item
weightsYesWeight of each item
capacityYesMaximum weight capacity of the knapsack

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description must carry the full behavioral burden. It states the optimization goal but omits critical traits: whether the solution is exact, expected input size limits, runtime characteristics, and what the return value contains. This is insufficient for a solver tool.

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, well-structured sentence that front-loads the problem class and the optimization objective. It contains no redundant or wasted words.

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

Completeness2/5

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

For a solver with no annotations and no output schema, the description is too sparse. It fails to explain the return value (e.g., optimal value and/or selected items) and provides no behavioral context about the solving process, leaving the agent with significant gaps.

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 all three parameters (values, weights, capacity) with clear meanings. The description adds no additional parameter semantics or formatting details beyond what the schema provides, making the baseline of 3 appropriate.

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 states a specific verb+resource: 'Solve the classic 0/1 knapsack problem', and specifies the objective (maximize value) and constraint (weight capacity). It does not, however, differentiate itself from sibling solvers like solve_linear_program or solve_integer_program, leaving the agent to infer that this is the specialized tool for knapsack problems.

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?

The description offers no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, exclusions, or the sibling solvers, leaving the agent without any explicit routing cues beyond the problem name.

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