Skip to main content
Glama

knapsack_solve

Read-onlyIdempotent

Solves the 0-1 knapsack problem by selecting items that maximize total value without exceeding a specified weight capacity.

Instructions

Solve the 0-1 knapsack problem: pick items to maximize value within a weight capacity.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "capacity": "<capacity>",
      "items": "<items>"
    },
    "name": "knapsack_solve"
  }
}

Input Schema

NameRequiredDescriptionDefault
itemsYesArray of { name?, weight, value } objects.
capacityYesMaximum weight capacity (integer units, max 100000).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.11

TDQS

B3.2/5.0
Behavior2/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint=false, so the safety profile is covered structurally. The description adds almost nothing behavioral beyond restating the problem: it does not say what the result contains, how ties are broken, whether fractional weights are supported, or what happens on infeasible input. With annotations carrying the safety burden, this is a below-baseline but non-contradictory disclosure.

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?

A single front-loaded sentence with the verb, the algorithm, and the optimization objective in that order. Nothing is padded and nothing needs to be moved earlier.

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?

There is no output schema, so the description should explain what a caller receives: the selected items, total value, total weight, or just an optimum value? It also omits distinguishing behavior such as tie-breaking and input integrality. For a solver whose entire value is its return value, that is a meaningful gap.

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%, with capacity documented as integer units with a max of 100000 and items documented as {name?, weight, value}. The description adds no further semantics about parameter format or constraints, so the schema does all the work and the baseline 3 applies.

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?

States a specific verb and named algorithm ("Solve the 0-1 knapsack problem") plus the objective, so the resource is unambiguous. It does not distinguish itself from near-neighbors in the same space such as tsp_solve, simplex_solve, hungarian_assign, or coin_change, so an agent must still rely on the name to route.

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?

The usage is implied by the problem definition: an agent holding a capacity and a list of weight/value items knows this applies. However, there is no explicit when-to-use framing, no statement of when a different solver (e.g. tsp_solve, hungarian_assign) is the right choice, and no preconditions.

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

Deploy Server

Other Tools