Skip to main content
Glama

Moltline Optimize

Knapsack Select

knapsack_select
Read-onlyIdempotent

Choose the items that maximise value under one or more capacity limits. FREE.

Typical input {"items": [{"id": "a", "value": 60, "weight": 10, "cost": 120}, {"id": "b", "value": 100, "weight": 20, "cost": 300}], "limits": {"weight": 25, "cost": 400}} returns {"selected": ["a"], "value": 60, "used": {"weight": 10, "cost": 120}, "slack": {"weight": 15, "cost": 280}, "solver_status": "OPTIMAL"}. Any numeric item field named in limits is a constrained resource; qty lets an item be taken several times. Use for budgets, cargo, campaign or feature selection. Not for dependencies between items. Errors: on invalid, missing, or malformed input this tool never raises a protocol error; it returns {"error": ""} (for example {"error": "items must be a non-empty list of "}). Every call is read-only and idempotent, so after correcting the input it is always safe to retry.

Input Schema

NameRequiredDescriptionDefault
itemsYes{id, value, qty, <resource fields>}: value to maximise plus one number per limited resource.
limitsYes{resource_name: capacity} for each constrained field.
time_limit_sNosolver time budget in seconds (default 3, max 15).

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.7/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, destructiveHint and openWorldHint, so the bar is lower. The description still adds real value: it discloses that errors are returned as {"error": ...} objects rather than protocol errors, and that retry after correction is always safe. It does not discuss solver non-optimality/timeout behavior beyond the time_limit_s parameter.

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

Conciseness4/5

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

Front-loaded with the core purpose and use cases, and the example is illustrative rather than padding. The inline JSON example is fairly long, but it earns most of its space by showing input/output shapes and slack/solver_status semantics.

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

Completeness5/5

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

For a solver tool with an output schema, nested objects and 100% schema coverage, the description covers purpose, input shape, an example return, error contract and retry safety. Nothing essential an agent needs to call it correctly is missing.

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

Parameters5/5

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

Schema coverage is already 100%, yet the description adds semantics not in the schema: any numeric item field named in limits is treated as a constrained resource, and qty allows repeated selection of an item. That is meaningful behavioural meaning beyond the field descriptions.

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?

Names a specific operation (choose items maximising value under capacity limits) and a concrete resource model (items with value plus constrained fields). It also distinguishes scope from siblings like pack_bins/cutting_stock by stating what it is not for (dependencies between items).

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?

Explicitly lists concrete use cases (budgets, cargo, campaign or feature selection) and an explicit exclusion ('Not for dependencies between items'). This gives an agent both positive selection criteria and a routing boundary.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.