register_input_state: Report session state to agents

View source: R/mcp-wrapper.R

register_input_stateR Documentation

Report session state to agents

Description

Registers a value that the ⁠MCP⁠ tool shiny_input_info reports next to the inputs, under the key "@state". Use it for state that changes what an agent should ask, for example whether the data loader is open (a closed loader usually means the data are loaded and the user wants to change analysis inputs only).

Usage

register_input_state(
  name,
  getter,
  description = "",
  session = shiny::getDefaultReactiveDomain()
)

Arguments

name

character string, the name of the state

getter

a function without arguments that returns the current value; it is called in shiny::isolate() each time shiny_input_info runs, and an error is reported as the state's error instead of failing the tool call

description

character string: what the value means, for agents

session

the shiny session (the module's session)

Value

NULL, invisibly

Examples

## Not run: 
# in a module server function
register_input_state(
  "loader_opened",
  function() isTRUE(loader_is_open()),
  description = "TRUE while the data loader is open"
)

## End(Not run)

shidashi documentation built on Oct. 12, 2026, 1:11 a.m.