Skip to main content
Glama

set_function

Turn on or off DCC locomotive decoder functions F0-F28 by address and function number. Uses cached state to avoid redundant commands.

Instructions

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

Args: address: The locomotive's DCC address. Acquires the throttle automatically if this session doesn't already hold it. function: Function number, 0-28 inclusive (validated; anything outside that range returns an error rather than being sent to JMRI). What each number actually controls is decoder/ roster-specific — F0 is almost universally the headlight(s) (see lights_on/lights_off below for that common case), but F1-F28 vary loco to loco (bell, horn, sound effects, couplers, etc.). If a 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 fall back to asking the user for the F-number if that loco has no label matching what they described. state: True to turn the function on, False to turn it off.

Safe to call repeatedly with the same state: like set_speed/ set_direction, JMRI silently no-ops a redundant "already in this state" request instead of replying, and this tool checks a local per-function cache — kept fresh by JMRI's own broadcasts from ANY client holding this address, not just this one — before deciding whether to send anything, so a repeat call (or a function last toggled by a JMRI panel/PanelPro) still reports the correct current state instead of hanging.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateYes
addressYes
functionYes
Behavior5/5

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

No annotations exist, so description bears full burden. It discloses throttle auto-acquisition, validation of function number, cache check via JMRI broadcasts, and no-op for redundant calls. Side-effects and safety are clearly 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?

Well-structured with purpose first, then parameter details, then behavioral notes. Slightly verbose in the function guidance section, but every sentence adds value.

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?

Covers purpose, parameters, usage guidelines, and behavioral details comprehensively. Lacks explicit description of the return/response format, but given no output schema, the description is nearly complete.

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 description coverage is 0%, but description compensates fully: address explains DCC and throttle acquisition, function explains range and roster-specific meaning with guidance on user labeling, state explains boolean meaning.

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 first sentence clearly states the tool turns locomotive decoder functions F0-F28 on or off. It distinguishes from sibling tools like lights_on/off by noting F0 is typically headlights but those have separate tools.

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?

Provides explicit guidance: use lights_on/off for F0 headlights, and call get_locomotive_functions first if user names a function by effect. Also mentions safe to call repeatedly, indicating idempotent usage.

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