| register_io | R Documentation |
MCP AccessRegister shiny inputs and outputs for MCP (Model Context
Protocol) agent access.
register_input() wraps a shiny input constructor to
register metadata. It evaluates expr and returns the UI element,
with tooltip as its hover tip (the HTML title
attribute). as_tooltip() gives the default hover tip: the first
sentence of description.
register_output() is a server-side function that registers a
render function call (e.g. renderPlot({...})), assigns it to
session$output, registers the MCP output spec, and sets
up download-widget handlers. The UI overlay icons are injected
entirely by JS.
register_input(
expr,
inputId,
update,
description = "",
tooltip = as_tooltip(description),
writable = TRUE,
hint = "no_hint",
quoted = FALSE,
env = parent.frame()
)
input_hint_classes
as_tooltip(description)
register_output(
expr,
outputId,
description = "",
quoted = FALSE,
env = parent.frame(),
...,
output_opts = list(),
download_function = NULL,
download_type = c("image", "htmlwidget", "threeBrain", "no-download", "data",
"stream_viz"),
extension = NULL,
session = shiny::getDefaultReactiveDomain()
)
expr |
For |
inputId |
character string. The |
update |
character string. The fully qualified update function,
e.g. |
description |
character string. A human-readable description of
the input or output purpose, exposed to |
tooltip |
character string shown when the mouse hovers over the
input; defaults to the first sentence of |
writable |
logical (default |
hint |
character string, one of |
quoted |
logical (default |
env |
the environment in which to evaluate |
outputId |
character string. The |
... |
reserved for future use. |
output_opts |
a named list of extra options for the output (e.g. width, height defaults). |
download_function |
a custom download handler function. When
|
download_type |
character string. One of |
extension |
character vector of allowed file extension for
download, or |
session |
the |
register_input returns the evaluated UI element, with
tooltip as the title of an input (see tooltip).
as_tooltip returns the first sentence of description
as a character string ("" when it is blank).
register_output is called for its side effects (assigning
the render function and registering widgets) and returns NULL
invisibly.
init_app, mcp_wrapper
# The default hover tip: the first sentence of the description
as_tooltip("Plot threshold, e.g. 0.5. Agents set it before running.")
## Not run:
# inside a shidashi module UI function:
ns <- shiny::NS("demo")
register_input(
expr = shiny::sliderInput(
inputId = ns("threshold"),
label = "Threshold",
min = 0, max = 1, value = 0.5
),
inputId = "threshold",
update = "shiny::updateSliderInput",
description = "Filter threshold for the plot"
)
# inside a shidashi module server function:
register_output(
expr = renderPlot({ plot(iris) }),
outputId = "my_plot",
description = "Scatter plot of iris data",
download_type = "image"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.