Skip to main content
Glama

set_function

Turn a DCC locomotive's decoder function (F0-F28) on or off by specifying address, function number, and state. Auto-acquires throttle and handles redundant requests.

Instructions

Turn one of a locomotive's decoder functions (F0-F28) on or off.

Args: address: DCC address. Auto-acquires the throttle if needed. function: 0-28 inclusive (validated locally; out-of-range returns an error without contacting JMRI). What each number controls is decoder/roster-specific — F0 is almost always headlight(s) (see lights_on/lights_off), F1-F28 vary loco to loco (bell, horn, sounds, couplers...). If the user names a function by effect ("turn on the bell", "rear lights") rather than a number, call get_locomotive_functions(name) FIRST to check for a user-set label before guessing or asking — only ask for the F-number if no label matches. state: True to turn the function on, False to turn it off.

Safe to call repeatedly with the same state: JMRI silently no-ops a redundant request, and a local per-function cache (kept fresh by JMRI's own broadcasts from ANY client holding this address) avoids hanging on a repeat or externally-toggled function.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateYes
addressYes
functionYes
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses that the tool auto-acquires the throttle if needed, validates the function locally, and is safe to call repeatedly due to JMRI's silent no-op and a local cache kept fresh by broadcasts. This provides good behavioral context, though it could mention potential side effects like sending commands to JMRI.

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 description is well-structured with clear paragraphs and bullet-like separations for each parameter. It is informative without being overly verbose, though it could be slightly more concise by removing redundant phrasing like 'kept fresh by JMRI's own broadcasts from ANY client holding this address'.

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?

Given that there are 3 parameters, no output schema, and no annotations, the description is remarkably complete. It covers purpose, usage guidelines, behavioral traits (auto-acquire, local validation, idempotency), parameter semantics (including cross-references to sibling tools), and caching behavior. This is sufficient for an agent to use the tool correctly.

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

Parameters4/5

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

Schema coverage is 0%, so the description must and does add meaning. It explains that address auto-acquires the throttle, that function is validated locally and its meaning is decoder-specific, and that state is a boolean. It also adds context about function labels and the cache, which goes beyond the schema's bare definition.

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?

The description clearly states the tool's action: turning a locomotive's decoder functions (F0-F28) on or off. It distinguishes itself from siblings like lights_on/lights_off by noting that F0 is almost always headlights and that other functions vary per decoder. It also cross-references get_locomotive_functions for user-set labels, providing clear differentiation.

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 description provides explicit guidance: if a user names a function by effect, call get_locomotive_functions first; only ask for the F-number if no label matches. It also states that out-of-range function numbers return an error without contacting JMRI. While it doesn't explicitly list when not to use the tool, the context is clear enough.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HO44-PROJECT/MrJ-JMRI-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server