Skip to main content
Glama
WattsonicAdmin

wattsonic-modbus-docs

Official

generate_client_code

Generates a client code template for a Modbus recipe in Python, Node.js, C#, or Go, including precondition checks, write sequence, confirmation reads, and keep-alive.

Instructions

Generate a client program template for a recipe, using the libraries of the website examples: Python pymodbus (ModbusTcpClient), Node.js modbus-serial, C# NModbus, Go goburrow/modbus. The template checks the preconditions, performs the write sequence with the documented function codes, reads the confirmation registers and runs the keep-alive. Conditional steps are behind flags that default to off. The code writes to a live inverter when run: review it first. This server only returns text and never connects to a device.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostNoInverter IP address to put in the template.192.168.1.100
unit_idNoModbus unit identifier (default 1).
languageYesTarget language.
recipe_idYesRecipe id from list_recipes, e.g. 'native.active_power_setpoint'.
transportNoOnly Modbus TCP (port 502) is generated.tcp

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.1

TDQS

A4.2/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does most of it well: it discloses that the server only returns text and never connects to a device (no side effects), that generated code performs real writes with documented function codes, and that conditional steps sit behind default-off flags. The residual gap is the exact return shape (a single code string?), which is not stated.

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 purpose, then escalates to the safety warning and the no-connection guarantee — good ordering. The opening sentence is long and the library enumeration is slightly verbose, but each element (preconditions, write sequence, confirmation reads, keep-alive) contributes to the agent's mental model.

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 code-generation tool with no output schema and 5 fully documented parameters, the description covers everything an agent needs: what is generated, in which languages, what the template does at runtime, the default-off behavior of optional steps, and the absence of server-side device contact. Only the literal response envelope is unstated, which is minor.

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 coverage is 100%, so host, unit_id, language, recipe_id, and transport are already fully documented in the schema, including the TCP-only const and the recipe_id example. The description's library mapping per language adds only marginal value beyond the enum. Baseline 3 applies when the schema does the heavy lifting.

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?

States a specific verb and deliverable: generate a client program template for a recipe, naming the exact libraries produced per target language. It is clearly distinct from the read/discovery siblings (list_recipes, get_recipe, validate_write) that surround it. An agent knows immediately what comes back and in what form.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

'The code writes to a live inverter when run: review it first' gives a concrete condition for handling the output cautiously, and the recipe_id constraint (from list_recipes) is stated in the schema. It stops short of explicitly routing against siblings such as validate_write or get_recipe, so the alternative-choice guidance is inferred rather than stated.

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