Skip to main content
Glama

Autotune an embedded controller

autotune_embedded_controller_with_c_codegen

Tune a linear plant and write a zero-heap C99 bundle.

The reply's codegen object lists mpc_bundle.h and mpc_bundle.c plus usage_example_c and controller_kind. A linear plant is a condensed QP (linear_qp). A nonlinear plant, including differential drive, is a linearized iteration (linearized_rti): Jacobians at the current state, then projected-gradient steps. That is not a full nonlinear SQP. Compile with gcc -O3 -std=c99 -Wall -Wextra -fPIC -shared -lm. Each control step is mpc_compute_u0 then, after the plant measurement, mpc_observer_update. Neither function allocates on the heap. MPC_NX, MPC_NU, MPC_ND, and MPC_HORIZON in the header are the array sizes.

Same payment as autotune_template: X-API-Key spends 2 autotune credits, and a missing key or an empty pack is HTTP 402 for x402.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "autotune_embedded_controller_with_c_codegen"
  }
}

Input Schema

NameRequiredDescriptionDefault
max_trialsNoOptuna trials before the C99 bundle is written. Default 1. Values below 1 are raised to 1. Paid at $2.00: X-API-Key spends 2 autotune credits, or HTTP 402 is x402 Base USDC. Each call starts a new study and writes a new bundle.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / max_trials / description
      Added value: +"Optuna trials before the C99 bundle is written. Default 1. Values below 1 are raised to 1. Paid at $2.00: X-API-Key spends 2 autotune credits, or HTTP 402 is x402 Base USDC. Each call starts a new study and writes a new bundle."
  2. First observed

TDQS

A3.9/5.0
Behavior5/5

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

Annotations only say this is not read-only, not idempotent, not destructive, and closed-world; the description adds substantially more: exact reply structure, required compile command, the mpc_compute_u0 / mpc_observer_update call sequence, the guarantee that neither allocates on the heap, and the macro names defining array sizes. It also discloses auth and cost behavior (X-API-Key spends 2 autotune credits, HTTP 402 / x402 Base USDC otherwise) with no contradiction of the annotations.

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?

The core action is front-loaded in a single sentence and the rest is grouped logically into output contents, algorithm choice, build/runtime instructions, and payment. It is dense and technical but nearly every sentence carries operational weight; only the payment sentence partly duplicates the schema's cost note.

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?

For a code-generating tool with a single optional parameter, the definition covers the returned artifacts, build flags, runtime contract, and billing conditions, which is more than enough to invoke it correctly. The one real gap is that it never says where the plant model itself comes from, given the schema accepts only max_trials, leaving the input source to be inferred from other tools.

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?

There is only one parameter (max_trials) and schema description coverage is 100%, so the schema already carries default, floor behavior, pricing, and per-call study semantics. The prose adds nothing about max_trials; 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?

The description opens with a specific verb+resource pair: "Tune a linear plant and write a zero-heap C99 bundle," and names the emitted artifacts (mpc_bundle.h/.c, usage_example_c, controller_kind). It distinguishes the two controller kinds (linear_qp vs. linearized_rti), though it never explicitly contrasts itself with autotune_template beyond sharing its payment model.

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?

Usage is only implied: an agent must infer that this is the tool for generating embedded C code from a plant model. There is no when-to-use/when-not guidance and no explicit routing against the sibling autotune_template or the job-based start/get tools. The "not a full nonlinear SQP" note clarifies the algorithm, not the tool-selection decision.

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.