% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mcp-wrapper.R
\name{register_io}
\alias{register_io}
\alias{register_input}
\alias{register_output}
\title{Register Shiny Inputs and Outputs for \verb{MCP} Access}
\usage{
register_input(
  expr,
  inputId,
  update,
  description = "",
  writable = TRUE,
  quoted = FALSE,
  env = parent.frame()
)

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()
)
}
\arguments{
\item{expr}{For \code{register_input}: a call expression that creates
a \code{shiny} input widget.
For \code{register_output}: a render function call such as
\code{renderPlot(\{...\})}.}

\item{inputId}{character string.  The \code{shiny} input ID
(without the module namespace prefix).}

\item{update}{character string.  The fully qualified update function,
e.g. \code{"shiny::updateTextInput"}.  Field mappings such as
\code{"shiny::updateSelectInput(value=selected)"} override the
default argument names passed to the update function.}

\item{description}{character string.  A human-readable description of
the input or output purpose, exposed to \verb{LLM} agents via \verb{MCP} tools.}

\item{writable}{logical (default \code{TRUE}).  Whether the \verb{MCP}
update tool is allowed to change this input.}

\item{quoted}{logical (default \code{FALSE}).  If \code{TRUE},
\code{expr} is treated as already quoted; otherwise it is captured
with \code{substitute()}.}

\item{env}{the environment in which to evaluate \code{expr}.}

\item{outputId}{character string.  The \code{shiny} output ID
(without the module namespace prefix).}

\item{...}{reserved for future use.}

\item{output_opts}{a named list of extra options for the output
(e.g. width, height defaults).}

\item{download_function}{a custom download handler function.  When
\code{download_type = "data"}, this function receives the file path
and writes the download content.}

\item{download_type}{character string.  One of \code{"image"},
\code{"threeBrain"}, \code{"data"}, or \code{"no-download"}.}

\item{extension}{character vector of allowed file extension for
download, or \code{NULL}.}

\item{session}{the \code{shiny} session object.  For
\code{register_output}, defaults to
\code{shiny::getDefaultReactiveDomain()}.}
}
\value{
\code{register_input} returns the evaluated UI element.
  \code{register_output} is called for its side effects (assigning
  the render function and registering widgets) and returns \code{NULL}
  invisibly.
}
\description{
Register \code{shiny} inputs and outputs for \verb{MCP} (Model Context
Protocol) agent access.

\code{register_input()} wraps a \code{shiny} input constructor to
register metadata.  It evaluates \code{expr} and returns the UI element.

\code{register_output()} is a server-side function that registers a
render function call (e.g. \code{renderPlot(\{...\})}), assigns it to
\code{session$output}, registers the \verb{MCP} output spec, and sets
up download-widget handlers.  The UI overlay icons are injected
entirely by \verb{JS}.
}
\examples{
\dontrun{
# 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"
)
}
}
\seealso{
\code{\link{init_app}}, \code{\link{mcp_wrapper}}
}
