Starts a local HTTP server and opens the MCP App in a browser. A lightweight host page emulates the MCP Apps postMessage protocol so that tools are fully functional — inputs trigger tool calls, and outputs update in real time, just like they would inside Claude Desktop.
Value
Invisibly, a list with url (the preview URL) and stop() (a
function to shut down the server).
Examples
if (FALSE) { # \dontrun{
app <- mcp_app(
ui = htmltools::tags$div(
mcp_text_input("name", "Your name"),
mcp_text("greeting")
),
tools = list(
list(
name = "greet",
fun = function(name = "world") {
list(greeting = paste0("Hello, ", name, "!"))
}
)
)
)
# Opens in browser with working inputs/outputs
srv <- preview_app(app)
# Stop when done
srv$stop()
} # }
